Why is this automation being triggered 3 times on state changes?

I am testing some triggers for automation with temp from multisensors, and did a simple automation to fire a telegram message to myself.



Notification in Telegram:

I’m trying to figure out why this is causing 2 or 3 messages to be sent (not always the same number, but seems to always be more than 1). There’s something going on with the state change that I don’t understand.

Because you have not specified a from or to state the automation will fire whenever the state or attributes of the sensor change.

1 Like

If you want it to be triggered every time the temperature changes, you could add a Template condition with this as the value_template:

{{ trigger.to_state.state != trigger.from_state.state }}

You could tweak this to only do it if it changes by more than a certain number of degrees by something like this

{{ (trigger.to_state.state | float - trigger.from_state.state | float) | abs >= 5}}

That will only apply if the absolute difference between the old and the new state is at least 5 degrees.

1 Like

@tom_l Thanks! I had no idea attributes were even changing during this time but makes sense. Wish it was easier to just dump out the states and attributes changes more easily.

@Steven_Rollason Thanks so much. You over delivered by anticipating my next question. I just added a template condition to that automation. Much appreciated! I had no idea that you could get the from and to states with that generic of a statement.