In my automations I normally use a lot the trigger.to_state
, but as we now have the this
variable available in the latest version, I was wondering if they are actually the same thing!
They’re not the same. this
refers to the state object of the automation or script that’s running, while trigger
refers to what triggered an automation. Scripts don’t have trigger
at all, but will have this
.
Thank you @rccoleman, but I think you missed that I was comparing to trigger.to_state
(a state object), not trigger
, hence my question!
My explanation still stands. trigger.to_state is the state object of the thing that triggered an automaton (specifically, the new state). ‘this’ is the automaton or script state object itself, having nothing to do with a trigger (which again, scripts don’t have at all).
You are absolutely correct! I re-read the original post and now see I understood it incorrectly… I actually though it was the state of the object that triggered the automation, not the state for the automation itself!