Counting number of thermostats where HVAC_action is heating

I have 4 thermostats one one floor, 5 on another and 3 on another floor (12 in total).

I want to create a template sensor to know how many thermostats are on for any given floor.

the following works for all thermostats:

{{ states.climate | selectattr('attributes.hvac_action','eq', 'heating') | list | count }}

However, this counts all 12 thermostats.

I tried specifying the individual thermostats but this isn’t working (it gives a result of 0 when they are on) - see below the code I used for the ground floor as an example - I listed all the entities and deleted “attributes.”). Any help much appreciated!

{{ ('climate.1_ground_landing_and_toilet_neo', 'climate.2_lounge_neo', 'climate.3_office_neo', 'climate.4_kitchen_neo') | selectattr('hvac_action','eq', 'heating') | list | count }}
1 Like

If you use the floors finctionality, you can do this for each floor:

{{ floor_areas('first') | map('area_entities') | sum(start=[]) | select('match', 'climate.') | map('state_attr', 'hvac_action') | select('eq', 'heating') | list | count }}

If you just want to hard-code the entities, you can do this:

{{ ['climate.1_ground_landing_and_toilet_neo', 'climate.2_lounge_neo', 'climate.3_office_neo', 'climate.4_kitchen_neo'] | map('state_attr', 'hvac_action') | select('eq', 'heating') | list | count }}
2 Likes

This works. Thanks so much @mekaneck

1 Like

Can I ask what your overall goal is?

Are you trying to achieve some priority call per floor system, call based on number of thermostats calling, or simply trying to clean up HA?

My goal is just to declutter the dashboard as much as possible. If I want to drill down into items on the dashboard I can do so. But I’m all about a visually
minimal dashboard but keeping max functionality.

1 Like