Bed presence detection with Aqara window and door sensor and a cheap car part
Bed presence detection could be very useful in home automation to control the lights and appliances you don’t need at night, but want to be ready in the morning. And today we will build a bed presence sensor out of a very universal device for DIY IoT. It is an Aqara ZigBee window and door sensor. Why it is so universal? Let’s take a closer look at its internals.
See that little glass tube? That’s a reed switch. It operates under a magnetic field generated by the magnet inside the second part of the sensor. So, in general, it just closes the contact between two points of the electrical circuit. We can unsolder it and replace it with something else. A switch, for example. Or with a car seat pressure sensor, like this one:
It could be found on Amazon or our favorite Chinese store just for 5$. It has two wires that could be closed or opened according to pressure presence. So all we need is to solder this sensor to the Aqara sensor’s board instead of the reed switch.
I’ve removed the button cup from the top of the sensor to leave a hole for wires. Just remember to pair your sensor with whatever you are using as a ZigBee hub before doing this.
All we need to do now is to put our new sensor under the mattress. I have a bed with wood slats that is narrower than the pressure sensor so I decided to put the sensor on a cardboard sheet
I made two sensors to separately detect the bed presence of me and my wife. You need to experiment with the sensor position to get the most accurate results. Also, you need to remember that the “open” state of the sensor means “the bed is not occupied” and “closed” means that “the bed is occupied”.
The third sensor on the screenshot is a Home Assistant template binary sensor that represents unconditional bed occupation. In other words, it is on
when someone is in bed, and off
otherwise:
binary_sensor:
- platform: template
sensors:
bed_occupancy:
friendly_name: "Bed occupancy"
device_class: occupancy
value_template: "{{is_state('binary_sensor.bed_occupancy_door_side', 'off') or is_state('binary_sensor.bed_occupancy_window_side', 'off')}}"