As far as I could find there is no way to have a notification service that forwards notifications conditionally.
For example, I have automations where notifications are sent but I do not want these notifications to arrive when I or my wife are in the office.
Obviously, writing conditions in those automations is possible but that becomes cluttered rather quick. I would prefer to have a notification group that takes those conditions in consideration.
So… I made it.
in configuration.yaml:
notify:
- name: conditional
platform: group
services:
- services: empty
This creates the service notify.conditional that leads nowhere. (let’s say a dummy)
the accompanying automation:
alias: 'notify.conditional_high '
trigger:
- platform: event
event_type: call_service
event_data:
domain: notify
service: conditional
# This trigger intercepts the call service notify.conditional
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.wife_notify
state: 'on'
- condition: state
entity_id: input_boolean.me_notify
state: 'on'
sequence:
- service: notify.wife_and_me
data:
message: '{{ trigger.event.data.service_data.message }}'
title: '{{ trigger.event.data.service_data.title }}'
- conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.me_notify
state: 'on'
- condition: state
entity_id: input_boolean.wife_notify
state: 'off'
sequence:
- service: notify.me
data:
message: '{{ trigger.event.data.service_data.message }}'
title: '{{ trigger.event.data.service_data.title }}'
- conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.me_notify
state: 'off'
- condition: state
entity_id: input_boolean.wife_notify
state: 'on'
sequence:
- service: notify.wife
data:
message: '{{ trigger.event.data.service_data.message }}'
title: '{{ trigger.event.data.service_data.title }}'
default:
- service: notify.persistent_notification
data:
message: '{{ trigger.event.data.service_data.message }}'
title: '{{ trigger.event.data.service_data.title }}'
mode: single
The action part of this automation looks at which input booleans are turned on (the conditional part) and based on that forwards the title and message from the original service call to the notify services that are set to available.
This could be much simpler but this works.
The input booleans can of course be turned off and on in an automation based on zone, time or whatever you fancy.