Hi all
I’ve been trying to get some actionable notification working, but can not achieve the wanted result.
In an nutshell, I want a notification being sent in the morning with “Yes” and “No” as options. If the response is yes, no further action is needed. If the response is no, then I want the notification to appear later that day at maybe 9pm again. However, if there is no response or the notification cleared for that matter, it should appear later again.
What I struggle to get to work, is if either the notification gets cleared or there is no response. Any help would be appreciated.
alias: Reminder Inhaler
description: ""
trigger:
- platform: time
at: "09:00:00"
enabled: true
condition: []
action:
- alias: Set up variables for the actions
variables:
action_yes: "{{ 'YES_' ~ context.id }}"
action_no: "{{ 'NO_' ~ context.id }}"
- alias: Ask if inhaler was used
service: notify.mobile_app_s23u
data:
message: Did you already use your Inhaler?
data:
actions:
- action: "{{ action_yes }}"
title: "Yes"
- action: "{{ action_no }}"
title: "No"
title: Inhaler Reminder
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_yes }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_no }}"
- platform: event
event_type: mobile_app_notification_cleared
event_data:
action_1_key: "{{ action_open }}"
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_yes }}"
enabled: true
sequence: []
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_no }}"
enabled: true
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- alias: Reminder Inhaler
service: notify.mobile_app_s23u
data:
message: Remember your inhaler before sleeping!
title: Inhaler Reminder
data:
actions:
- action: "{{ action_yes }}"
title: Ok
- conditions:
- condition: template
value_template: >-
{{ wait.trigger.event.event_type ==
'mobile_app_notification_cleared' }}
sequence:
- service: light.toggle
metadata: {}
data: {}
target:
entity_id: light.pc_ambient_light
mode: parallel
max: 10