Help - macro in a template?

You may have noticed I used states.climate in the very last template. That represents all the State objects of every climate component you’ve defined. That template works in the Template Editor but not in a Template Trigger (or the value_template of a Template Sensor).

Why not? Because, in a Template Trigger, Home Assistant doesn’t automatically expand states.climate and then monitor each member for state-changes. It would be cool if it did, but it doesn’t.

You created group.all_rads. Paste this into the Template Editor and you’ll see it works equally well:

{{ expand('group.all_rads') | selectattr('attributes.preset_mode', 'eq', 'permanent') | list | count  }}

That expand function sure looks handy. Maybe it works in a Template Trigger? Nope, not the way we would want. What Home Assistant sees is group.all_rads and will monitor it for state-changes and not the group’s members (which would be more useful for our purposes).

If you think it would be useful to have Home Assistant monitor the group’s members (when it sees expand used in a Template Trigger) then you may wish to cast a vote for this Feature Request: