How to Show temperature of each area?

Hi,
I have placed temperature / humidity sensors in each room.
is there an elegant way to show a list of all areas with their temperature?

I can manually add area cards to a view, but they are rather bulky. I could manually add entity cards for the temp sensors and manually rename the title to the area name, but I feel that there should be a more elegant solution. Some jinja or auto-entitities magic that creates such a table. Any advice?

entities card, note entities not entity.

Copy-paste the following template into the Template Editor and confirm it reports the correct temperature for each area.

{% for a in areas() %}
{%- set t = area_entities(a) | select('search', '^sensor.*temperature')
  | map('states') | map('float', -99)| reject('eq', -99) | list -%}
{{ area_name(a) }}: {{ t|average if t|count > 0 else '' }}
{% endfor %}

It iterates through all areas, finds all entities in the area whose entity_id starts with sensor and contains the word “temperature”, rejects any whose value is not a number, then computes the average (assuming there may be more than one temperature sensor in the area).

If some or all of your temperature sensors do not contain “temperature” in their entity_id but all have a device_class set to temperature, then use this:

{% for a in areas() %}
{%- set t = expand(area_entities(a)) 
  | selectattr('attributes.device_class', 'defined')
  | selectattr('attributes.device_class', 'eq', 'temperature')
  | map(attribute='state') | map('float', -99)| reject('eq', -99) | list -%}
{{ area_name(a) }}:  {{ t|average if t|count > 0 else '' }}
{% endfor %}

Either template can be used in a Markdown card.

1 Like