Using Binary Sensors for room occupancy

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

Perfecting room occupancy detection can be quite a daunting task. Traditional solutions, such as using motion sensors scattered across various locations, may not always hit the mark. Imagine being deeply engrossed in an adrenaline-pumping novel or caught up in the latest gripping TV drama, only for you to be abruptly enveloped in darkness because you've been still for a while. The annoyance of having to execute a panicky hand dance in front of a sensor to resurrect the light is all too familiar.

Contents

How template binary sensor can help perfect occupancy detection

Welcome to the world of template binary sensors, a dynamic solution that empowers you to utilize a diverse range of sensors for superior room occupancy detection. You're no longer shackled to just motion sensors; you can now tap into the state of a television (on means occupied) or even a humidity sensor (high humidity indicates the presence of a person savouring a steamy shower).

Incorporating additional occupancy sensors

One of the prime advantages of template binary sensors is their flexibility in integrating additional sensors down the line. Bid farewell to the laborious task of reprogramming multiple automations, as you can easily incorporate new sensors. Should you invest in another motion sensor, it can be seamlessly integrated into your existing room occupancy binary sensor, smoothly becoming part of your pre-existing scripts and automations.

A tangible demonstration of template binary sensors in action

To give you a sneak peek into the realm of template binary sensors, let's take a detour into my Home Assistant setup. In the bathroom, I've devised a binary sensor that considers the room “occupied” if humidity exceeds 60% (a tell-tale sign of a shower in action) or if the motion sensor picks up movement. This ingenious blend automatically lights up the bathroom when it's in use. The icing on the cake? I can incorporate an infinite array of sensors into this binary sensor for even greater 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 ) }}
A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...