"Example State": {
"plugin": "State"
},
- "Off Delay": {
- "plugin": "Wait",
- "seconds": 1.0
+ "Waiter": {
+ "plugin": "GenericWait"
},
"Delay Start after On": {
"plugin": "Alias",
- "from": { "sender": "Example State", "event": "changed", "state": true },
- "to": { "target": "Off Delay", "command": "wait" }
+ "from": {
+ "sender": "Example State",
+ "event": "changed",
+ "state": true
+ },
+ "to": {
+ "target": "Waiter",
+ "command": "wait",
+ "seconds": 5.0,
+ "id": "off delay"
+ }
},
"State Off after Delay": {
"plugin": "Alias",
- "from": { "sender": "Off Delay", "event": "finished" },
- "to": { "target": "Example State", "command": "set state", "new state": false }
+ "from": {
+ "sender": "Waiter",
+ "id": "off delay"
+ },
+ "to": {
+ "target": "Example State",
+ "command": "set state",
+ "new state": false
+ }
},
"Debug Logger": {
"plugin": "Log",
async def test_commands(websocket):
commands = [{'target': 'Example State',
- 'command': 'set state', 'new state': True},
- {'target': 'Example State', 'command':
- 'get state'}]
+ 'command': 'get state'},
+ {'target': 'Example State',
+ 'command': 'set state', 'new state': True}]
for command in commands:
message = json.dumps(command)
await websocket.send(message)
await command_task
print("Wait for 0.1 seconds for command messages.")
await asyncio.sleep(0.1)
- print("Wait for 1.9 seconds for delayed messages.")
- await asyncio.sleep(1.9)
+ print("Wait for 6.9 seconds for delayed messages.")
+ await asyncio.sleep(6.9)
async with websockets.connect(f"ws://localhost:8080/Example-Client")\
as websocket:
print("Sending commands to websocket 'Example-Client'.")
await command_task
print("Wait for 0.1 seconds for command messages.")
await asyncio.sleep(0.1)
- print("Wait for 1.9 seconds for delayed messages.")
- await asyncio.sleep(1.9)
+ print("Wait for 6.9 seconds for delayed messages.")
+ await asyncio.sleep(6.9)
if __name__ == '__main__':
asyncio.run(main())