Compare commits

..

1 Commits

Author SHA1 Message Date
Lukas Svoboda a6cb121b4a
Bump version from 1.8.1 to 1.8.2 2026-02-26 19:38:03 +01:00
4 changed files with 37 additions and 32 deletions

View File

@ -52,7 +52,6 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
"""Init global updater.""" """Init global updater."""
self.hass = hass self.hass = hass
self.config = config self.config = config
self.config_entry = config
self.windy = WindyPush(hass, config) self.windy = WindyPush(hass, config)
self.pocasi: PocasiPush = PocasiPush(hass, config) self.pocasi: PocasiPush = PocasiPush(hass, config)
super().__init__(hass, _LOGGER, name=DOMAIN) super().__init__(hass, _LOGGER, name=DOMAIN)

View File

@ -40,10 +40,9 @@ class InvalidAuth(HomeAssistantError):
class ConfigOptionsFlowHandler(OptionsFlow): class ConfigOptionsFlowHandler(OptionsFlow):
"""Handle WeatherStation ConfigFlow.""" """Handle WeatherStation ConfigFlow."""
def __init__(self, config_entry) -> None: def __init__(self) -> None:
"""Initialize flow.""" """Initialize flow."""
super().__init__() super().__init__()
self.config_entry = config_entry
self.windy_data: dict[str, Any] = {} self.windy_data: dict[str, Any] = {}
self.windy_data_schema = {} self.windy_data_schema = {}
@ -54,15 +53,18 @@ class ConfigOptionsFlowHandler(OptionsFlow):
self.pocasi_cz: dict[str, Any] = {} self.pocasi_cz: dict[str, Any] = {}
self.pocasi_cz_schema = {} self.pocasi_cz_schema = {}
@property
def config_entry(self):
return self.hass.config_entries.async_get_entry(self.handler)
async def _get_entry_data(self): async def _get_entry_data(self):
"""Get entry data.""" """Get entry data."""
entry_data = {**self.config_entry.data, **self.config_entry.options}
self.user_data = { self.user_data = {
API_ID: entry_data.get(API_ID), API_ID: self.config_entry.options.get(API_ID),
API_KEY: entry_data.get(API_KEY), API_KEY: self.config_entry.options.get(API_KEY),
WSLINK: entry_data.get(WSLINK, False), WSLINK: self.config_entry.options.get(WSLINK, False),
DEV_DBG: entry_data.get(DEV_DBG, False), DEV_DBG: self.config_entry.options.get(DEV_DBG, False),
} }
self.user_data_schema = { self.user_data_schema = {
@ -74,17 +76,19 @@ class ConfigOptionsFlowHandler(OptionsFlow):
self.sensors = { self.sensors = {
SENSORS_TO_LOAD: ( SENSORS_TO_LOAD: (
entry_data.get(SENSORS_TO_LOAD) self.config_entry.options.get(SENSORS_TO_LOAD)
if isinstance(entry_data.get(SENSORS_TO_LOAD), list) if isinstance(self.config_entry.options.get(SENSORS_TO_LOAD), list)
else [] else []
) )
} }
self.windy_data = { self.windy_data = {
WINDY_STATION_ID: entry_data.get(WINDY_STATION_ID), WINDY_STATION_ID: self.config_entry.options.get(WINDY_STATION_ID),
WINDY_STATION_PW: entry_data.get(WINDY_STATION_PW), WINDY_STATION_PW: self.config_entry.options.get(WINDY_STATION_PW),
WINDY_ENABLED: entry_data.get(WINDY_ENABLED, False), WINDY_ENABLED: self.config_entry.options.get(WINDY_ENABLED, False),
WINDY_LOGGER_ENABLED: entry_data.get(WINDY_LOGGER_ENABLED, False), WINDY_LOGGER_ENABLED: self.config_entry.options.get(
WINDY_LOGGER_ENABLED, False
),
} }
self.windy_data_schema = { self.windy_data_schema = {
@ -103,11 +107,15 @@ class ConfigOptionsFlowHandler(OptionsFlow):
} }
self.pocasi_cz = { self.pocasi_cz = {
POCASI_CZ_API_ID: entry_data.get(POCASI_CZ_API_ID, ""), POCASI_CZ_API_ID: self.config_entry.options.get(POCASI_CZ_API_ID, ""),
POCASI_CZ_API_KEY: entry_data.get(POCASI_CZ_API_KEY, ""), POCASI_CZ_API_KEY: self.config_entry.options.get(POCASI_CZ_API_KEY, ""),
POCASI_CZ_ENABLED: entry_data.get(POCASI_CZ_ENABLED, False), POCASI_CZ_ENABLED: self.config_entry.options.get(POCASI_CZ_ENABLED, False),
POCASI_CZ_LOGGER_ENABLED: entry_data.get(POCASI_CZ_LOGGER_ENABLED, False), POCASI_CZ_LOGGER_ENABLED: self.config_entry.options.get(
POCASI_CZ_SEND_INTERVAL: entry_data.get(POCASI_CZ_SEND_INTERVAL, 30), POCASI_CZ_LOGGER_ENABLED, False
),
POCASI_CZ_SEND_INTERVAL: self.config_entry.options.get(
POCASI_CZ_SEND_INTERVAL, 30
),
} }
self.pocasi_cz_schema = { self.pocasi_cz_schema = {
@ -302,4 +310,4 @@ class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
@callback @callback
def async_get_options_flow(config_entry) -> ConfigOptionsFlowHandler: def async_get_options_flow(config_entry) -> ConfigOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return ConfigOptionsFlowHandler(config_entry) return ConfigOptionsFlowHandler()

View File

@ -14,6 +14,6 @@
"issue_tracker": "https://github.com/schizza/SWS-12500-custom-component/issues", "issue_tracker": "https://github.com/schizza/SWS-12500-custom-component/issues",
"requirements": [], "requirements": [],
"ssdp": [], "ssdp": [],
"version": "1.8.3", "version": "1.8.2",
"zeroconf": [] "zeroconf": []
} }

View File

@ -33,8 +33,8 @@ class Routes:
def switch_route(self, coordinator: Callable, url_path: str): def switch_route(self, coordinator: Callable, url_path: str):
"""Switch route.""" """Switch route."""
for route in self.routes.values(): for url, route in self.routes.items():
if route.url_path == url_path: if url == url_path:
_LOGGER.info("New coordinator to route: %s", route.url_path) _LOGGER.info("New coordinator to route: %s", route.url_path)
route.enabled = True route.enabled = True
route.handler = coordinator route.handler = coordinator
@ -52,20 +52,18 @@ class Routes:
enabled: bool = False, enabled: bool = False,
): ):
"""Add route.""" """Add route."""
key = f"{route.method}:{url_path}" self.routes[url_path] = Route(url_path, route, handler, enabled)
self.routes[key] = Route(url_path, route, handler, enabled)
def get_route(self, url_path: str) -> Route | None: def get_route(self, url_path: str) -> Route:
"""Get route.""" """Get route."""
for route in self.routes.values(): return self.routes.get(url_path, Route)
if route.url_path == url_path:
return route
return None
def get_enabled(self) -> str: def get_enabled(self) -> str:
"""Get enabled routes.""" """Get enabled routes."""
enabled_routes = {route.url_path for route in self.routes.values() if route.enabled} enabled_routes = [
return ", ".join(sorted(enabled_routes)) if enabled_routes else "None" route.url_path for route in self.routes.values() if route.enabled
]
return "".join(enabled_routes) if enabled_routes else "None"
def __str__(self): def __str__(self):
"""Return string representation.""" """Return string representation."""