This automation runs every time after a reboot (not meant to), i guess the sensor goes from something to a value below 5. But what that value is i can’t see or figure out, i’m hoping it’s unknown.
Now I could use the current condition and check for uptime, but it seems more appropriate to check the sensor for a unknown condition (so i know it transitioned from unknown to a known value ?
I couldn’t find the syntax of how to check for the last transitioned state. I also couldn’t see it in the history_stats (maybe it doesn’t ever have a unknown state?)
Any help would be appreciated here.
alias: Announce when car is x amount of minutes away from home (arriving)
description: test
trigger:
- platform: numeric_state
entity_id: sensor.waze_travel_time_2
attribute: duration
below: "5"
condition:
- condition: template
value_template: >-
{{ ( as_timestamp(now()) - as_timestamp(states('sensor.uptime'))) // 60 >
1 }}
action:
- service: notify.alexa_media_everywhere
data:
data:
type: announce
method: all
message: >-
"Car is expected to arrive home in {{
state_attr('sensor.waze_travel_time_2','duration')|round(1) }} minutes"
mode: single