So, I have a few speakers all over my house and I currently use them VERY frequently to announce house status things (like “Washing machine is done”, “Front door is now open”, or “Motion detected in the garage”). However, I generally have played all the speakers at the same time but now I want to start paying attention to each room where there’s a speaker and setting an activity state for each room into a binary_sensor, such as:
binary_sensor.garage_occupancy would look something like
{{ is_state('cover.garage_bay_door', 'open') or
is_state('cover.toy_garage_bay_door', 'open') or
is_state('binary_sensor.garage_front_man_door', 'on') or
is_state('binary_sensor.garage_rear_man_door', 'on') or
is_state('binary_sensor.garage_to_house_door', 'on') or
is_state('binary_sensor.garage_bay_motion_detected', 'on') or
is_state('binary_sensor.garage_bay_motion_detected_near_man_door', 'on') or
is_state('binary_sensor.toy_garage_bay_motion_detected', 'on') }}
So, the binary_sensor can tell me if I need to announce on the media_player.garage speakers. That seems to work quite well and I can build one of these template binary_sensors for each room to enable/disable that room’s media_player speaker (based on the custom set of things that may be triggered by someone being in the room).
HOWEVER, I’ve run into a problem while thinking about the automation. I could easily write the automation with a big parallel block which issues several tts.speak commands, one for each room but that wouldn’t be great since I think the synchronization of all the speakers would be bad. I am figuring it would be better to build the automation to create a list of the rooms which have active occupancy and at the end of the automation issue a single tts.speak with the list of rooms. Something like this (with activity detected in the master bedroom, living room, and garage):
action: tts.speak
metadata: {}
target:
entity_id: tts.piper_hassio
data:
cache: false
message: '{{ message }}'
media_player_entity_id:
- media_player.master_bedroom
- media_player.living_room
- media_player.garage
So, does anyone know how to make an automation which creates and modifies a dynamic list of entities and eventually executes an action at the end with the dynamic list? I can’t seem to wrap my head around how to do that. ![]()

