Son's Daily Medicine Checker

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:

  1. 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

  2. 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.

  3. 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.

  4. 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

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…

10 Likes

Dash buttons would be perfect for this, given they effectively cost nothing, or less than nothing when there’s an offer on, you could have one for each time slot.

1 Like

Thanks for the like @Bobby_Nobble. Are the dash buttons not wired into amazon for product purchases? I would be happy ro investigate, but as you can see, I stuck to “out the box” components and features of HA… purely due to lack of skill…

1 Like

You go through the setup wizard using the Amazon app on your phone and when it gets to the choose a product page you just cancel it. You will also need to run something like dasher to capture the button presses.

I’m using a few of them for a very similar purpose (wife meds and also one each for the cat and dog being fed).

1 Like

@daemondazz thanks for the tip… will give it a try…

1 Like

You only do that after you’ve claimed the £4.99, or whatever your local currency is, credit on a live Amazon account and then reset it to the point you said on an account you only use for buttons to avoid any conflict.

If you’ve gone the hass.io route, then both dasshio and dasher are simple addons that only need a click to install. There are threads on here supporting both. I personally use dasshio as it was the first to become available for hass.io, dasher gives you more options but I don’t need them so stuck with the first option.

I think what you’ve done is a great, my eldest went through four years of chemo with similar regularity of drugs and something like this back then would’ve made it much less stressful as well as a welcome diversion setting it up.

Glad to say those days are long gone for us, fingers still crossed, but you have my best wishes for your much longer journey.

2 Likes

Olá o que pensam em relação a melhorar o sistema … Imagine uma máquina de liberação de medicamentos … Nas horas programadas o remédio é liberado… tendo um botão de pânico caso algo de errado. A tia da minha esposa vai todos os dias na casa da mãe dela separar os remédios que “senhora” vai tomar no outro dia. Um pote para os remédios da manhã. … outro pote os remédios da tarde e outro pote remédios da noite. Cada pote tem uma cor.

Eu tinha pensado em fazer uma roleta que libera os remédios nas horas programadas, porém os remédios nao podem sair da embalagem original. Para não perderem o efeito devido ao contato com o ar.

Isso é só uma sugestão. … que pode ser pensado em ser melhorado o seu sistema podem ser usado no mundo inteiro ( idosos, mulheres tomando anticoncepcional, babás para filhos) e gerar um relatório com as horas que foi tomado o remédio.

Obrigado e desculpe por escrever em português -Brasil.

Hello what do you think about improving the system … Imagine a drug release machine … At scheduled times the remedy is released … having a panic button if something wrong. My wife’s aunt goes to her mother’s house every day to separate the pills that “lady” is going to take the other day. A pot for the morning remedies. … another pot the afternoon remedies and other pot evening remedies. Each pot has a color.

I had thought about making a roulette wheel that releases the pills at the scheduled times, but the pills can not leave the original packaging. Do not lose the effect due to contact with the air.

That’s just a suggestion. … which can be thought of being improved your system can be used worldwide (seniors, women taking contraceptives, nannies for children) and generate a report with the hours that the medicine has been taken.

Thank you and sorry for writing in Portuguese - Brazil.

next time try use google translate first… I think the idea is good, but the hardware will be a challenge bearing in mind the type of medication (we have to draw up a dose in a syringe.)

You could start with something simple lilke a pill dispenser which would give you a good size target market…

na próxima vez, tente usar o google tradutor primeiro … Acho que a idéia é boa, mas o hardware será um desafio tendo em conta o tipo de medicação (devemos elaborar uma dose em uma seringa).

Você poderia começar com algo simples, um dispensador de comprimidos que lhe daria um mercado alvo de bom tamanho …

1 Like

Nice Job Well Done

thinking out side the Square

what about adding

in on the med cupboard Door