One of the downsides when working from home is the sedentary lifestyle. We tend to sit more and take less breaks than we would usually do in an office, and over time that takes a toll on our backs and necks. I thought I fixed this by buying a standing desk, but I was wrong. The problem is that I usually forget to raise the desk so I sit in my chair for more than an hour until I feel pain in my back, and that's when I remember that I should stand up. So how do I fix this? An alarm that would ring every hour would do just fine, but it's not very accurate. What if I'm not in the office? What if I'm working at night? Do I really want to spend time setting alarms? No!
I like to automate things so I found a solution for this as well. The only thing I had to do was to place a contact sensor under my chair, and each time I would sit down it would report its state to Home Assistant. From there on I could create whatever automation I wanted. In my case, after 50 minutes of sitting down, I'll have Alexa notify me that I must stand up, and insist every 5 minutes if I'm still sitting down. Here's how I did it.
Step 1: Place the contact sensor
I found that when I sit on the chair, the seat will go down a bit, so I just need to find the perfect place for my contact sensor so that it will get close enough when I sit down. Also, I would like it to remain closed when I lean on my back, because that still counts as sitting down (and a bad position for my back). After a few trials I found the perfect position, here's how it looks for an Aeron chair.
The small magnet can be glued on top of the chair using its original sticker and it will hold just fine. The best part is that you can hardly see them when you look from above, not that it would matter that much.
Step 2: Add it to Home Assistant
This is where the fun begins. The first thing you have to do is to connect your sensor to Home Assistant, the way you do this depends on your hardware. In my case, I have a Conbee II so I have to pair my Zigbee sensor with it, then it will appear in Home Assistant as a Binary Sensor. I then created a template sensor just for fun. It has two states: "Sitting down" and "Standing up", here's how the code looks like:
I made a YouTube video where you can see how it works:
If you liked this, don't forget to subscribe using the form on top or by following me on Twitter so you won't miss the next blog post!