-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathhaswitches.yaml
40 lines (39 loc) · 1.21 KB
/
haswitches.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: haswitches
doc: |-
When the garden detector is ON, turn on the switch. When the
detector is OFF, turn off the switch.
This spec is solely for a Home Assistant demo.
patternsyntax: json
nodes:
start:
branching:
type: message
branches:
- pattern: |
{"type":"event","event":{"data":{"entity_id":"binary_sensor.garden","new_state":{"state":"on"}}}}
target: on
on:
action:
interpreter: ecmascript
source: |-
_.out({to: {mid: "ws"}, payload: {type:"call_service","domain":"switch","service": "turn_on","service_data":{"entity_id":"binary_sensor.garden"}}});
return _.bindings;
branching:
branches:
- target: waitForOff
waitForOff:
branching:
type: message
branches:
- pattern: |
{"type":"event","event":{"data":{"entity_id":"binary_sensor.garden","new_state":{"state":"off"}}}}
target: off
off:
action:
interpreter: ecmascript
source: |-
_.out({to: {mid: "ws"}, payload: {type:"call_service","domain":"switch","service": "turn_off","service_data":{"entity_id":"binary_sensor.garden"}}});
return _.bindings;
branching:
branches:
- target: start