Binary sensor
Binary sensors are similar to other sensors in that they
monitor the states and conditions of different entities. Where binary sensors
differ is they can only return one of two mutually exclusive values.
For example, a binary sensor for a window may report a value
of open or closed, a switch on or off, a condition true or false.
This either/or constraint is what makes these sensors binary. They are digital in nature, whereas analog sensors, like temperature and weight sensors, return a range of values.
Some binary sensors are created automatically when you add a device integration. For example, adding the ecobee integration will create a binary sensor to detect room occupancy. Other binary sensors can be created manually using the template integration or using an input boolean helper.
Building block integration
This binary sensor is a building block integration that cannot be added to your Home Assistant directly but is used and provided by other integrations.
A building block integration differs from the typical integration that connects to a device or service. Instead, other integrations that do integrate a device or service into Home Assistant use this binary sensor building block to provide entities, services, and other functionality that you can use in your automations or dashboards.
If one of your integrations features this building block, this page documents the functionality the binary sensor building block offers.
Binary sensor states
A binary sensor has two states: on or off. In the Home Assistant interface, its device class determines the icon and the label shown for each state. For example, a lock binary sensor shows Unlocked when its state is on and Locked when its state is off.
In addition, the entity can have the following states. Each item shows the interface label, followed by the stored state:
-
Unavailable (
unavailable): The entity is currently unavailable. -
Unknown (
unknown): The state is not yet known.
Device class
The device class tells Home Assistant what a binary sensor detects, such as an open door or motion. Home Assistant uses the device class to choose the icon and the labels for on and off, such as Open and Closed. The device class also decides where you can use the binary sensor, such as in triggers and conditions, on the Security dashboard, or in voice assistants. If a binary sensor doesn’t show up where you expect it, check its device class.
The integration that provides the binary sensor sets the device class. When you create a binary sensor yourself with a template helper, you choose the device class.
Device classes in automations and templates
- Automations: Some device classes have their own triggers and conditions, such as Door opened. Of your binary sensors, these triggers and conditions only list the ones with that device class. The list below shows the triggers and conditions of each device class.
- Templates: The device class is the
device_classattribute of the entity. Use the stored value, such asdoor. For example, you can find entities by device class.
List of available device classes
A binary sensor without a device class shows On and Off as its state labels.
Each item shows the name you see in the Home Assistant interface, followed by the device class as Home Assistant stores it. Below each item are the labels the interface shows for the on and off states, and the triggers and conditions of the device class, if it has any.
-
Battery (
battery): Shows whether the battery is low.-
Low (
on) -
Normal (
off) - Triggers: Battery low, Battery not low
- Conditions: Battery is low, Battery is not low
-
Low (
-
Charging (
battery_charging): Shows whether the battery is charging. Under Show as, this type is called Battery charging.-
Charging (
on) -
Not charging (
off) - Triggers: Battery started charging, Battery stopped charging
- Conditions: Battery is charging, Battery is not charging
-
Charging (
-
Carbon monoxide (
carbon_monoxide): Shows whether carbon monoxide is detected.-
Detected (
on) -
Clear (
off) - Triggers: Carbon monoxide cleared, Carbon monoxide detected
- Conditions: Carbon monoxide cleared, Carbon monoxide detected
-
Detected (
-
Cold (
cold): Shows whether something is cold.-
Cold (
on) -
Normal (
off)
-
Cold (
-
Connectivity (
connectivity): Shows whether a device is connected.-
Connected (
on) -
Disconnected (
off)
-
Connected (
-
Door (
door): Shows whether a door is open.-
Open (
on) -
Closed (
off) - Triggers: Door closed, Door opened
- Conditions: Door is closed, Door is open
-
Open (
-
Garage door (
garage_door): Shows whether a garage door is open.-
Open (
on) -
Closed (
off) - Triggers: Garage door closed, Garage door opened
- Conditions: Garage door is closed, Garage door is open
-
Open (
-
Gas (
gas): Shows whether gas is detected.-
Detected (
on) -
Clear (
off) - Triggers: Gas cleared, Gas detected
- Conditions: Gas cleared, Gas detected
-
Detected (
-
Glass break (
glass_break): Shows whether glass breaking is detected.-
Glass break detected (
on) -
Clear (
off)
-
Glass break detected (
-
Heat (
heat): Shows whether something is hot.-
Hot (
on) -
Normal (
off)
-
Hot (
-
Light (
light): Shows whether light is detected.-
Light detected (
on) -
No light (
off) - Triggers: Light level cleared, Light level detected
- Conditions: Light level is detected, Light level is not detected
-
Light detected (
-
Lock (
lock): Shows whether a lock is unlocked.-
Unlocked (
on) -
Locked (
off)
-
Unlocked (
-
Moisture (
moisture): Shows whether moisture is detected, such as a water leak.-
Wet (
on) -
Dry (
off) - Triggers: Moisture cleared, Moisture detected
- Conditions: Moisture is detected, Moisture is not detected
-
Wet (
-
Motion (
motion): Shows whether motion is detected.-
Detected (
on) -
Clear (
off) - Triggers: Motion cleared, Motion detected
- Conditions: Motion is detected, Motion is not detected
-
Detected (
-
Moving (
moving): Shows whether something is moving.-
Moving (
on) -
Not moving (
off)
-
Moving (
-
Occupancy (
occupancy): Shows whether a room or area is occupied.-
Detected (
on) -
Clear (
off) - Triggers: Occupancy cleared, Occupancy detected
- Conditions: Occupancy is detected, Occupancy is not detected
-
Detected (
-
Opening (
opening): Shows whether something is open, such as a cabinet or a drawer.-
Open (
on) -
Closed (
off)
-
Open (
-
Plug (
plug): Shows whether something is plugged in.-
Plugged in (
on) -
Unplugged (
off)
-
Plugged in (
-
Power (
power): Shows whether power is detected.-
On (
on) -
Off (
off)
-
On (
-
Presence (
presence): Shows whether someone is home.-
Home (
on) -
Away (
off)
-
Home (
-
Problem (
problem): Shows whether there is a problem.-
Problem (
on) -
OK (
off)
-
Problem (
-
Running (
running): Shows whether something is running.-
Running (
on) -
Not running (
off)
-
Running (
-
Safety (
safety): Shows whether something is unsafe.-
Unsafe (
on) -
Safe (
off)
-
Unsafe (
-
Smoke (
smoke): Shows whether smoke is detected.-
Detected (
on) -
Clear (
off) - Triggers: Smoke cleared, Smoke detected
- Conditions: Smoke cleared, Smoke detected
-
Detected (
-
Sound (
sound): Shows whether sound is detected.-
Detected (
on) -
Clear (
off)
-
Detected (
-
Tamper (
tamper): Shows whether tampering is detected.-
Tampering detected (
on) -
Clear (
off)
-
Tampering detected (
-
Update (
update): Shows whether an update is available.-
Update available (
on) -
Up-to-date (
off)
-
Update available (
-
Vibration (
vibration): Shows whether vibration is detected.-
Detected (
on) -
Clear (
off) - Triggers: Vibration cleared, Vibration detected
- Conditions: Vibration is detected, Vibration is not detected
-
Detected (
-
Window (
window): Shows whether a window is open.-
Open (
on) -
Closed (
off) - Triggers: Window closed, Window opened
- Conditions: Window is closed, Window is open
-
Open (
For sensors that measure values, see the sensor device classes.
Changing the device class of a binary sensor
If a binary sensor shows up as the wrong type, for example as an opening instead of a door, you can change its device class.
You can only change the device class in the UI if the binary sensor has a unique ID. A binary sensor without a unique ID shows a message in its entity settings instead. For such a binary sensor, you can change the device class in YAML with customization.
- Go to Settings > Devices & services > Entities and select the binary sensor.
- In the top-right corner, select Settings
. - Under Show as, select the type that matches your device.
- Select Update.
- Result: The binary sensor shows up as the new type in triggers and dashboards.
If you created the binary sensor with a template helper, change the device class in the options of the template helper instead.