Include grouped input booleans that are on in a notification?

Wondered if someone might be able to point me in th right direction please…

I use input booleans to trigger some automations, with the automations turning them back off once complete.
With the booleans added to a dashboard and used to start the automations, it shows when an automation’s currently running.

I’ve grouped the toggles like this in my configureation.yaml:

group:
  all_toggles:
    name: "All toggles"
    entities:
     - input_boolean.1
     - input_boolean.2
     - input_boolean.3

…and then used this in an automation:

if:
  - condition: state
    entity_id: group.all_toggles
    state: "on"
then:
  - service: notify.mobile_app_myphone
    metadata: {}
    data:
      message: Toggle is on
      title: Toggle is on
else:
  - service: notify.mobile_app_myphone
    metadata: {}
    data:
      message: Toggles are off
      title: Toggles are off

Is there a way to include a list of boolean friendly names from the group that are currently on in the notification sent from the automation? Preferably one on each line if possible?
So the notification message would be something like:

These toggles are on:
Toggle 1
Toggle 3

I’ve been searching and trying all sorts of variations, but not managed to figure it out.
Thanks a lot

Yes, however if you trigger from a group, the trigger fires when the first boolean turns on, so it is unlikely to return more than one value unless they are otherwise entrained. As long as at least one boolean is on, the trigger will not fire for subsequent booleans turning on.

If the trigger is individual booleans instead of the group, you can use the select() filter to pull the “on” entities from the list provided by the entity_id attribute.

if:
  - condition: state
    entity_id: group.all_toggles
    state: "on"
then:
  - service: notify.mobile_app_myphone
    metadata: {}
    data:
      title: Toggle is on
      message: |
        {{ expand(state_attr('group.all_toggles', 'entity_id') | select('is_state', 'on')) 
        | map(attribute='attributes.friendly_name') | join('\n')}}
else:
  - service: notify.mobile_app_myphone
    metadata: {}
    data:
      message: Toggles are off
      title: Toggles are off

Yup here’s some code for my group binary_sensor.alarm_sensors

This essentially iterates the group to show the states

service: notify.telegram
data:
  title: "*HOME ALARM TRIGGERED*"
  message: |
    {{ now().strftime('%H:%M:%S %A %d %B %Y') }}
    {% for sensor in state_attr('binary_sensor.alarm_sensors', 'entity_id') %}
    {{ state_attr(sensor, 'friendly_name') }}={{ states(sensor)}}{% endfor %}
service: notify.email
data:
  title: HOME ALARM TRIGGERED
  message: >
    <b>{{ now().strftime('%H:%M:%S %A %d %B %Y') }}</b> <p> <table border="1"
    width="100%" cellpadding=2 cellspacing=2> {% for sensor in
    state_attr('binary_sensor.alarm_sensors', 'entity_id') %}<tr><td>{{
    state_attr(sensor, 'friendly_name') }}</td><td>{{ states(sensor)
    }}</td></tr> {% endfor %} </table>
enabled: true

Thanks, and so quick!

I’ve been triggering from a single boolean, then would like to list any that are on in a notification.

Using this:

message: |
  {% for sensor in state_attr('group.all_toggles', 'entity_id') %}
  {{ state_attr(sensor, 'friendly_name') }}={{ states(sensor)}}{% endfor %}

Sends a notification that lists all group members and their state:

Boolean 1=on
Boolean 2=off
Boolean 3=on

Its a lot closer than I was, but is there a way to only include them if they’re on, and without the state listed please?
So it’d be just

Boolean 1
Boolean 3

removing

={{ states(sensor)}}

drops the =state bit, but all group memebrs are listed…

Thanks again

The key is to pipe through select
| select('is_state', 'on')

{% for sensor in state_attr('binary_sensor.alarm_sensors', 'entity_id') | select('is_state', 'on')  %}
    {{ state_attr(sensor, 'friendly_name') }}={{ states(sensor)}}{% endfor %}

{% for sensor in state_attr('group.all_toggles', 'entity_id') | select('is_state', 'on')  %}
 {{ state_attr(sensor, 'friendly_name') }}{% endfor %}

…did it. Thanks a lot

If I might go back a step though… This is so that I can get a notification about any automations that were running as I restart homeassistant.
Triggering on home assistants start, it now lists any that might need attention, which is just what I was hoping for.
It’s not a situation I find/create very often, but it’s good to know when it comes up.

Is there any better way to deal with that though, or any way for home assistant to continue where it left off with any automations after being restarted?