You can’t build YAML configuration using templates like that.
Approach it from the other direction… set up a notifier group for each Person entity in the household, making sure the names match. For example, if your Person entity’s friendly_name is “Bob”, the notifier group should be:
notify:
- name: Bob
platform: group
services:
- service: mobile_app_bob_phone
- name: Alice
platform: group
services:
- service: mobile_app_alice_phone
- service: alexa_media_alice_bedroom_dot
Once you have your notifier groups set up you can use a template to dynamically define the list for the for_each of the Repeat action.
repeat:
for_each: >
{{ states.person | selectattr('state', 'eq' ,'home')
| map(attribute = 'name' ) | list | slugify }}
sequence:
- service: notify.{{ repeat.item }}
data:
message: There's someone at the door
There is work being done to have a single notification service and convert the existing notification services into entities to make automations like this easier to set up. Currently it has only been implemented for simpler notifiers like File.