-
Notifications
You must be signed in to change notification settings - Fork 34
/
script_use_zha_devices.yaml
39 lines (39 loc) · 1.42 KB
/
script_use_zha_devices.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
---
alias: Loop over zha_devices, extract some device data
sequence:
- parallel:
- sequence:
- wait_for_trigger:
- platform: event
event_type: zha_devices_ready
- service: system_log.write
data:
logger: zha_devices
level: error
message: '{{ "Got event %s" % ( wait.trigger.event.data.devices ) }}'
- service: system_log.write
alias: List unavailable only
data:
logger: zha_devices
level: error
message: >
{% set ns = namespace(names=[]) %}
{% for item in wait.trigger.event.data.devices if not item.available %}
{% set ns.names = ns.names + [ "'%s'" % (item.name) ] %}
{% endfor %}
Items: {{ ns.names | join(', ') }}
- repeat:
for_each: "{{ wait.trigger.event.data.devices }}"
sequence:
- service: system_log.write
data:
logger: zha_devices
level: error
message: >-
{{ "Item '%s' Power: %s dBm Available: %s" % (
repeat.item.name, repeat.item.rssi, repeat.item.available
) }}
- service: zha_toolkit.zha_devices
data:
event_done: zha_devices_ready
mode: single