1 """Support for Stookwijzer Sensor."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from stookwijzer
import Stookwijzer
13 SensorEntityDescription,
22 from .const
import DOMAIN
23 from .coordinator
import StookwijzerConfigEntry, StookwijzerCoordinator
26 @dataclass(kw_only=True, frozen=True)
28 """Class describing Stookwijzer sensor entities."""
30 value_fn: Callable[[Stookwijzer], int | float | str |
None]
33 STOOKWIJZER_SENSORS = [
36 native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND,
37 suggested_unit_of_measurement=UnitOfSpeed.BEAUFORT,
38 device_class=SensorDeviceClass.WIND_SPEED,
39 suggested_display_precision=0,
40 state_class=SensorStateClass.MEASUREMENT,
41 value_fn=
lambda client: client.windspeed_ms,
44 key=
"air_quality_index",
45 device_class=SensorDeviceClass.AQI,
46 state_class=SensorStateClass.MEASUREMENT,
47 value_fn=
lambda client: client.lki,
51 translation_key=
"advice",
52 device_class=SensorDeviceClass.ENUM,
53 value_fn=
lambda client: client.advice,
54 options=[
"code_yellow",
"code_orange",
"code_red"],
61 entry: StookwijzerConfigEntry,
62 async_add_entities: AddEntitiesCallback,
64 """Set up Stookwijzer sensor from a config entry."""
71 """Defines a Stookwijzer binary sensor."""
73 entity_description: StookwijzerSensorDescription
74 _attr_attribution =
"Data provided by atlasleefomgeving.nl"
75 _attr_has_entity_name =
True
79 description: StookwijzerSensorDescription,
80 entry: StookwijzerConfigEntry,
82 """Initialize a Stookwijzer device."""
87 identifiers={(DOMAIN, entry.entry_id)},
88 manufacturer=
"Atlas Leefomgeving",
89 entry_type=DeviceEntryType.SERVICE,
90 configuration_url=
"https://www.atlasleefomgeving.nl/stookwijzer",
95 """Return the state of the device."""
int|float|str|None native_value(self)
None __init__(self, StookwijzerSensorDescription description, StookwijzerConfigEntry entry)
None async_setup_entry(HomeAssistant hass, StookwijzerConfigEntry entry, AddEntitiesCallback async_add_entities)