Hi,
So this may not be the most impressive in terms of hacking hardware or API’s but with my limited knowledge of python/YAML, combined with the ease of use of the Home Assistant Platform, I thought I would share my project, as it brings 2 things that I love together…sort of… here goes:
Our little 18 month old son was born with a pituitary gland defect meaning that for the rest of his life he will need to take medication 4 times a day… at 06:00, 12:00, 16:00 and 22:00. As my wife and I both work, and our little tyke can’t go to creshe due to an immune deficiency (he was born at 24 weeks) we therefore have a nanny who looks after him during the day at home.
The elevator pitch of the solution I have in place goes like this:
-
There is a open/close sensor on his meds cupboard (only his meds are stored there) - Z-wave Plus Door Window Sensor by Neo Coolcam
-
This will trigger the counter, but only during the timeslot 30min before and 30 min after each medication time. And only once, by tripping an input_boolean to on and therefore if the cupboard is opened again during that timeslot it will not trigger as it check the boolean to see if it has been tripped. The input_boolean. is then turned off after the timeslot.
-
There is a notification which comes through to my wife and my phone at the due time telling us he needs his meds as well as the dosage. This message is also played over TTS to a couple of chromecast speakers throughout the house.
-
Once the timeslot is closed for his meds, there is an automation which checks to see if he has had the right amount of doses for the day after that timeslot (1,2,3 or 4) If not, a warning notification message goes out to our phones and TTS to speakers stating the timeslot that he has missed.
IF for some reason he has had his meds, then we have another input_boolean which we can manually trip to add 1 to the counter (meaning that the next warning will probably not be played as the counter will be at the right number of dosages)
NEXT STEPS:
I am waiting for a button to arrive so that the nanny can also add to the counter. When this arrives, I may decide to loop the warning until the button is pressed…
CONFIGURATION:
Time for meds alert: (x4, 1 for each time)
Automation:
- id: finn _meds_1
alias: Finn Meds at 6
initial_state: 'on'
hide_entity: true
trigger:
platform: time
at: 06:00:00
action:
- service: script.turn_on
entity_id: script.finnmeds1
Script:
finnmeds1:
sequence:
- service: media_player.turn_on
entity_id: media_player.lounge_satellite
- service: media_player.turn_on
entity_id: media_player.lounge_tv
- service: notify.anna_jj
data:
message: Finn needs 1.5mg hydrocortisone.
- delay: '00:00:05'
- service: media_player.volume_set
entity_id: media_player.lounge_satellite
data:
volume_level: 0.40
- service: tts.amazon_polly_say
entity_id: media_player.lounge_satellite
data:
message: Finn needs 1.5mg hydrocortisone.
Meds Counter:
Automation:
- id: finn_meds_counter
alias: Finn Meds Counter
hide_entity: false
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.neo_coolcam_doorwindow_detector_sensor_11_0
to: 'on'
condition:
condition: or
conditions:
- condition: time
after: '05:30:00'
before: '06:45:00'
- condition: time
after: '11:45:00'
before: '12:30:00'
- condition: time
after: '15:30:00'
before: '16:30:00'
- condition: time
after: '21:30:00'
before: '22:30:00'
- condition: state
entity_id: input_boolean.medchecker
state: 'off'
action:
- service: script.turn_on
entity_id: script.finn_meds_counter
Script:
finn_meds_counter:
sequence:
- service: counter.increment
entity_id: counter.countmeds
- service: input_boolean.turn_on
data:
entity_id: input_boolean.medchecker
Meds Warning: (x4, 1 for each time)
Automation:
- id: finn_meds_warning_6
alias: Finn Meds Warning 6
hide_entity: false
initial_state: ‘on’
trigger:- at: ‘06:45:00’
platform: time
condition:
condition: template
value_template: ‘{{ states.counter.countmeds < 1 }}’
action: - service: script.turn_on
entity_id: script.finn_meds_warning_6
- at: ‘06:45:00’
Script:
finn_meds_warning_6:
sequence:
- service: media_player.turn_on
entity_id: media_player.lounge_satellite
- service: notify.anna_jj
data:
message: Finn does not seem to have had his 06:00 meds.
- delay: '00:00:05'
- service: media_player.volume_set
entity_id: media_player.lounge_satellite
data:
volume_level: 0.40
- service: tts.amazon_polly_say
entity_id: media_player.lounge_satellite
data:
message: Finn does not seem to have had his 06:00 meds.
Resets: (Rest of Meds Checker x4, 1 for each time)
#Reset Meds Counter
- id: reset_finn_meds_counter
alias: Reset Finn Meds Counter
hide_entity: false
initial_state: 'on'
trigger:
- at: '00:00:00'
platform: time
action:
- service: counter.reset
entity_id: counter.countmeds
#Reset Meds Checkers
- id: reset_finn_medschecker_6
alias: Reset Finn Meds Checker 6
hide_entity: false
initial_state: 'on'
trigger:
- at: '06:45:00'
platform: time
action:
- service: input_boolean.turn_off
entity_id: input_boolean.medchecker
Like I said, nothing fancy in terms of technical skill, using mostly components all found out the box in Home assistant… A testament to the creators of Home Assistant… Thank you for all your hard work in bringing Home Assistant into the world!
Also, thanks to @treno and @Nitee and @fabaff for the help along the way…
Hope some of you find this useful…
DISCLAIMER:
WE HAVE OUR OWN BACKUP SYSTEMS LIKE A WHITE BOARD IN THE KITCHEN DETAILING TIMES AND MEDS AS WELL AS ALARMS ON OUR PHONES.
DUE TO THE IMPORTANCE OF THIS SPECIFIC LIFE THREATENING USE CASE, SYSTEMS LIKE THIS SHOULD NOT BE RELIED UPON SOLEY FOR LIFETHREATENING SCENARIOS SUCH AS DESCRIBED ABOVE. THIS WAS CREATED SIMPLY AS AN ADDITIONAL AID AND TO MAKE OUR LIVES THAT LITTLE EASIER AND A LITTLE PEACE OF MIND…LIKE THE INTERNET OF THINGS SHOULD…