Notifications are a cornerstone of Home Assistant automations. However, the current notification process is clumsy as it is specific to devices. This means that if you wish to change which devices get notified, you need to set them up specifically in automations.
A particular automation workflow that Home Assistant does not do well is sending notifications only to people in a given zone (e.g. at home). To achieve this now, you must set if-then conditions to only send messages when a given device or person is at home.
Already, we have notify.mobile_app_bobs_phone
, but I suggest we broaden this out a bit further.
- People possess Devices, so a notification directed to that person would then send to their listed devices.
- Zones also possess Devices and People, so a notification to a zone should then go to one or both, depending on preference.
Now let’s use an example of people and devices in or outside a zone.
Devices in zone.home |
Devices NOT in zone.home |
|
---|---|---|
Bob (home) | Bob’s iPhone | - - - |
Stephanie (home) | Stephanie’s Galaxy | Stephanie’s iPad |
Tina (away) | Tina’s Galaxy Tab | Tina’s Fairphone |
Unassigned | Lounge TV | Communal iPad* |
* Have you ever misplaced a communal iPad? It could be ANYWHERE
Let’s represent this hierarchically for each person first:
- notify.person_bob:
- notify.mobile_app_bobs_iphone
- notify.person_stephanie:
- notify.mobile_app_stephanies_galaxy
- notify.mobile_app_stephanies_ipad
- notify.person_tina:
- notify.mobile_app_tinas_galaxy_tab
- notify.mobile_app_tinas_fairphone
This is straightforward: you call a service to notify the person and it comes to the relevant device. The best part is that as people change their devices over time, you don’t need to rewrite automations. (This is already done in notification groups but it’s clunky and should be brought into the GUI).
What about the zone? Based on who and what’s at home, it’ll look like this:
- notify.zone_home:
- notify.person_bob
- notify.person_stephanie
- notify.mobile_app_bobs_iphone
- notify.mobile_app_stephanies_galaxy
- notify.mobile_app_tinas_galaxy_tab
- notify.lg_webos_tv_lounge_tv
This list would change in real time depending on who and what is in the zone.
How would this play when you call a service? I imagine there will be additional filters:
- No filter: This will cascade the notification to all things within the zone, including people and devices.
- Notify people only: This will send the notification only to people within the zone and not to devices that are unassigned.
- Notify present devices only: This will prevent a notification being sent to a device not in the zone, but whose owner is in the zone.
- Combination of 2 and 3: This will only notify devices that belong to people AND are in the zone.
Let’s send a notification to notify.zone_home
and see how it behaves under those filters:
1. notify.zone_home
, no filters
Devices in zone.home |
Devices NOT in zone.home |
|
---|---|---|
Bob (home) | Bob’s iPhone | - - - |
Stephanie (home) | Stephanie’s Galaxy | Stephanie’s iPad |
Tina (away) | Tina’s Galaxy Tab | Tina’s Fairphone |
Unassigned | Lounge TV | Communal iPad |
Notice how Tina’s Galaxy Tab is notified, even though Tina isn’t in the zone? Basically without filters it notifies everything currently in the zone and filters down.
2. notify.zone_home
, People Only
Devices in zone.home |
Devices NOT in zone.home |
|
---|---|---|
Bob (home) | Bob’s iPhone | - - - |
Stephanie (home) | Stephanie’s Galaxy | Stephanie’s iPad |
Tina (away) | Tina’s Galaxy Tab | Tina’s Fairphone |
Unassigned | Lounge TV | Communal iPad |
Notice how Tina’s Galaxy Tab isn’t being notified anymore because Tina isn’t in the home even though her Galaxy Tab is.
Also, the unassigned Lounge TV isn’t being notified this time because nobody owns it.
3. notify.zone_home
, Present Devices Only
Devices in zone.home |
Devices NOT in zone.home |
|
---|---|---|
Bob (home) | Bob’s iPhone | - - - |
Stephanie (home) | Stephanie’s Galaxy | Stephanie’s iPad |
Tina (away) | Tina’s Galaxy Tab | Tina’s Fairphone |
Unassigned | Lounge TV | Communal iPad |
This time, notice that Stephanie’s iPad isn’t being targeted because it’s not in the zone. The Lounge TV is being targeted this time round.
4. notify.zone_home
, People & Present Devices Only
Devices in zone.home |
Devices NOT in zone.home |
|
---|---|---|
Bob (home) | Bob’s iPhone | - - - |
Stephanie (home) | Stephanie’s Galaxy | Stephanie’s iPad |
Tina (away) | Tina’s Galaxy Tab | Tina’s Fairphone |
Unassigned | Lounge TV | Communal iPad |
In this situation, see how Tina’s Galaxy Tab isn’t allowed to be notified because Tina isn’t in the zone? In this situation, a person being out of the zone will deny notification to any of their devices in the zone.
What about device-specific settings?
This a problem. But I suggest having different areas in the data that allows HA to tailor for different devices. Title
and Message
are conserved throughout, but there could be iOS:
, android:
, etc. areas where you can do push settings, volume, etc.