Hi, trying to get a wait template to work. As far I can can see, the following should work, but it doesn’t. When I look in the log it says the script is already running, implying that the wait template did not wait and proceeded to run the script again before it ended. Any ideas why my wait template isn’t waiting?
@tom_l Good to know as I’m having similar issues. What determines how long the wait template is active? I’ve got automation actions that only fire after my mobile phone is in a state of ‘charging’ but even if its state changes to ‘discharging’ minutes later and the automation is triggered again, the wait_template is ignored as I’m assuming based on your comments that it is still active?
For those looking for an alternative method, I switched my automation around so rather than using a wait_template to wait for my phone to start charging, I use this as the trigger now but added a condition that tests to see if the stair lights were turned off in the last 5 minutes which is far more reliable.
- alias: Detect Pete in Bed
trigger:
- platform: state
entity_id: sensor.nokia_7_1_app_battery_state
from: 'discharging'
to: 'charging'
condition:
condition: and
conditions:
- condition: state
entity_id: 'person.pete'
state: 'home'
- condition: state
entity_id: media_player.sony_bravia_tv
state: 'off'
- condition: time
after: '21:00:00'
before: '02:00:00'
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp((states.light.stair_lights.last_updated)) <300)}}"