#Very small question about triggers

1 messages · Page 1 of 1 (latest)

austere lantern
#

Feels overkill to make a thread for this but here goes:

Say I have a trigger for when an entity goes from state X to "any other" for 60 s.

If the entity goes from X to Y for over 60 s the trigger fires, all good.

But what happens if the entity goes from X to Y for 45 s and then to Z for an hour? Does the trigger not fire because another state change happened before the 60 s?

I'm seeing behavior that would match this, but it seems absurd since "any other" should mean truly any other, no?

wooden pebble
#

yeah that's how it works - this is because of the way it behaves internally. it's (very simplified) looking for the "last changed" attribute to be 60 seconds ago, which updates when the state changes from Y to Z, delaying the thing activating
If you want to do this, either make a template trigger for <entity state != X> or make a binary template helper for the same and then a state trigger on that and then it will behave the way you want it to

austere lantern
#

This is very important information and good to know, thanks 👍

#

Honestly I'm kinda shocked this isn't mentioned in the documentation

#

I've been having several issues because of it

wooden pebble
#

i think it is mentioned but obliquely - basically that those triggers can only ever look at what the state used to be before it changed and what is is now. In the case of X->Y->Z it never sees all 3 at once, only X->Y for 45s (not long enough to trigger it) and Y->Z (not from X so ignore)

autumn void
#

@austere lantern also maybe share what you're trying to accomplish since there might be an alternative

austere lantern
#

Honestly the description would take a whole wall of text but the gist of it is detecting whether my robot vacuum is in a given room or not. It should trigger an automation when the robot leaves (state goes from X to any other) but I wanted to debounce it with 30 s since sometimes the robot can register as being in the next room depending on how he moves when near the doorway. Problem is, when going to the next room down the hall, 30s is plenty of time to get there, which causes the trigger to fail.

wanton bluff
#

I would make a boolean per room. Then it's on when it's in the room, and off when it is not in the room.

#

Then you can reliably detect when it has been not in the room for 60s, regardless of what's happening with the state.