Skip to content

Instantly share code, notes, and snippets.

@dmakovec
Created November 3, 2022 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmakovec/d2df5977746719e90d30ce5ec5a82d5b to your computer and use it in GitHub Desktop.
Save dmakovec/d2df5977746719e90d30ce5ec5a82d5b to your computer and use it in GitHub Desktop.
A pill reminder automation for Home Assistant
alias: "Pill reminder"
description: ""
trigger:
- platform: time_pattern
minutes: /30
alias: Every 30 mins
condition:
- condition: state
entity_id: input_boolean.not_had_pill_today
state: "on"
action:
- alias: Set up variables
variables:
action_yes: YES_PILL
action_no: NO_PILL
- alias: Ask question
service: notify.mobile_app_pixel_7
data:
message: Had it today?
title: Pill
data:
actions:
- action: "{{ action_yes }}"
title: "Yes"
- action: "{{ action_no }}"
title: "No"
- alias: Wait for 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 }}"
timeout:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
- if:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_yes }}"
alias: Answer "Yes" received
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.not_had_pill_today
data: {}
alias: Check the answer
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment