Skip to content

Commit 46bd657

Browse files
committed
docs: new binary sensor-entity device class
1 parent d87c3a3 commit 46bd657

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

doc/entities/entity_sensor.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The sensor entity only supports the `ON` state and the [common entity states](RE
3737
|-------|-----------------------------------------------------|
3838
| ON | The sensor is available and providing measurements. |
3939

40-
### Device classes
40+
### Device Classes
4141

4242
The device class specifies the type of sensor. Default if not specified: `custom`.
4343

@@ -51,6 +51,19 @@ The device class specifies the type of sensor. Default if not specified: `custom
5151
| power | W | Power in watt or kilowatt |
5252
| temperature | °C | Temperature with automatic °C, °F conversion, depending on remote settings. Use `native_unit` option if the temperature is measured in °F. |
5353
| voltage | V | Voltage in volt |
54+
| binary | | Binary sensor. The binary specific device class is stored in the `unit` attribute. |
55+
56+
#### Binary Device Class
57+
58+
The `binary` device class allows specifying a binary sensor with two states in the `value` attribute: `on` and `off`.
59+
60+
These values can mean different things depending on the `unit` attribute. For example, a binary sensor with the `unit`
61+
attribute set to `sound`: `on` means sound detected and `off` means no sound detected. For `unit` set to `window`: `on`
62+
means the window is open and `off` means the window is closed.
63+
64+
If the `unit` attribute is not specified, the binary sensor is a generic on/off sensor.
65+
66+
🚧 Supported unit values are the Home Assistant binary sensor device classes: <https://www.home-assistant.io/integrations/binary_sensor/#device-class>
5467

5568
### Options
5669

@@ -86,9 +99,9 @@ The following attributes are supported:
8699
- Only sending the `unit` attribute is not valid.
87100
- If the state is never sent, the sensor is considered available (`ON`).
88101

89-
### Event examples
102+
### Event Examples
90103

91-
#### State change event
104+
#### State Change Event
92105

93106
Sensor with a number value:
94107

@@ -144,3 +157,22 @@ Sensor coming online with the current value:
144157
}
145158
}
146159
```
160+
161+
Binary sensor event:
162+
163+
```json
164+
{
165+
"kind": "event",
166+
"msg": "entity_change",
167+
"cat": "ENTITY",
168+
"msg_data": {
169+
"entity_type": "sensor",
170+
"entity_id": "sensor-bin1",
171+
"attributes": {
172+
"state": "ON",
173+
"value": "off",
174+
"unit": "running"
175+
}
176+
}
177+
}
178+
```

0 commit comments

Comments
 (0)