WTH: auto complete for states in YAML editor

We have nice drop downs for known states in the UI. But when editing YAML, any state value should be entered as string, without any guidance. This can especially be difficult when the UI languages is not English, since state names are often translated. Then it’s hard to know what the “internal” state name is you need to use in YAML. We already have autocompletion for entity IDs and icon names in YAML. It would be nice to have something similar for states.

There already was a WTH for this in 2020. Also, there is a related WHT this year, but that’s a bit broader and less concrete, and a moderator recommended me to create a separate WTH.

Also, I understand that there are still integrations that don’t publish all possible states. In that case, HA can’t know the possible states, and auto-complete is not possible in that case. However, I figure that in the majority of the cases, HA would be able to know (and thus autocomplete) the states for an entity.

This might be pretty hard because the editor doesn’t really know the context of what you’re typing in.

Entities and mdi icons start with a pretty clear prefix domain., or mdi:, so that’s how the editor gets the hint its supposed to offer autocompletions.

I don’t think we want it to popup with on and off anytime the letter o is typed, but I don’t know a good way it’s supposed to know “this string here is supposed to be an entity state”

Can’t it be triggered by states('<any entity id>')? It could use the entity id to lookup the applicable states.