Getting Area Name of entity_id in a template sensor?

Hi all,

I’m trying to get the area_name for an entity_id given by Jinja2 filter.

The below is working correctly and giving me the friendly_name of the entity that matches.

{{ states.climate | selectattr('attributes.preset_mode', 'defined') | selectattr('attributes.preset_mode', 'eq', 'Override')|map(attribute='attributes.friendly_name') |list }}

Is there anyway to output the area name rather than the friendly name?

thanks!

1 Like

Okay was simpler that I thought! :sweat_smile:

the below shows the area_name:

{{ states.climate | selectattr('attributes.preset_mode', 'defined') | selectattr('attributes.preset_mode', 'eq', 'Override')|map(attribute='entity_id') |map('area_name') |list }}
5 Likes