I have a notification group setup of the two Home Assistant companion app using Android devices:
notify:
- platform: group
name: Family
services:
- service: mobile_app_galaxy_a32
- service: mobile_app_pixel_3a
I would like to send an actionable notification to that group whenever the front gate is detected to be open, with the option to close it. When the front gate is detected to be closed, that notification should vanish from all devices.
- alias: Notify if gate open
id: 'notify_if_gate_open'
trigger:
- id: 'gate_opened'
platform: state
entity_id: cover.gate
to: 'open'
- id: 'gate_closed'
platform: state
entity_id: cover.gate
to: 'closed'
mode: restart
max_exceeded: silent
action:
- choose:
- conditions:
- condition: trigger
id: 'gate_opened'
sequence:
- service: notify.family
data:
title: 'Gate'
message: 'Gate is open'
data:
notification_icon: 'mdi:gate-open'
channel: garage
tag: gate-open
actions:
- action: CLOSE_GATE
title: 'Close Gate'
#Wait for feedback from the actionable notification
- wait_for_trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: CLOSE_GATE
#timeout: "00:30:00"
#continue_on_timeout: false
#Continue only if the gate is currently open
- condition: state
entity_id: cover.gate
state: 'open'
#Close the gate
- service: cover.close_cover
entity_id: cover.gate
default:
- service: notify.family
data:
title: 'Gate'
message: 'clear_notification'
data:
channel: garage
tag: gate-open
However the notification is not send reliably to all devices, nor is it automatically removed.