Creating a Notify Group automatically, with all connected mobile apps

I would like some notifications to be sent to all connected mobile apps. I do rotate phones in use fairly often for work reasons. It would be great to have HA automatically add mobile apps to an “all_mobile_apps” Notify Group, every time a new mobile app connects. I have been exploring whether this type of construct is possible in HA but couldn’t find a solution.

HA supports:

notify:
  - name: all_mobile_apps
    platform: group
    services:
      - service: mobile_app_phone1
      - service: mobile_app_phone2
...

I would need something like:

notify:
  - name: all_mobile_apps
    platform: group
    services:
      - service: mobile_app_*
...

Any hint or idea on how to approach this?
Ideally mobile apps would get added to the group as they connect to the HA server. Alternatively, restarting HA after switching phones would work as well - at least not having to touch HA configuration every time would be a time saver (and also prevent problems)

Look here

Hello, it doesn’t seems to solve your problem right? Were you able to find one? I am looking for something similar: To have notify group refreshed automatically with new mobile devices, or to have mobile_app_* in the notify group.

I’ve just started using companion app notifications, and it feels like the UI support is far behind what’s possible with the amazing set of features (especially on Android).

To help me out, and to make it feel like my work will scale, I’ve made my own utility script where I’ve used the fields feature to give names and descriptions to some of the options. In my script I also then hard-code the few devices I send alerts to.

Then, in my automations, I can just call that script and choose which (or all) of the devices to send alerts to, and what sort of alerts.

The most interesting thing (that feels like a partial answer to the OP) is that you can set a variable that defines the entire service call payload, so that you don’t need to duplicate your alert info. You’ll see that called data_payload below.

Script:

alias: UTILITY - Alert
mode: queued
fields:
  alert_device_1:
    name: Alert Device 1
    description: Whether to alert device 1
    selector:
      boolean: null
    default: false
    required: true
  alert_device_2:
    name: Alert Device 2
    description: Whether to alert device 2
    selector:
      boolean: null
    default: false
    required: true
  title:
    name: Title
    description: Alert title
    selector:
      text: null
    required: true
  message:
    name: Message
    description: Alert message
    selector:
      text: null
    required: true
  channel:
    name: Channel
    description: Channel to use
    selector:
      text: null
    required: false
    default: ""
  importance:
    name: Importance
    description: Notification importance level (high, low, max, min, default)
    selector:
      text: null
    required: true
    default: default
variables:
  data_payload:
    message: "{{ message }}"
    title: "{{ title }}"
    data:
      channel: "{{ channel }}"
      importance: "{{ importance }}"
sequence:
  - if:
      - condition: template
        value_template: "{{ alert_device_1 }}"
    then:
      - service: notify.mobile_app_device_1
        data: "{{ data_payload }}"
  - if:
      - condition: template
        value_template: "{{ alert_device_2 }}"
    then:
      - service: notify.mobile_app_device_1
        data: "{{ data_payload }}"
icon: mdi:lightbulb-alert
max: 10

And then in an automation:

  - service: script.utility_alert
    data:
      alert_device_1: true
      title: Urgent request
      message: Your dishwasher flooded again
      channel: urgent_alerts
      importance: max

Note that I’ve edited variable names and device names for readability, but may have introduced a typo.

Hope this helps somebody.

3 Likes