Template for Counting Radiators Heating - Using Specific Attribute

Hi all - after successfully creating sensors to count both the number of lights on and doors open, I’m struggling to achieve the same with the number of radiators heating.

The key difference is that rather than counting the state itself, I need to count a specific attribute (‘is_heating’) for all my climate entities. I can draw out a result from a template using {{ state_attr('climate.wiser_bedroom', 'is_heating') }} - this returns false when off, and true when the radiators are on.

How can I use this to build a count for all the climate entities whose ‘is_heating’ attribute = true?

Huge thanks!

{{ states.climate | selectattr('attributes.is_heating', 'defined')
   | selectattr('attributes.is_heating', 'eq', true) | list | count }}

If all of your climate entities have an is_heating attribute then you can eliminate the the first selectattr filter.

{{ states.climate | selectattr('attributes.is_heating', 'eq', true) | list | count }}
1 Like

Ahhhhhhhhhhhhh I had ‘true’ when I tried this earlier - hadn’t realised I needed to lose the quotations! Huge thanks :slight_smile:

1 Like