I’m getting the following error, when trying to save an automation that includes a template in the Actions block.
Message malformed: template value should be a string for dictionary value @ data[‘action’][0][‘data’]
Testing the template section with developer tools shows no errors and delivers the expected results. Deliver a list of all lights that are part of any light group.
Are you missing a closing bracket after selectattr('entity_id', 'in', states.light? Also, I think you have a surplus bracket after one of your list filters.
Unfortunately yes. I can save the automation without problem when I leave the template empty.
This action is the first action in the automation
The difference is, that I want to extract all entities that are members of groups. Your short version just extracts group entity. I’m able to save your template version with the automation.
In my original post I unfortunately inserted some test code for just one light group. I updated this later.
selectattr('name', 'eq', 'Leuchte') selects one specfic light group selectattr('entity_id', 'in', integration_entities('group')) selects all light groups
Without “selectattr” this delivers for the lights group only entities related : binary_sensor.xyz.update_available
not the light entity itself, with selectattr in the query the result list is empty.
So what is “as suggested” because it’s unclear what you want the template to do. You said this:
I want to extract all entities that are members of groups
Yet your own template doesn’t do that; it attempts to extract only light entities. That’s why I posted a template that extracts all light entities that are members of any group.
A “light group” isn’t a group entity, it’s a special light entity with an entity_id attribute containing a list of other light entities.
This template finds all “light group” entities by extracting all light entities containing an entity_id attribute. Then it expands them and lists their members.
Many thanks for the explanation of how to extract the light entities within a light group. This approach doesn’t generate errors in automations and also works elsewhere, e.g. with a template applied in lovelace cards (e.g. custom:auto-entities).