Just an update since there are now sensors for the last seen values
- alias: Zigbee Device Missing Alert
id: zigbee_device_missing_alert
trigger:
- platform: time
at: '10:00'
- platform: time
at: '20:00'
condition:
- condition: template
value_template: '{% set ns = namespace(break = false) %}
{% for state in (expand(states.sensor,states.binary_sensor, states.light, states.switch) |selectattr(''entity_id'', ''search'', ''last_seen'')) -%}
{%- if (as_timestamp(now()) - as_timestamp(state.state) > (60 * 60 * 8)) and ns.break == false %}
{%- set ns.break = true %}
true
{%- endif -%}
{%- endfor %}'
action:
- service: notify.mobile_app_pixel_4a
data:
message: "Some Zigbee devices haven't been seen lately... {% for state in (expand(states.sensor,states.binary_sensor,
states.light, states.switch) |selectattr('entity_id', 'search', 'last_seen') -%} {%- if (as_timestamp(now()) - as_timestamp(state.state) > (60 * 60 * 8)
) %} {{ ((as_timestamp(now()) - as_timestamp(state.state)) / (3600)) | round(1)
}} hours ago for {{ state.name }} {{'\r\n'}} {%- endif -%} {%- endfor %}"