I would suggest to use trigger.to_state.state like you did in the 2nd if statement.
That will check on the state which caused the trigger.
Technically, the state could have changed between the trigger, and the actual execution of the action sequence. So if you want to be sure you are checking on the actual state, you could use states(trigger.entity_id). But that should only make a difference if you have like delays in your automation before this state is tested.
It is not a stretch to think that trigger is an ephemeral entity with a number of states. But, alas, it is not.
After searching the HA documentation I could not find where states() is documented? I did find examples, but examples are just that, examples and not definitive. If it is, indeed, not documented, where should it be docuemented?
What, then, is trigger and where is that documented?
Going forward, I will try to remember your response. I would like the reference, too, because the answers found on the forum are not part of the documentation. In addition, my memory is fallible.
When you write {{ states('sensor.outdoor_temperature') }} , Home Assistant looks up that exact entity ID and gives you back its state. It is that direct.
This is an example. A definition would be:
states( name ), where name is a string which refers to the state entity ID of an existing entity
I see from your reference that:
trigger is a "Home Assistant extension template variable"
trigger is an object. Specifically a dictionary that changes based on the trigger that occurs in the automation. It's not text. What you're seeing is object oriented code. When text or words are not wrapped in quotes, they are objects, functions, macros, filters, tests, or keywords for Jinja. When words are wrapped in quotes, it is a string. This is the same concept for all coding languages.
The links to the documentation are an important part of the answer because they provide authoritative supporting details where as replies in the forum, while often helpful, are not documentation.
The function states() requires a valid entity ID string as its first argument. As petro pointed out, most of what you see in a template is text, but not all of that text represent string data.
No, trigger is a built-in variable. Its value is applied when a trigger fires in an automation or trigger-based template entity. The value held by that variable is a dictionary object. The exact structure and contents of that object depend on the type of trigger that generated it.
The to_state property of the variable trigger (trigger.to_state) would return the entire new State Object of the triggering entity at the time the trigger fired. Following that logic and syntax, trigger.to_state.state returns the new state value of the triggering entity.
The string "trigger.to_state" is an invalid argument for the function states() because it is not a valid entity ID string.
A valid entity ID string, for example "light.above_tv", is composed of:
A valid entity domain like "light".
A valid object ID like "above_tv"
There is no entity domain "trigger" in HA, therefor "trigger.to_state" cannot be a valid entity ID string.