Binary Sensor
binary_sensor
binary_sensor domain implementation (read-only).
SPEC
module-attribute
SPEC: DomainSpec[BinarySensor] = register_domain(DomainSpec(name='binary_sensor', entity_cls=BinarySensor))
The DomainSpec registered with the shared DomainRegistry.
BinarySensor
Bases: Entity
A read-only Home Assistant binary sensor entity.
Binary sensors represent boolean detection states (e.g. motion,
door open). They are read-only; no actions are exposed. Listener
names use on_activate / on_deactivate.
Source code in src/haclient/domains/binary_sensor.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
is_on
property
is_on: bool
Whether the binary sensor is in the on state.
device_class
property
device_class: str | None
Device class (e.g. "motion", "door").
on_activate
on_activate(func: ValueChangeHandler) -> ValueChangeHandler
Register a listener for when the sensor activates (state on).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
callable
|
Sync or async callable invoked with |
required |
Returns:
| Type | Description |
|---|---|
callable
|
The same func, returned so the method can be used as a decorator. |
Source code in src/haclient/domains/binary_sensor.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
on_deactivate
on_deactivate(func: ValueChangeHandler) -> ValueChangeHandler
Register a listener for when the sensor deactivates (state off).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
callable
|
Sync or async callable invoked with |
required |
Returns:
| Type | Description |
|---|---|
callable
|
The same func, returned so the method can be used as a decorator. |
Source code in src/haclient/domains/binary_sensor.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |