Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active March 2, 2023 22:05
Show Gist options
  • Select an option

  • Save Didgeridrew/e0246a5579c1898c813a577031457f27 to your computer and use it in GitHub Desktop.

Select an option

Save Didgeridrew/e0246a5579c1898c813a577031457f27 to your computer and use it in GitHub Desktop.
HA - sending Mobile Actionable Notification and saving reply and timestamp to calendar event
#REPLY and BUTTONS -----------------------------
alias: Benj egg text
description: ""
trigger:
- platform: time
at: "07:30:00"
condition: []
action:
- alias: Set up variables for the actions
variables:
action_yestest: "{{ 'YESTEST_' ~ context.id }}"
action_notest: "{{ 'NOTEST_' ~ context.id }}"
- alias: has Benj had any egg
service: notify.mobile_app_redmi_note_8t
data:
message: Has Benj had any egg?
data:
channel: egg
actions:
- action: REPLY
title: "Other:"
- action: "{{ action_yestest }}"
title: Jaffa
- action: "{{ action_notest }}"
title: "No"
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_yestest }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_notest }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: REPLY
channel: egg
- alias: Perform the action
service: calendar.create_event
target:
entity_id: calendar.calendar
data:
end_date: "{{ (now() + timedelta(days=1)).date() }}"
start_date: "{{ now().date()}}"
summary: |
{% set w_action = wait.trigger.event.data.action %}
{% if w_action == action_yestest %}
Full Jaffa
{% elif w_action == action_notest %}
"None"
{% else %}
{{ wait.trigger.event.data.reply_text }}
{% endif %}
mode: parallel
#REPLY ONLY ---------------------------------
alias: ztest Actionable Reply
description: save reply from actionable notification to a helper
trigger:
- platform: time
at: "09:00:00"
condition: null
action:
- alias: Ask for Reply
service: notify.mobile_app
data:
message: Reply with words
data:
data:
channel: egg_check
actions:
- action: REPLY
title: Reply
- alias: Wait for a response
timeout: "00:01:00"
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
data:
channel: egg_check
action: REPLY
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == 'REPLY' }}"
sequence:
- service: calendar.create_event
data:
summary: "{{ wait.trigger.event.data.reply_text }}"
description: ""
start_date_time: "{{ now().isoformat()[:19] }}"
end_date_time: "{{ now().isoformat()[:19] }}"
target:
entity_id: calendar.YOUR_CALENDAR
- delay: 90
- service: notify.mobile_app
data:
data:
channel: egg_check
message: clear_notification
default:
- service: calendar.create_event
data:
summary: "NO RESPONSE FROM NOTIFICATION"
description: ""
start_date_time: "{{ now().isoformat()[:19] }}"
end_date_time: "{{ now().isoformat()[:19] }}"
target:
entity_id: calendar.YOUR_CALENDAR
- delay: 5
- service: notify.mobile_app
data:
data:
channel: egg_check
message: clear_notification
mode: parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment