Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for yalexs ble binary sensors."""
2 
3 from __future__ import annotations
4 
5 from yalexs_ble import ConnectionInfo, DoorStatus, LockInfo, LockState
6 
8  BinarySensorDeviceClass,
9  BinarySensorEntity,
10 )
11 from homeassistant.core import HomeAssistant, callback
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 
14 from . import YALEXSBLEConfigEntry
15 from .entity import YALEXSBLEEntity
16 
17 
19  hass: HomeAssistant,
20  entry: YALEXSBLEConfigEntry,
21  async_add_entities: AddEntitiesCallback,
22 ) -> None:
23  """Set up YALE XS binary sensors."""
24  data = entry.runtime_data
25  lock = data.lock
26  if lock.lock_info and lock.lock_info.door_sense:
28 
29 
31  """Yale XS BLE binary sensor."""
32 
33  _attr_device_class = BinarySensorDeviceClass.DOOR
34 
35  @callback
37  self, new_state: LockState, lock_info: LockInfo, connection_info: ConnectionInfo
38  ) -> None:
39  """Update the state."""
40  self._attr_is_on_attr_is_on = new_state.door == DoorStatus.OPENED
41  super()._async_update_state(new_state, lock_info, connection_info)
None _async_update_state(self, LockState new_state, LockInfo lock_info, ConnectionInfo connection_info)
None async_setup_entry(HomeAssistant hass, YALEXSBLEConfigEntry entry, AddEntitiesCallback async_add_entities)