1 """Support for yalexs ble sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from yalexs_ble
import ConnectionInfo, LockInfo, LockState
13 SensorEntityDescription,
18 SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
20 UnitOfElectricPotential,
25 from .
import YALEXSBLEConfigEntry
26 from .entity
import YALEXSBLEEntity
27 from .models
import YaleXSBLEData
30 @dataclass(frozen=True, kw_only=True)
32 """Describes Yale Access Bluetooth sensor entity."""
34 value_fn: Callable[[LockState, LockInfo, ConnectionInfo], int | float |
None]
37 SENSORS: tuple[YaleXSBLESensorEntityDescription, ...] = (
40 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
41 entity_category=EntityCategory.DIAGNOSTIC,
42 state_class=SensorStateClass.MEASUREMENT,
44 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
45 entity_registry_enabled_default=
False,
46 value_fn=
lambda state, info, connection: connection.rssi,
50 device_class=SensorDeviceClass.BATTERY,
51 entity_category=EntityCategory.DIAGNOSTIC,
52 state_class=SensorStateClass.MEASUREMENT,
54 native_unit_of_measurement=PERCENTAGE,
55 value_fn=
lambda state, info, connection: state.battery.percentage
60 key=
"battery_voltage",
61 translation_key=
"battery_voltage",
62 device_class=SensorDeviceClass.VOLTAGE,
63 entity_category=EntityCategory.DIAGNOSTIC,
64 state_class=SensorStateClass.MEASUREMENT,
66 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
67 entity_registry_enabled_default=
False,
68 value_fn=
lambda state, info, connection: state.battery.voltage
77 entry: YALEXSBLEConfigEntry,
78 async_add_entities: AddEntitiesCallback,
80 """Set up YALE XS Bluetooth sensors."""
81 data = entry.runtime_data
86 """Yale XS Bluetooth sensor."""
88 entity_description: YaleXSBLESensorEntityDescription
92 description: YaleXSBLESensorEntityDescription,
95 """Initialize the sensor."""
102 self, new_state: LockState, lock_info: LockInfo, connection_info: ConnectionInfo
104 """Update the state."""
106 new_state, lock_info, connection_info
None __init__(self, YaleXSBLESensorEntityDescription description, YaleXSBLEData data)
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)