A little help with RejectAttr please

Hi,

I’m looking to count my active climate devices… I have a mixture of air conditioning units and more typical heating devices.

I’ve created the following template:

{{ (states.climate) | selectattr('state','eq','heat') | rejectattr ('hvac_action','eq','idle') | list | count }}

Basically it’s not excluding climate devices where the hvac_action is idle.

I think I can see why as the hvac_action would normally be referred to a state_attr but I don’t know how to reflect this in the syntax here or if that’s possible?

Screenshot below of an example entity that I want to exclude.

Thanks
Barry

does this work?

{{ (states.climate) | selectattr('state','eq','heat') | rejectattr ('attributes.hvac_action','eq','idle') | list | count }}
1 Like

It does! Easy when you know how!

Many thanks
Barry

1 Like