Correct syntax to count group members based on attribute

I have a bunch of TRVs (appear as climate entities) in a group. I simply want the best way to count how many of these have a hvac_action attribute of heating.

I have it working with

{{ expand('group.active_trvs') | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count}}

which is fine but the docs say

Avoid using states.sensor.temperature.state , instead use states('sensor.temperature') . It is strongly advised to use the states() , is_state() , state_attr() and is_state_attr() as much as possible, to avoid errors and error message when the entity isn’t ready yet (e.g., during Home Assistant startup).

and gives examples like

{{ ['light.kitchen', 'light.dinig_room'] | select('is_state', 'on') | select('is_state_attr', 'brightness', 255) | list }}

but attempting to convert this as

{{ expand('group.active_trvs') | select('is_state_attr','attributes.hvac_action', 'idle') | list | count }}

results in

AttributeError: 'TemplateState' object has no attribute 'lower'

which I guess is because it returns a TemplateState object not a standard State object ??

Also appears hit and miss as to when I need to include the attributes. or not.

I am able to do this using entity_ids using

{% set trvs = [
  state_attr('climate.bedroom_thermostat' , 'hvac_action'),
  state_attr('climate.lounge_thermostat' , 'hvac_action')
] %}
{{ trvs | select ('eq', 'heating') | list | count}}

but I really want to use the group so I can set that dynamically to be different TRVs using the group.set service.

Ultimately what is the best way to create a binary sensor that checks whether any entity currently in the active_trvs group has a hvac_action or heating that won’t error when HA starts etc.