Automation and scenarios Blog

DIY: Bed Occupancy Detection with Home Assistant

bedroom

Bed occupancy detection is one of those Home Assistant projects that make automation truly smart and personalized. Such a system allows you to control lighting, climate, security, and run various scenarios depending on whether a person is in bed or not. There are several proven ways to implement this mechanism, and most of them are available in DIY format.

One of the most accurate and popular solutions is to use pressure sensors, such as FSR (force-sensitive resistors), placed under the mattress. These sensors are connected to ESP8266 or ESP32 microcontrollers with ESPHome firmware. The device measures the resistance depending on the weight on the mattress. With proper calibration, high accuracy can be achieved: false positives are eliminated, and automation becomes reliable. Users from Home Assistant forums report that when sensors are installed in the pelvis and back area, the system clearly determines when a person lies down or gets up.

Another approach is to use pressure sensors built into old scales, such as IKEA. The board and reading elements are modified to track the total weight. If the bed weighs 40 kg and an additional load of about 60–100 kg appears, the system assumes that someone is in the bed. Such homemade platforms are mounted under the legs of the bed, and the data is sent to Home Assistant via ESPHome or MQTT. Despite the need for soldering and configuring signal amplifiers, many praise this scheme for its reliability and ease of installation.

Ready-made solutions also exist. The Withings Sleep sensor is a thin mat placed under the mattress that tracks heart rate, breathing, and movement and clearly transmits the status “in bed” and “not in bed” through official integration with Home Assistant. The device does not require soldering or firmware configuration, but it is significantly more expensive than DIY options. However, it offers additional features: tracking sleep phases, heart rate, and sleep quality, which can be useful in a large smart home project.

Some enthusiasts use ultrasonic or laser distance sensors (e.g., HC-SR04 or VL53L0X) installed on the side or under the bed. The sensor measures the distance to the surface, and if someone lies down, it changes. This solution is less reliable than pressure sensors, as it can give false positives, especially with thick blankets or cats jumping on the bed. However, it is attractive because it does not require anything to be installed under the mattress or under the bed legs.

There are also experimental methods, such as using a camera with infrared lighting and local body recognition via Frigate and Coral TPU. Such a system can detect a person’s silhouette in bed and trigger automation. But implementation requires technical knowledge, privacy issues, and additional computing power.

Regardless of the approach chosen, determining presence in bed helps to implement scenarios such as: “if I lie down, turn off the lights,” “if both people are in bed, activate security,” “if I get up, turn on the coffee maker.” All these actions are implemented through automation in Home Assistant, and the bed status sensor simply acts as a trigger. It is precisely this kind of DIY project that allows a smart home to truly adapt to a person’s lifestyle.