- DIY
- A
Smart bed for a smart home
Hello tekkix! Today I want to share my experiment with the "development of a human detection sensor on the bed."
Why was this necessary?
I had long ago created an automation that opened the curtains in the morning when there was movement in the living room on weekdays, and on weekends, according to the same sensor, the scenario opened the curtains in the bedroom. Everything works great until one of us gets up early on the weekend and the other stays in bed (I admit, most often it was me 😊). It was necessary to determine and not open the curtains in the bedroom. In the future, you can link this sensor, for example, to turn on night lighting, turn on the air conditioner/fan, etc.
Or when there is nothing left to automate...
Sensors
I decided to use the cheapest Zigbee door/window opening sensor, which works on the reed switch principle (the reed switch closes under the influence of a magnetic field). And a pressure sensor in the car seat. I ordered both devices on Aliexpress: door sensor, seat sensor. I ordered all this just in case, especially the seat sensor, I didn't know if its resistance would be enough to close the contacts instead of the reed switch and if it would close under the weight of the mattress.
What was done?
Measuring the resistance of the pressure sensor
First, I measured the resistance at idle, the resistance was about 1MΩ, then under pressure (I sat on it) - full closure. Then I put the sensor under the mattress, the resistance remained close to megaohm.Reed switch dismantling
Having opened the sensor case, I carefully unsoldered the reed switch.Installing the pressure sensor
Instead of the reed switch, I soldered the pressure sensor.Integration into the smart home
After the alteration, the sensor retained its compatibility with the smart home ecosystem. Now it sends a signal not about "opening/closing", but about "pressure presence".
Automation example for Home Assistant
description: "Open curtains on weekends, in the living room by motion, and then in the bedroom by absence of a person on the bed"
mode: single
triggers:
- trigger: state
entity_id:
- binary_sensor.presence_sensor_living_room
to: "on"
conditions:
- condition: time
weekday:
- sat
- sun
after: "06:00:00"
before: "13:00:00"
actions:
- action: cover.open_cover
metadata: {}
data: {}
target:
area_id: gostinaia
- wait_for_trigger:
- trigger: state
entity_id:
- binary_sensor.krovat_contact
from: "off"
to: "on"
for:
hours: 0
minutes: 1
seconds: 0
continue_on_timeout: false
- action: cover.open_cover
metadata: {}
data: {}
target:
area_id: spalnia
Finished device
Optimization and nuances
As seen in the photo above, the pressure sensor is not 100% utilized, something needs to be placed under it, for example, glued to a thin sheet of aluminum. The new sensor only works on my side of the bed, you need to buy another pressure sensor and parallel them.
New HA sensor with debounce
- platform: template
sensors:
presence_sensor_on_bed:
friendly_name: "Presence sensor on bed"
device_class: presence
value_template: >-
{% set last_changed = states['binary_sensor.0xa4c138732178ae70_contact'].last_changed %}
{% if now().timestamp() - as_timestamp(last_changed) > 2 %}
{{ 'off' if states('binary_sensor.0xa
Write comment