I have a template which should read true when Home Assistant has been up for more than 30 seconds.
"{{ (as_timestamp(now()) - as_timestamp(states('sensor.uptime'))) > 30 }}"
What’s curious is that I can test this using Developer/ Tools.Template/Template Editor and see that it evaluates to true but when the following automation runs, the trace shows that it evaluates to false.
alias: Power Disconnected
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.inverter_grid_connected_status
from: "on"
to: "off"
for:
hours: 0
minutes: 0
seconds: 10
conditions:
- condition: and
conditions:
- condition: time
after: "06:00:00"
before: "21:00:00"
- condition: template
value_template: >-
"{{ (as_timestamp(now()) - as_timestamp(states('sensor.uptime'))) > 30
}}"
actions:
- action: notify.pushover
metadata: {}
data:
title: Grid Power Disconnected
message: Grid Power Disconnected
data:
sound: no_power
priority: 0
mode: single
here is the trace…
and here is the test of the template…
And here are the specifics on sensor.uptime
Surely I must be missing something very basic here… Any help is appreciated.