Use new template 'expand' functionality in automation trigger?

testing:

{{ expand('group.all_lights')|
        map(attribute='entity_id')| list | join(', ')}}

creates a beautiful list of all individual lights. Wouldn’t it be magic if we could use this as part of a trigger template, instead of having to list all lights in the automation. It is in fact long longed for and currently missing functionality…

I’ve tested a few simple automation configurations, but they error out in the config check. Surprisingly not on the template, but, eg on the 'to:' field not being allowed.

Is still not possible, or am I doing something wrong

- alias: 'Notify Hub Offline'
  id: 'Notify Hub Offline'
  trigger:
    platform: template
    value_template: >
     {{ expand('group.hubs_binary_pinged')|map(attribute='entity_id')| list | join(', ')}}
#    platform: state
#    entity_id:
#      - binary_sensor.asus_router
#      - binary_sensor.ikea_tradfri
#      - binary_sensor.philips_hue
#      - binary_sensor.iungo
#      - binary_sensor.solaredge
#      - binary_sensor.timecapsule
#      - binary_sensor.synology
    to: 'off'
    for:
      seconds: 30
  condition: []

  action:
    - service: notify.notify #HA app notification
      data_template:
        title: 'Hassio Main system message: Hub offline!'

55

2 Likes

I may not have the syntax quite right here but don’t you need something along the lines of:

[{{ expand('group.all_lights')| map(attribute='entity_id')| list | join(', ')}}]

(Square brackets at the start and end.)

No, not for regular automation triggers, my template works fine perse, simply doesnt work as trigger

just to be sure: I was not talking Lovelace, where the various interpretations of templating need square brackets now and then :wink:

that is, until all custom cards will have adopted regular plain Jinja, as the new markdown card now does natively. hurrah for that.

1 Like

Did you ever get this to work? I’d be interested to know how it turned out please?