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 appliance you don’t need at night, but want to be ready in the morning. And today we will build bed presence sensor out of a very universal device for DIY IoT. It is Aqara ZigBee window and door sensor. Why it is so universal? Let’s take a closer look at its internals.

image

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 car seat pressure sensor, like this one:

image

It could be found on Amazon or our favourite 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.

image

I’ve removed the button cup from the top of the sensor to leave a hole for the wires. Just remember to pair your sensor with whatever you are using as ZigBee hub before doing this.

image

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 pressure sensor so I decided to put the sensor on a cardboard sheet

image

I made two sensors to separately detect 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 “open” state of the sensor means “the bed is not occupied” and “closed” means that “the bed is occupied”.

image

The third sensor on the screenshot is a Home Assistant template binary sensor that represent unconditional bed occupation. In other words, it is on when someone is in a 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')}}"

Updated:

Comments