Tracking BMs with Home Assistant AKA Poop Button


I have Parkinson's, and it sucks. A lesser known symptom of Parkinson's is constipation. Sometimes it is due to medications taken and other times it is because of less movement due to apathy and depression. Then there is other times where it can just be the Parkinson's being a literal pain in the ass. I found myself not even realizing how long I was going between BMs and started worrying about it. I tried to find an app or some good way to track it but I couldn't find anything reliable or decent that I would stick to.

I love Home Assistant, I could play with it all day long. I have dashboards for tracking batteries in different devices, air quality in the house, weather, even network performance. Everything but me. I worked in a nursing home for 13 years and I know how EMRs work. I could add a helper to track my last BM, and build from that alerts and visual reminders so I know how long it has been. Thus, the 'Poop Button' was born.

I started out by adding a helper named LastBM that would keep the date and time of the last time I went number '2'. I manually entered a time for now for testing, but I would eventually need a better way to enter this.









I went back and forth on how I wanted this to be presented, but I decided to create a whole new dashboard with a single view.

I used the mdi:hospital-box icon and made it look like it's official or something.


Then I added a big button with a tiny poo icon in the middle.


I used a Mushroom Template Card with the mdi:emoticon-poop icon.




I added {{ time_since(as_datetime(states('input_datetime.lastbm')), 1) }} to get the time of the last poo under the icon. time_since is a great dynamic function because it will read out the specificity you want based on that last variable you entered. I put in that ',1' because I want 1 degree of specificity. In other words, I don't need to know the minutes if it has been hours, or hours if it has been days. As you can see here, it has been days and I am in pain, yay! Maybe I should add a reminder to take some Dulcolax or something.

To change the color of the poo emoticon I used this code in the mushroom card color section,

{% set last_updated = as_timestamp(states('input_datetime.lastbm')) %}

  {% set seconds_ago = as_timestamp(now()) - last_updated %}
  {% set days_ago = seconds_ago / 86400 %}
  {% if days_ago < 1 %}
    green
  {% elif days_ago < 2 %}
    yellow
  {% elif days_ago < 3 %}
    orange
  {% else %}
    red
  {% endif %}



I also wanted a notification on my phone so I set up an automation with three triggers, and added trigger IDs for each one.

Trigger ID 24
{% set last_bm = state_attr('input_datetime.lastbm', 'timestamp') %}
      {{ as_timestamp(now()) >= (last_bm + 86400) }}

Trigger ID 48
{% set last_bm = state_attr('input_datetime.lastbm', 'timestamp') %}
      {{ as_timestamp(now()) >= (last_bm + 172800) }}

Trigger ID 72
{% set last_bm = state_attr('input_datetime.lastbm', 'timestamp') %}
      {{ as_timestamp(now()) >= (last_bm + 259200) }}


Then adding the actions is as easy as entering 'Send notifications to your device' and entering the message 'No BM in 24 hours', etc, and matching the trigger IDs. In case you didn't know, the HA geniuses created this action so you create one automation to handle multiple scenarios and not have to create separate automations for each one. I also use it for presence detection. In one automation you can have a light turn on if presence is detected, and turn back off if that presence is cleared.












Lastly, whenever I let a man know about a wallaby, I need to create an easy way to let this system know about it. It's easy to create a button, and the button does do that if pressed. To take it one step further, and prove I'm as much of a geek my daughter thinks I am, I wanted to use an NFC tag. As luck would have it she had crocheted a poo emoji for me on my birthday a couple years ago. She even had him holding up a little sign, the perfect size to hide a tag behind.

When I scan the tag the automation simply sets a Datetime to the LastBM helper I created in the beginning with this,

{{ now().strftime('%Y-%m-%d %H:%M:%S') }}

Now, thanks to Home Assistant, I'll never forget the last time the Browns went to the Superbowl!

I have run into an issue though. Without a state class and only a datetime, HA will only store the info for 10 days. I can't go back with just this and tell my doctor there were 'x' amount of times in the last six months where it was more than 72 hours. I am looking into using one of the PHR self-hosted apps like Fasten or OpenEMR to do this. They may already have something built-in, but if not I'll build it.



References

Popular posts from this blog

Blue Charm beacons, TLM data via ESPHome

Tracking BMs with Home Assistant AKA Poop Button

Mason Bees