core: Automatons ignore state trigger
The problem
When binary sensors go from “on” to “off” while waiting for a “for” statement, the “off” state doesn’t stop the “for” timer.
Environment
- Home Assistant Core release with the issue: 0.113b0
- Last working Home Assistant Core release (if known): 0.112.3
- Operating environment (OS/Container/Supervised/Core): Container
- Integration causing this issue: automation
- Link to integration documentation on our website: n/a
Problem-relevant configuration.yaml
- alias: Door Left Open
trigger:
platform: state
to: "on"
entity_id:
- binary_sensor.garagedoor
- binary_sensor.patiodoor
- binary_sensor.frontdoor
for:
minutes: 15
action:
- service: script.house_annoucement
data_template:
this_message: "{{trigger.to_state.name}} left open."
volume: 0.8
Traceback/Error logs
n/a
Additional information
In the automation example above, when the door is indeed closed within the 15 minutes, this automation still fires.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (14 by maintainers)
Thanks @bdraco I am now on a similar automation with success.
@Krocko Its caused by #37559. Harmony is too fast now.
Try this instead
It’s likely a different issue as your example has no delay or call to track same state. I’ll see if I can replicate it now that I have all the yaml
I also had the problem in 0.113.0b0 with this trigger:
Same happened with a similar
numeric_statetrigger.After upgrading to 0.113.0b1 it has not happened.
Also, looking at the code change, it makes sense – the list being iterated was changing during the iteration, which can cause weird effects like this. Copying the list using
[:]before iterating is a classic way to solve that problem. 😃Yes, I will test it after work.
This is very likely caused by same issue as #37902