Condition Templating: Dynamic Entity ID

Hi Community,

I’m working on a little something here that will eventually end up being a condition to check the state of an input_boolean (on/off) but running into an issue with the templating side of it. I’ll show basically what I’m trying to accomplish here:

    {% set value = 'zone_enter_' + states.device_tracker.asus_z012dc.attributes.friendly_name.lower() %}
    {% set bool = states('input_boolean.{{ value }}') %}
    {{ value }}
    {{ bool }}
    {{ states.input_boolean.zone_enter_chris.state }}

The idea is I want a condition to check the state of a dynamically generated input_boolean (which already exists in config) but can’t put together how to make it a “real” value to test against, the output of the above in the template editor shows:

zone_enter_chris
    unknown
    on

Am what I’m trying to do here basically impossible or am I going about this the wrong way?

Figured it out :slight_smile:

    {% set value = 'input_boolean.' + 'zone_enter_' + states.device_tracker.asus_z012dc.attributes.friendly_name.lower() %}
    {% set bool = states(value) %}
    {{ value }}
    {{ bool }}
    {{ states.input_boolean.zone_enter_chris.state }}

Returns:

input_boolean.zone_enter_chris
    on
    on

Yay for me!