Hi!
I used this automation a while ago, which sent me a notification when a Zigbee device was no longer reachable.
The peculiarity was that every so many hours it sent me the notification with the updated time.
For example:
Zigbee Devices Offline:
Bedroom Light - from 5 hours
After 2 hours…
Zigbee Devices Offline:
Bedroom Light - from 7 hours
Unfortunately it doesn’t work anymore. If I trigger the automation manually, only the message arrives but without the entity.
At the scheduled times, however, the message does not even arrive, the automation does not trigger (probably a problem with the condition?)
- alias: ALERT Zigbee Offline Devices
id: zigbee_device_missing_alert
trigger:
- platform: time
at: "07:00"
- platform: time
at: "16:00"
- platform: time
at: "20:00"
condition:
- condition: template
value_template: >
{% set ns = namespace(break = false) %}
{% for state in states -%}
{%- if state.attributes.last_seen %}
{%- if (as_timestamp(now()) - as_timestamp(state.attributes.last_seen) > (5 * 60 * 60) ) and ns.break == false %}
{%- set ns.break = true %}
true
{%- endif -%}
{%- endif -%}
{%- endfor %}
action:
- service: notify.notification_service
data:
title: Z2M DEVICE ALERT
message: >
Zigbee Devices Offline:
{% macro GetDroppedZigbee() -%}
{% for state in states.sensor -%}
{%- if ("linkquality" in state.name and state_attr(state.entity_id, "last_seen") != None and (as_timestamp(now()) - as_timestamp(state_attr(state.entity_id, "last_seen")) > (5 * 60 * 60))) -%}
{{ state.name | regex_replace(find=' linkquality', replace='', ignorecase=False) }} -- Da {{ ((as_timestamp(now()) - as_timestamp(state.attributes.last_seen)) / (3600)) | round(0) }} ore {{- '\n' -}}
{%- endif -%}
{%- endfor %}
{%- endmacro -%}
{{ GetDroppedZigbee() }}
What could be the problem? I just can’t solve it
Thanks
1 post - 1 participant