Can state condition accept "entity_id" as variable?

Never said I thought I could do better; I was simply agreeing with wizbang that the documentation for those two features is skimpy (not just for new users). trigger_variables is particularly superficial and its explanation of “limited templates” is almost circular. wizbang is correct in saying it’s not self-evident where it can/cannot be applied (case in point, it can’t be used in a State Trigger).

I think both of you are missing the entire section below limited triggers templates that describes what is limited…

If you’d not want to read…

Pretty much everything from the home assistant state machine is not usable. Normal jinja is allowed.

Here’s what I found:

The section for Trigger Variables:

Trigger variables

Similar to script level variables, trigger_variables will be available in trigger templates with the difference that only limited templates can be used to pass a value to the trigger variable.

The section for Limited Templates (“limited templates are limited”):

Limited Templates

Templates for some triggers as well as trigger_variables only support a subset of the Home Assistant template extensions. This subset is referred to as “Limited Templates”.

If there’s more on either subject, I would appreciate a link to it.

Scroll down, or better yet, ctrl f on the word limited. It’s mentioned everywhere in the template docs about templates

Just to show you without even scrolling, in the very next section about the states methods…

I think you’re doing a great job showing how awkwardly the documentation goes about explaining the concept. Instead of providing a comprehensive definition in one place, it is spread (very) thinly throughout the documentation.

I’ve seen the States section and understand that everything in it cannot be used in a limited template (one of the reasons why I said the feature doesn’t meet my needs). I also recall the Release Notes where it provided examples of trigger_variables and limited templates but they never made it into the documentation. Anyone who didn’t read those Notes and only has the current documentation as a reference, has even fewer examples of the two concepts.

Perhaps what’s needed is one of your large red arrows (or just a link) leading from Limited templates to States.

As i said before, it works for me. In fact I learned about it today without even touching the software just by reading said docs. If it doesn’t work for you, then suggest edits. :man_shrugging: I don’t know what else can be said.

I just came by here on the search for an answer to the exact same question. And ended up reading a lot from here on. I’d like to make two points:

  1. I agree on the documentation being structured in an “interesting” way. But I believe, @petro made me understand it better. It’s just to be read like source code. Which makes sense for a frequently changing open source project, maybe.

  2. The state trigger could easily be improved to allow templates in entity_id, if a template were rendered here: core/state.py at fc539da42b910f357aa55d5a8231abb6e8aac5db · home-assistant/core · GitHub. So, the feature is just a pull request away. :wink:

As I don’t have a development setup currently, I guess, I will go with a state_changed event trigger and a condition for the time being. (Another thing I considered is to use the entity ids in the event_data, but that only supports single strings, too.)