It works without the condition, but with the condition, it won’t.
I want to notify of motion when there has been no motions for 1 hour.
I have already tried removing the “-” from “- condition: state”
I have already tried putting standby in my condition in quotes.
- id: '1546401232053'
alias: notification
trigger:
- entity_id: sensor.sn1_pir
from: standby
platform: state
to: motion detected
condition:
- condition: state
entity_id: sensor.sn1_pir
state: standby
for:
hours: 1
minutes: 1
seconds: 1
action:
- data:
data:
push:
thread-id: home-assistant-informational
message: Motion detected in office
title: Motion detected
service: notify.notify
You don’t need it as a separate condition. Make it part of the trigger like this:
- id: '1546401232053'
alias: notification
trigger:
- entity_id: sensor.sn1_pir
from: standby
platform: state
to: motion detected
for:
hours: 1
action:
etc.
Edit: I misread what you’re asking. Disregard.
It doesn’t work with the condition because the condition is only true when the state has been standby
for the last one hour, one minute and one second, including now. But the trigger is firing when the state has changed to motion detected
. So, the condition can’t possibly be satisfied that way, because by the time it is being evaluated, the state is no longer standby
.
What you want is something like this:
condition:
condition: template
value_template: >
{{ (now() - trigger.from_state.last_changed).total_seconds() / 3600 > 1 }}
trigger.from_state.last_changed
is the time when the state changed to standby
(given how your trigger is defined.)
This worked flawlessly, thank you very much.
My only question is what code is that being used in the value template config. I want to read more about it so in the future I can write my own, hope that makes sense lol
See Template Condition, as well as the links that section references.