Is_state() vs .state ==

Can someone explain why this does not work…
is_state('trigger.to_state','on')

But this does in an automation action?
trigger.to_state.state == 'on'

My understanding is that “trigger.to_state” and “trigger.from_state” are supposed to be valid state objects, but the is_state() method does NOT like it.

See pnbruckner’s answer here:

No. That doesn’t make sense. Thats not an answer, but a workaround.

That would be the current state of the entity that triggered the automation when called, not the exact state that triggered the object. Between the time the automation was triggered and when trigger.entity_id is called, that entity could have changed state again. Thats bad logic.
With that methodology, you could still never access “from_state”.

So if it makes it less complicated, I’ll revise my question…

Can someone explain why this does not work…
is_state('trigger.from_state','on')

But this does in an automation action?
trigger.from_state.state == 'on'

I get what you are saying but that’s the way it currently works. Feel free to propose a feature request.