Notify person

This feature request thread brought this 5 year HA lurker out of the shadows to create an account.

Please don’t forget about this one guys. Targeting people and all their associated devices for notifications would be huge for increasing user engagement.

Here’s a workaround until this becomes a supported feature. In short, using customize.yaml you can associate notify services with each person entity. Then you can reference those in automations or scripts.

Step 1: Edit your customize.yaml file (see here for details) and list each person and their associated notification services that you’d like to use. For example:

person.john_doe:
  notify_services:
    - 'notify.mobile_app_johns_iphone'
    - 'notify.custom_notify_service_for_john'
person.jane_doe:
  notify_services:
    - 'notify.mobile_app_janes_android'

Then restart so it takes effect. (There are ways to reload this file without restarting and those methods are discussed in the docs; I won’t cover them here.)

Step 2: Utilize those new attributes in your automations & scripts. Here is an example script that will call every notify service attached to every person who is currently home:

alias: Alert everyone who is home
continue_on_error: true
sequence:
  - variables:
      notify_services: >
        {{ state_attr('zone.home','persons') | map('state_attr','notify_services') | sum(start=[]) | list }}
  - repeat:
      for_each: "{{ notify_services }}"
      sequence:
        - service: "{{ repeat.item }}"
          data:
            message: You are home!
mode: single

I specify continue on error in case a notify service is removed or renamed; this way all the other notifications are still sent. You will still see errors in your logs if that happens though.

Edit: here’s a simpler option if you are OK with restricting yourself to only one notify service per person.

Example of customize:

person.john_doe:
  notify_service: notify.mobile_app_johns_iphone
person.jane_doe:
  notify_service: notify.mobile_app_janes_android

Example of how to notify everyone who is home:

alias: Alert everyone who is home
continue_on_error: true
sequence:
  - variables:
      notify_services: >
        {{ state_attr('zone.home','persons') | map('state_attr','notify_service') | list }}
  - repeat:
      for_each: "{{ notify_services }}"
      sequence:
        - service: "{{ repeat.item }}"
          data:
            message: You are home!
mode: single

And where it becomes easier is if you only want to notify a single person. Instead of

service: notify.mobile_app_johns_iphone
data:
  message: "Hello John!"

You can use this instead:

service: "{{ state_attr('person.john_doe', 'notify_service') }}"
data:
  message: "Hello John!"

The benefit is that you never have to maintain your automations or scripts if you decide that you want to be notified by a different method. Or if you change your phone and your notification method changes. It’s a single change to the customize YAML.

BUMP!

This is so important! In my case I have a guest user account that I give to visitors. (obviusly I change the PW inbetween visitors). This means that the devices accosiated with the user account changes frequently and sometimes this account is logged in on multiple devices. It needs to be possible to broadcast notifications to all devices where a certain account is logged in without having to manually add devices!

1 Like