1 """Support for Meteoclimatic sensor."""
6 SensorEntityDescription,
13 UnitOfPrecipitationDepth,
23 DataUpdateCoordinator,
26 from .const
import ATTRIBUTION, DOMAIN, MANUFACTURER, MODEL
28 SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
32 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
33 device_class=SensorDeviceClass.TEMPERATURE,
34 state_class=SensorStateClass.MEASUREMENT,
38 name=
"Daily Max Temperature",
39 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
40 device_class=SensorDeviceClass.TEMPERATURE,
44 name=
"Daily Min Temperature",
45 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
46 device_class=SensorDeviceClass.TEMPERATURE,
49 key=
"humidity_current",
51 native_unit_of_measurement=PERCENTAGE,
52 device_class=SensorDeviceClass.HUMIDITY,
53 state_class=SensorStateClass.MEASUREMENT,
57 name=
"Daily Max Humidity",
58 native_unit_of_measurement=PERCENTAGE,
59 device_class=SensorDeviceClass.HUMIDITY,
63 name=
"Daily Min Humidity",
64 native_unit_of_measurement=PERCENTAGE,
65 device_class=SensorDeviceClass.HUMIDITY,
68 key=
"pressure_current",
70 native_unit_of_measurement=UnitOfPressure.HPA,
71 device_class=SensorDeviceClass.PRESSURE,
72 state_class=SensorStateClass.MEASUREMENT,
76 name=
"Daily Max Pressure",
77 native_unit_of_measurement=UnitOfPressure.HPA,
78 device_class=SensorDeviceClass.PRESSURE,
82 name=
"Daily Min Pressure",
83 native_unit_of_measurement=UnitOfPressure.HPA,
84 device_class=SensorDeviceClass.PRESSURE,
89 native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
90 device_class=SensorDeviceClass.WIND_SPEED,
91 state_class=SensorStateClass.MEASUREMENT,
95 name=
"Daily Max Wind Speed",
96 native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
97 device_class=SensorDeviceClass.WIND_SPEED,
102 native_unit_of_measurement=DEGREE,
103 icon=
"mdi:weather-windy",
107 name=
"Daily Precipitation",
108 native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
109 device_class=SensorDeviceClass.PRECIPITATION,
115 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
117 """Set up the Meteoclimatic sensor platform."""
118 coordinator = hass.data[DOMAIN][entry.entry_id]
127 """Representation of a Meteoclimatic sensor."""
129 _attr_attribution = ATTRIBUTION
132 self, coordinator: DataUpdateCoordinator, description: SensorEntityDescription
134 """Initialize the Meteoclimatic sensor."""
137 station = self.coordinator.data[
"station"]
138 self.
_attr_name_attr_name = f
"{station.name} {description.name}"
143 """Return the device info."""
145 entry_type=DeviceEntryType.SERVICE,
146 identifiers={(DOMAIN, self.
platformplatform.config_entry.unique_id)},
147 manufacturer=MANUFACTURER,
149 name=self.coordinator.name,
154 """Return the state of the sensor."""
156 getattr(self.coordinator.data[
"weather"], self.
entity_descriptionentity_description.key)
157 if self.coordinator.data
None __init__(self, DataUpdateCoordinator coordinator, SensorEntityDescription description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)