-
Notifications
You must be signed in to change notification settings - Fork 54
Functions not triggered in the order of events #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That's a very interesting issue - the functions run asynchronously when triggered, so even if one is started before the other, the subsequent execution of the rest of the trigger function could happen in any order if they are very close in time (0.36 msec in the case you show) If the on -> off period might be very short, but off is expected to persist for some time, you could use There are likely other solutions, but |
In fact, you could just set |
This, exactly - after your first reply I realized that I might have overthought this, I had used Thanks for your help! |
I have a script that turns on a light when a person is detected and turns it off after a delay if detection stops.
The triggers are
@state_trigger("binary_sensor.person_detected == 'on'")
on one function and...=='off'
on the other, respectively.Sometimes detections are very short, the sensor entity can change value within a second, and when that happens, my functions may be triggered in the wrong order even though the events are recorded in the correct order.
An example event straight from the
events
table of HA, with timestamps and formatted dates, first turningon
thenoff
:And a snippet of the pyscript logs; the last two lines correspond to the above events, except the functions were called in the reverse order:
The result being that my light stays on indefinitely after such a "hiccup". Is this a bug or more like a fundamental system limitation where the order of triggers cannot be guaranteed at such short time intervals?
Thanks!
The text was updated successfully, but these errors were encountered: