Hi everybody,
I have one particular binary_sensor
(via zigbee2mqtt
) that disconnects too often. It is a door reed sensor. In order to determine whether or not it is still connected to the network, I want to create an automation that notifies me if that particular sensor’s state.last_changed
value is older than x
.
I made a template sensor for this: {{ (as_timestamp(now()) - (as_timestamp(states.binary_sensor.zwischenzimmer_tuer_contact.last_changed))) | timestamp_custom("%H:%M", false)}}
. The door’s state has changed 6 minutes ago; the sensor’s value is 00:06
, which is correct.
However, I am not sure how to continue from here.
My automation currently looks like this
automation:
# Update the sensor every 15 minutes
- alias: "[Helper] ZZ Tür Update"
trigger:
- platform: time_pattern
minutes: 15
action:
- service: homeassistant.update_entity
entity_id: sensor.zzt_last_update
# Send notification when last_change was longer than 8 hours ago
- alias: "[Helper] ZZ Tür Notify"
trigger:
- platform: time_pattern
minutes: 30
condition:
condition: numeric_state
entity_id: sensor.zzt_last_update
# ...? what goes here?
I thought that perhaps I have to create another template sensor that equals to 08:00:00
, convert it to as_timestamp
, then work from there on… but this seems like it is way too complicated.
Is it possible to make an automation based upon this sensor (sensor.zzt_last_update
) not changing for 8 hours? Or what is the best way to create an action where there has not been an value change for this door sensor?
Thank you for your ideas