I am using a value template condition to avoid firing off too many alerts. This works BRILLIANTLY for one automation, but not at all for another? Confused.
This works:
- alias: 'MQTT to say Daneboom home'
trigger:
platform: state
entity_id: group.daneboom
to: 'home'
from: 'not_home'
condition:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.mqtt_to_say_daneboom_home.attributes.last_triggered | default(0)) | int > 3600)}}'
action:
- service: mqtt.publish
data_template:
topic: "home-assistant/home"
retain: false
payload: 'daneboomhome'
but this does not??
- alias: 'Alert that Rosetta is down'
trigger:
platform: state
entity_id: sensor.rosetta_up
from: 'ALIVE'
condition:
- condition: template
value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.alert_that_rosetta_is_down.last_triggered | default(0)) | int > 360)}}'
action:
- service: notify.Daneboom_iPhone
data_template:
title: "Alarm"
message: "Rosetta is down - {{ as_timestamp(now()) | timestamp_custom('%I:%M %p %d/%m/%Y', true) }}"
target: ""
Any insights welcome!
DOH! Figured it out. Stupid me. It was the “Attributes” part of the template I was somehow missing. Sorry!!