mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-09 18:40:14 -04:00
54 lines
2.1 KiB
YAML
54 lines
2.1 KiB
YAML
template:
|
|
- sensor:
|
|
- name: "Alive ZWave Devices"
|
|
unique_id: template_sensor_alive_zwave
|
|
state: >-
|
|
{{ expand(integration_entities('Z-Wave JS') )| selectattr("entity_id", "search", "node_status") |
|
|
selectattr('state', 'in', 'alive') |
|
|
map(attribute='entity_id')| list | count | int(default=0)}}
|
|
|
|
- name: "Dead ZWave Devices"
|
|
unique_id: template_sensor_failed_zwave
|
|
state: >-
|
|
{% if states('sensor.alive_zwave_devices')|int(default=0) > 0 %}
|
|
{{ expand(integration_entities('Z-Wave JS') )| selectattr("entity_id", "search", "node_status") |
|
|
selectattr('state', 'in', 'dead') |
|
|
map(attribute='entity_id')| list | count | int(default=0)}}
|
|
{% else %}
|
|
0
|
|
{% endif %}
|
|
|
|
automation:
|
|
- id: automation_alert_failed_zwave_nodes
|
|
alias: Ping Dead Zwave Nodes
|
|
description: "Iterates through a list of dead ZWave Nodes and calls a service to press the Ping button"
|
|
mode: single
|
|
max_exceeded: silent
|
|
trigger:
|
|
- platform: state
|
|
entity_id: sensor.dead_zwave_devices
|
|
condition:
|
|
- condition: template
|
|
value_template: '{{ states("sensor.dead_zwave_devices")|int(default=0) >0 }}'
|
|
action:
|
|
- repeat:
|
|
while: '{{ states("sensor.dead_zwave_devices")|int(default=0) > 0 }}'
|
|
sequence:
|
|
- action: button.press
|
|
target:
|
|
entity_id: >-
|
|
{% set list =
|
|
expand(integration_entities('Z-Wave JS') )| selectattr('entity_id', 'search', 'node_status') |
|
|
selectattr('state', 'in', ['dead', 'unavailable', 'unknown']) |
|
|
map(attribute='entity_id')| list %}
|
|
|
|
{% set ns = namespace(buttons=[]) %}
|
|
{% for d in list %}
|
|
{% set ns.buttons = ns.buttons +
|
|
['button.' ~ (states[d].object_id.split('_node')[0]) ~ '_ping'] %}
|
|
|
|
{% endfor %}
|
|
{{ns.buttons}}
|
|
- delay:
|
|
seconds: 1
|