1 """Support for KNX/IP weather station."""
3 from __future__
import annotations
6 from xknx.devices
import Weather
as XknxWeather
8 from homeassistant
import config_entries
22 from .
import KNXModule
23 from .const
import KNX_MODULE_KEY
24 from .entity
import KnxYamlEntity
25 from .schema
import WeatherSchema
31 async_add_entities: AddEntitiesCallback,
33 """Set up switch(es) for KNX platform."""
34 knx_module = hass.data[KNX_MODULE_KEY]
35 config: list[ConfigType] = knx_module.config_yaml[Platform.WEATHER]
38 KNXWeather(knx_module, entity_config)
for entity_config
in config
43 """Return a KNX weather device to be used within XKNX."""
46 name=config[CONF_NAME],
47 sync_state=config[WeatherSchema.CONF_SYNC_STATE],
48 group_address_temperature=config[WeatherSchema.CONF_KNX_TEMPERATURE_ADDRESS],
49 group_address_brightness_south=config.get(
50 WeatherSchema.CONF_KNX_BRIGHTNESS_SOUTH_ADDRESS
52 group_address_brightness_east=config.get(
53 WeatherSchema.CONF_KNX_BRIGHTNESS_EAST_ADDRESS
55 group_address_brightness_west=config.get(
56 WeatherSchema.CONF_KNX_BRIGHTNESS_WEST_ADDRESS
58 group_address_brightness_north=config.get(
59 WeatherSchema.CONF_KNX_BRIGHTNESS_NORTH_ADDRESS
61 group_address_wind_speed=config.get(WeatherSchema.CONF_KNX_WIND_SPEED_ADDRESS),
62 group_address_wind_bearing=config.get(
63 WeatherSchema.CONF_KNX_WIND_BEARING_ADDRESS
65 group_address_rain_alarm=config.get(WeatherSchema.CONF_KNX_RAIN_ALARM_ADDRESS),
66 group_address_frost_alarm=config.get(
67 WeatherSchema.CONF_KNX_FROST_ALARM_ADDRESS
69 group_address_wind_alarm=config.get(WeatherSchema.CONF_KNX_WIND_ALARM_ADDRESS),
70 group_address_day_night=config.get(WeatherSchema.CONF_KNX_DAY_NIGHT_ADDRESS),
71 group_address_air_pressure=config.get(
72 WeatherSchema.CONF_KNX_AIR_PRESSURE_ADDRESS
74 group_address_humidity=config.get(WeatherSchema.CONF_KNX_HUMIDITY_ADDRESS),
79 """Representation of a KNX weather device."""
82 _attr_native_pressure_unit = UnitOfPressure.PA
83 _attr_native_temperature_unit = UnitOfTemperature.CELSIUS
84 _attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
86 def __init__(self, knx_module: KNXModule, config: ConfigType) ->
None:
87 """Initialize of a KNX sensor."""
89 knx_module=knx_module,
97 """Return current temperature in C."""
98 return self.
_device_device.temperature
102 """Return current air pressure in Pa."""
103 return self.
_device_device.air_pressure
107 """Return current weather condition."""
108 return self.
_device_device.ha_current_state().value
112 """Return current humidity."""
113 return self.
_device_device.humidity
117 """Return current wind bearing in degrees."""
118 return self.
_device_device.wind_bearing
122 """Return current wind speed in m/s."""
123 return self.
_device_device.wind_speed
float|None humidity(self)
int|None wind_bearing(self)
float|None native_temperature(self)
float|None native_wind_speed(self)
None __init__(self, KNXModule knx_module, ConfigType config)
float|None native_pressure(self)
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
XknxWeather _create_weather(XKNX xknx, ConfigType config)