I saw @sjee mentioned that you can use state.last_changed
as part of an automation here.
What I’m trying to achieve is to have the automation (notification) only occur if the state has not been updated in the last 10 seconds. I’m having a hard time integrating this into my automation. I tried adding a template condition to the automation, but then it never runs as it seems to always be low. Without, the notifications operate fine, but I’m trying to prevent the notification from firing when I trigger the door from the UI.
condition:
- condition: template
value_template: '{{ as_timestamp(now()) - as_timestamp(states(switch.sensor.garage_door_control.last_updated)) < 10 }}'
The overall automation:
- alias: Notify iOS Garage
initial_state: true
hide_entity: true
trigger:
- platform: state
entity_id: cover.garage_door
from: 'closed'
to: 'open'
# condition:
# - condition: template
# value_template: '{{ as_timestamp(now()) - as_timestamp(states(switch.sensor.garage_door_control.last_updated)) < 10 }}'
action:
service: notify.ios_dkphone
data:
title: "Garage Alert"
message: "GARAGE IS OPEN"
data:
push:
badge: 0
category: 'garage1'