I think that’s it it’s not reading it as a list because of the join etc. Quotes yes brackets no and remove the join. Then I BELIEVE it will see the data passed in as a LIST not a dict.
Card actions almost never support templating. You need to place your templated action in a script, then call that script from the card action.
Other issues:
All templates must be surrounded by quotes or be preceded by a multi-line quote indicator.
It’s not likely to be a big problem in this case where you are listing covers in a single room, but it is best practice to use a attribute to store a list. States are strings with a 255 character limit, so a long list of entity IDs may get truncated and break your action.
Attributes are currently only configurable via YAML.
This is how I would typically set it up, so the state returns a count of open windows and the attribute entity_id returns the entity ids (like it does for group helpers).
So what I currently have is two scripts for one room - one for open and one for close. What I’m trying to do is to be more dynamic. Is it possible to have one script and call it using parameters for the open/close operation and for the area? If so, how would the script look like and how would the call look like? I was searching for that but came accross different approaches and none of them worked for me. Also the sensor: Would it be possible to dynamically generate attributes for each area in one sensor and then fill those with the names of the window entities?
Yes, but you will have to tell us how you plan on handling the Area part. Will the sensors follow a specific ID convention that contains the Area? Will you assign the sensor to the Area or give them a label? Basically, we need to know how the sensor will be linked to the area so we can construct a template that leverages that link to get the sensor’s entity ID.
alias: fenster-control
description: ""
fields:
target_area:
name: Area
description: The Area with the windows you want to control
example: Buro
selector:
area:
multiple: false
entity:
domain: cover
action:
name: Cover Action
description: The window cover action you want to perform
example: open
selector:
select:
options:
- open
- close
sequence:
- action: cover.{{action}}_cover
target:
entity_id: |
{# For this example I'm assuming you are using a strict ID convention for your sensors #}
{% set entity = 'sensor.fenster_' ~ target_area|slugify %}
{{ state_attr(entity, 'entity_id') }}
data: {}
Then, instead of calling a toggle action in your card, call the script directly as a service with the appropriate service data.