#Entity within a template variable

1 messages · Page 1 of 1 (latest)

thorn cape
#

I am trying to control my blinds via a double tap of my light switch, I have lights switches and blinds in lots of rooms so I want one automation to do this throughout the house. The light switch stores the number of taps in an event entity. If I set the automations to trigger based on a change to that entity I can then run a query to get the area of that entity and control the blind in that area.

What I am stuck on is the entity is passed into the variable trigger.entity_id but I don't want to query trigger.entity_id I want to query the entity it contains.

I am using {{ expand('{{ trigger.entity_id }}')|map(attribute='entity_id')|map('area_name')|unique|join(', ') }}

It works if I replace trigger.entity_id with the actual entity name but what do I need to do to run the query on the entity within the trigger entity?

mortal galleon
#

In my opinion you share way to little of that event. How do you make that? What does it look like?

thorn cape
#

the event entity is part of the device which is part of the LightwaveSmart integration. Don't get to hung up on the entity itself I think this is more a gap in my understanding of Jinja. For example the entity is called event.lights_smart_switch_pair the automation triggers based on a change to that (but also the equivalent entity in about 5 others rooms)

I know that {{ expand('{{ event.lights_smart_switch_pair }}')|map(attribute='entity_id')|map('area_name')|unique|join(', ') }} will return the Area name.

I know that trigger.entity_id has a value of event.lights_smart_switch_pair so how do I find the area of event.lights_smart_switch_pair only referencing trigger.entity_id.

I have a feeling the answer will be simple and make me feel really stupid

#

just realised I made it far too complicated and can use {{area_name(trigger.entity_id)}}.