1 """Support for BSB-Lan sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
11 SensorEntityDescription,
19 from .
import BSBLanConfigEntry, BSBLanData
20 from .coordinator
import BSBLanCoordinatorData
21 from .entity
import BSBLanEntity
24 @dataclass(frozen=True, kw_only=True)
26 """Describes BSB-Lan sensor entity."""
28 value_fn: Callable[[BSBLanCoordinatorData], StateType]
31 SENSOR_TYPES: tuple[BSBLanSensorEntityDescription, ...] = (
33 key=
"current_temperature",
34 translation_key=
"current_temperature",
35 device_class=SensorDeviceClass.TEMPERATURE,
36 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
37 state_class=SensorStateClass.MEASUREMENT,
38 value_fn=
lambda data: data.sensor.current_temperature.value,
41 key=
"outside_temperature",
42 translation_key=
"outside_temperature",
43 device_class=SensorDeviceClass.TEMPERATURE,
44 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
45 state_class=SensorStateClass.MEASUREMENT,
46 value_fn=
lambda data: data.sensor.outside_temperature.value,
53 entry: BSBLanConfigEntry,
54 async_add_entities: AddEntitiesCallback,
56 """Set up BSB-Lan sensor based on a config entry."""
57 data = entry.runtime_data
62 """Defines a BSB-Lan sensor."""
64 entity_description: BSBLanSensorEntityDescription
69 description: BSBLanSensorEntityDescription,
71 """Initialize BSB-Lan sensor."""
72 super().
__init__(data.coordinator, data)
79 """Return the state of the sensor."""
StateType native_value(self)
None __init__(self, BSBLanData data, BSBLanSensorEntityDescription description)
None async_setup_entry(HomeAssistant hass, BSBLanConfigEntry entry, AddEntitiesCallback async_add_entities)