Using Binary Sensors for room occupancy

No comments
Disclosure: This post contains affiliate links. If you click through and make a purchase, I’ll earn a commission, at no additional cost to you. Read my full disclosure here.
Advertisement
lock_open_closed_occupied

Reliable room occupancy detection can be a challenge to achieve, as traditional methods such as using motion sensors in multiple locations may not always be accurate. For example, if you are watching television or reading and hardly moving for an extended period, the lights may turn off. In that situation, it can be inconvenient to have to wave your hand in front of a sensor just to turn them back on.

Advertisement

Imagine being able to use multiple sensors for room occupancy detection. Well, you can, by utilizing a template binary sensor. You’re not limited to just motion sensors for occupancy detection. For example, you can use the state of a television as a sensor (if it’s on, the room is considered occupied) or even a humidity sensor (if humidity levels are high, it’s likely someone is taking a shower).

Adding more sensors

Another advantage of using the template binary sensor is the flexibility it offers in adding more sensors later on. Without the need to rewrite multiple automations, you can easily integrate new sensors. For instance, if you decide to get an additional motion sensor, you can simply add it to your existing room occupancy binary sensor, and it will automatically be included in any scripts or automations you have set up.

Advertisement

Using the template binary sensor

Here’s an example from my Home Assistant setup. The binary sensor I use for my bathroom is set to “occupied” if the humidity goes above 60%, which indicates that someone is taking a shower, or if the motion sensor detects any movement. This automatically turns on the lights when the bathroom is in use. The best part is, I can add an unlimited number of sensors to this binary sensor for even more accuracy and automation.

platform: template
sensors:
  shower_occupancy:
    friendly_name: "Shower occupancy"
    device_class: occupancy
    delay_off:
      minutes: 3
    entity_id: binary_sensor.shower_motion
    value_template: >-
      {{ is_state('binary_sensor.shower_motion', 'on') 
          or ( states('sensor.shower_humidity') | float > 60 ) }}

Leave a comment

Share to...