Adjusting Notify All group to select who to notify

Hi,
First posting. Hope it works…
I have created a notify.ALL_DEVICES group in my configuration.yaml so my automations can notify all members of the group through the HA app. But now I would like the members to be able to turn off some of the notifications by adjusting if they are part of the group. Anyone know how to achieve this? I can easily set a variable/input_boolean that each HA app user can set true/false to indicate if they should or should not receive the notifications, but I do not know how to use them in the configuration.yaml.
Here is my configuration.yaml:

notify:
  - name: ALL_DEVICES
    platform: group
    services:
      - service: mobile_app_johns_s_iphone
      - service: mobile_app_mums_iphone_two
      - service: mobile_app_terrys_ipad
      - service: mobile_app_dads_iphone

Hi there ,I think that it you should do this from automations and not with group platform. As far as i know template conditions to check the state of input_boolean cannot be used in config like this. I would have checked the state of input boolean in automations and carried out the notifications accordingly.

Yes but I have many automations and I created a group so I don’t have to clutter up my automations with tons of individual notifications to each one. It saves hundreds of lines in my automations to just call one service rather than multiple services each with its own data.
Is there an alternative way to do it in automations so I don’t have to repeat the code over and over?

well in that case you can create a script with these notifications and call this script from automations whenever you need to send the notifications. You can pass on the message as a variable. This should work for you.

No idea whether this would work, but it should be relatively easy to test.

Try using the group.set and group.remove services in the Developer Tools to add / remove entities on the fly and then test with a notification to the group.

If that works then you should be able to create a single automation to add / remove a notify entity from the group based on the appropriate trigger.

@sheminasalam I am not sure how to pass variables to scripts. Here’s an example of one of my simpler notifications. I cannot do this in a script as trigger would not be defined. It would be possible with variables but I am not familiar with the use of them in HA.

  - service: notify.all_devices
    data:
      message: '{{ trigger.to_state.attributes.friendly_name }} reconnected - All OK'
      title: Online notification


@TazUk Great I have not heard of group.set. Or remove. I will try that out. Sounds like a possible option if it works that way.

Okay, so I think I am getting beyond my current understanding of HA and Yaml. I only started in the last few months. I tried to read up on groups https://www.home-assistant.io/integrations/group/ but that seems to be different to the notify group I’ve created. group.set and the explanations given seem to be all about groups of entities but the notify group seems to be a group of services? I am a bit lost as to how use group.set to add additional recipients to the notify service.
Any help would be appreciated.

I’ve had a quick play and it looks like my suggestion is a red herring - I clearly shouldn’t post pre-coffee. Apologies for the confusion.

Regarding passing variables to scripts from an automation…

In the automation, you should be able to pass the values as part of the service call to the script, e.g.

  action:
    - service: script.notification_decider
      data: 
        n_message: '{{ trigger.to_state.attributes.friendly_name }} reconnected - All OK'
        n_title: "Online notification"

And then use those named parameters in the script.

    - service: notify_alldevices
      data:
        message: "{{ n_message }}"
        title: "{{ n_title }}"

I think this is how it’s done looking at my older notes, but I’ve not done this for some time so have nothing to test…

This approach will of course get more complicated if you want to add in images and other capabilities depending on the type of phones you are notifying.

The only alternative I can think of is to create multiple notify groups for every combination, or perhaps use a choose action in each automation and send the notifications without using a notify group based on who has them enabled (example snippet below)
Either of these options may get messy and wordy over time.

  action:
    - variables:
          msg: '{{ trigger.to_state.attributes.friendly_name }} reconnected - All OK'
          title: "Online notification"
    - choose:
        - conditions:
            - condition: state
              entity_id: 
                  - input_boolean.notify_john
                  - input_boolean.notify_mum
                  - input_boolean.notify_terry
                  - input_boolean.notify_dad
              state: on
          sequence:
            - service: notify.all_devices
              data:
                  message: "{{ msg}}"
                  title: "{{ title }}"
        - conditions:
            - condition: state
              entity_id: 
                  - input_boolean.notify_john
                  - input_boolean.notify_mum
                  - input_boolean.notify_terry
              state: on
          sequence:
              - service: mobile_app_johns_s_iphone
                data:
                    message: "{{ msg }}"
                    title: "{{ title }}"
              - service: mobile_app_mums_iphone_two
                data:
                    message: "{{ msg }}"
                    title: "{{ title }}"
              - service: mobile_app_terrys_ipad
                data:
                    message: "{{ msg }}"
                    title: "{{ title }}"
...etc

There’s a discussion here about a similar scenario that may prove helpful

I expect someone will chip in with better options so feel free to ignore these :slight_smile: