What are binary sensors in Home Assistant?

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.

Binary sensors in Home Assistant play a crucial role in smart home setups, with their core function being to report one of two possible states: either 0 (off) or 1 (on). These sensors come in various forms, contributing to the seamless operation of connected devices such as light switches, Wi-Fi outlets, contact sensors, and locks.

The rationale behind binary sensors

While sensors inherently possess the capability to represent on and off states, binary sensors offer a more simplistic and efficient alternative. Home Assistant, upon detecting a binary sensor, is aware that it can only ever report a 0 or 1, making their representation on the frontend, such as with the Glance Card, more straightforward.

The binary nature of these sensors also simplifies their use in Home Assistant automations and scripts, as users only need to verify if a sensor is off or on, rather than comparing its state to a predefined value.

The status of a binary sensor shown in Home Assistant.

Exploring Home Assistant's binary sensor device classes

Binary sensors can be assigned specific device classes, such as those indicating whether a door is open or closed, if a lock is secure, or if movement is detected. A comprehensive list of device classes can be found in the Home Assistant documentation.

Some Home Assistant binary sensors, like Aqara motion sensors, automatically report the correct device class when integrated with Home Assistant via Zigbee2MQTT. However, not all devices possess this capability, necessitating manual customization of the entity. Additionally, there are instances when a binary sensor may report an incorrect device class, which can be rectified through customization. Device classes are vital for accurately displaying binary sensors on the Home Assistant frontend and enhancing the aesthetics of the Home Assistant Dashboard.

This sensor has the device class motion

Delving into binary sensor examples

A myriad of devices function as binary sensors, and users can even create their own using Home Assistant's binary sensor template. For instance, if you have a thermometer and merely want to know if a room is cold or not cold, you can create a binary sensor based on the thermometer to report the cold state when a specific temperature is reached. Examples of binary sensors in use include Aqara motion sensors, contact sensors, and Sonoff switches running ESPHome. Binary sensor templates can also be employed for room occupancy detection.

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...