1 """Support for Meteoclimatic weather service."""
3 from meteoclimatic
import Condition
13 DataUpdateCoordinator,
16 from .const
import ATTRIBUTION, CONDITION_MAP, DOMAIN, MANUFACTURER, MODEL
20 """Return condition from dict CONDITION_MAP."""
21 if condition
in CONDITION_MAP:
22 return CONDITION_MAP[condition]
23 if isinstance(condition, Condition):
24 return condition.value
29 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
31 """Set up the Meteoclimatic weather platform."""
32 coordinator = hass.data[DOMAIN][entry.entry_id]
38 """Representation of a weather condition."""
40 _attr_attribution = ATTRIBUTION
41 _attr_native_pressure_unit = UnitOfPressure.HPA
42 _attr_native_temperature_unit = UnitOfTemperature.CELSIUS
43 _attr_native_wind_speed_unit = UnitOfSpeed.KILOMETERS_PER_HOUR
45 def __init__(self, coordinator: DataUpdateCoordinator) ->
None:
46 """Initialise the weather platform."""
48 self.
_unique_id_unique_id = self.coordinator.data[
"station"].code
49 self.
_name_name = self.coordinator.data[
"station"].name
53 """Return the name of the sensor."""
54 return self.
_name_name
58 """Return the unique id of the sensor."""
63 """Return the device info."""
65 entry_type=DeviceEntryType.SERVICE,
66 identifiers={(DOMAIN, self.
platformplatform.config_entry.unique_id)},
67 manufacturer=MANUFACTURER,
69 name=self.coordinator.name,
74 """Return the current condition."""
79 """Return the temperature."""
80 return self.coordinator.data[
"weather"].temp_current
84 """Return the humidity."""
85 return self.coordinator.data[
"weather"].humidity_current
89 """Return the pressure."""
90 return self.coordinator.data[
"weather"].pressure_current
94 """Return the wind speed."""
95 return self.coordinator.data[
"weather"].wind_current
99 """Return the wind bearing."""
100 return self.coordinator.data[
"weather"].wind_bearing
def native_temperature(self)
def native_wind_speed(self)
def native_pressure(self)
None __init__(self, DataUpdateCoordinator coordinator)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
def format_condition(condition)