Skip to content

Instantly share code, notes, and snippets.

@sam2332
Created March 8, 2024 00:05
Show Gist options
  • Save sam2332/cd5e841e2aa2208100d9a1d6c85e149b to your computer and use it in GitHub Desktop.
Save sam2332/cd5e841e2aa2208100d9a1d6c85e149b to your computer and use it in GitHub Desktop.
Medications
alias: Reminder for Medication
description: Sends reminders to take medication at a specific time and notifies when medication is not taken.
domain: automation
input:
reminder_time:
name: Reminder Time
description: The time to send the medication reminder
selector:
time: {}
door_sensor:
name: Door Sensor
description: The door sensor to check if the person has accessed the medication
selector:
entity:
domain: binary_sensor
counter:
name: Counter
description: The counter to use for tracking medication missed
selector:
entity:
domain: counter
notification_device:
name: Notification Device
description: The device to send the notification to
selector:
device:
integration: mobile_app
trigger:
- platform: time
at: !input reminder_time
condition:
- condition: state
entity_id: !input door_sensor
state: 'off'
action:
- service: counter.increment
target:
entity_id: !input counter
- service: notify.mobile_app
target:
device_id: !input notification_device
data:
title: "Reminder!!"
message: "Please Take Your Medicine!!"
- wait_for_trigger:
- platform: state
entity_id: !input door_sensor
to: 'on'
timeout: "00:05:00"
continue_on_timeout: true
- choose:
- conditions:
- condition: state
entity_id: !input door_sensor
state: 'on'
sequence:
- service: counter.reset
target:
entity_id: !input counter
default:
- service: notify.mobile_app
target:
device_id: !input notification_device
data:
title: "Missed Medication Alert"
message: "You missed your medication time. Please take it as soon as possible."
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment