Bed sensor in Home Assistant

Print Friendly, PDF & Email

A classic in home automation is to add different sensors, in today's post we are going to see some examples of how with Home Assistant and pressure sensors we can do very curious things. Sensors that we can put on the bed, on a carpet, sofa…

Thanks to ESPHome we will see how easy and fast everything is, we will need to start a small ESP32 or ESP8266, where as many of you already know he will be installed with 1 click on ESPHome firmware. We can connect one or more pressure sensors to this plate, it will depend on our need; for example in a double bed, Under the mattress you can put 2 Mat format pressure sensors, and thus know who in particular is in bed, since we usually have the land separated.

There are several types of pressure sensors, The most common are those in the mat format, that can be hidden under a doormat, Under the mattress, of the sofa… Pressure sensors carry a couple of wires, we will connect them to the ESP32 board or ESP8266, one to GND ground and the other to a GPIO that we'll use to know when someone (or a cat) Press the sensor, 'Cause he sits on top, He lies down, Pisa… and therefore trigger any automation we feel like with Home Assistant.

And the automations to taste and need, that if he is in bed and detects that we have gone to bed (And it's night), Well, check certain things that we may have left undone, Lock the locks, Turn off lights, Lower the blinds, Say goodnight and tell you a joke… As well as if you have it on the sofa and other conditions are met, Turn on the TV, Dim ambient light, Lower the stores… On the pilates mat and I put on music, on the carpet at the entrance and at night open the electronic door to the cat…

The issue of deploying it with a board with an ESP microcontroller, is that it will usually have to be connected to the power supply, If we have a plug at hand or we are not friends with batteries, it is a very good option. But also in case you haven't thought of it, instead of using an ESP32, We could use a water leak sensor, of those that detect if there is water in the soil, (It would be as simple as connecting the 2 Pressure sensor cables to water sensor connectors). Those are usually powered by a battery, They last for months, are RF or Zigbee, and you take off all the ESPHome part that we will see in this post. Go, or a magnetic sensor, these doors that we have in a drawer. In the end, what we need in Home Assistant is a binary sensor, that responds with an ON or an OFF to its status, be us with an ESP and its GPIO, or with a device from a manufacturer.

You can buy the pressure sensors anywhere from these Chinese or American online sites, for a few euros we will find them, although this, I love it.

Txapas on the side, as usual, I recommend you install the ESPHome firmware directly by connecting the boards via USB to your computer and opening this website It will detect it and proceed to install the firmware, After that, it will ask you for your Wi-Fi network, will connect and Home Assistanr and ESPHome will find out, where we can already apply the configuration that it should carry.

Once Home Assistant detects it, we will only add the following configuration, in this example this ESP has two pressure sensors, one on pin D2 and one on pin D4 of this board, A sensor measures when I'm in bed, And the other one is my girl.

binary_sensor:
  - Platform: Good name: Seila_en_Cama pin:
      number: D2 inverted: true mode:
        Input: True pullup: True Filters:
      - delayed_off: 20s
  - Platform: Good name: Hector_en_Cama pin:
      number: D4 inverted: true mode:
        Input: True pullup: True Filters:
      - delayed_off: 20s

And after saving the changes and having installed the firmware on our ESP board, we will have our new entities and we will be able to add them to a card within Home Assistant.

And we will be able to create the automations that interest us, we will only have to add a State-type trigger, that we will monitor to know when the sensor status has changed from Off to On, and thus we can create the actions that interest us, not without forgetting, for example, that we can set conditions, Like it's night, or a schedule, or that the automation does not run again if it was already run in the last few weeks. 8 hours…

As always, thank you for your reading, especially if you have come this far and the post can give you something, the truth is that this thing about sensors and Home Assistant is a vice, many of the tasks that our house can do for us depending on certain conditions… Have a good week, Be good, And good, And good :-?.

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!