Compare commits

...

7 commits

Author SHA1 Message Date
9f06486512
Version bump
Some checks failed
Run Python tests / Run tests (3.12) (push) Successful in 1m21s
Validate / validate-hacs (push) Failing after 42s
Validate / validate-hassfest (push) Failing after 36s
2024-12-29 18:47:59 +01:00
3ede45af43
Merge pull request #66 from jdejaegh/62-set-option-flow-config_entry-explicitly
Rename internal variable of IrmKmiOptionFlow to avoid name clash
2024-12-29 18:39:57 +01:00
34cb9e1bb5
Merge pull request #65 from jdejaegh/64-async_config_entry_first_refresh
Fix 'irm_kmi' uses `async_config_entry_first_refresh`, which is only supported for coordinators with a config entry
2024-12-29 18:38:09 +01:00
0de029b30b
Rename internal variable of IrmKmiOptionFlow to avoid name clash 2024-12-29 18:34:19 +01:00
4978a92385
Fix typo 2024-12-29 18:17:17 +01:00
1254ae7157
Use hass.config_entries.async_reload to reload config entry 2024-12-29 18:06:08 +01:00
91d46dcb6c
Put config entry in coordinator 2024-12-29 18:04:24 +01:00
4 changed files with 15 additions and 16 deletions

View file

@ -45,8 +45,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry.""" """Reload config entry."""
await async_unload_entry(hass, entry) await hass.config_entries.async_reload(entry.entry_id)
await async_setup_entry(hass, entry)
async def async_migrate_entry(hass, config_entry: ConfigEntry): async def async_migrate_entry(hass, config_entry: ConfigEntry):

View file

@ -107,7 +107,7 @@ class IrmKmiConfigFlow(ConfigFlow, domain=DOMAIN):
class IrmKmiOptionFlow(OptionsFlow): class IrmKmiOptionFlow(OptionsFlow):
def __init__(self, config_entry: ConfigEntry) -> None: def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow.""" """Initialize options flow."""
self.config_entry = config_entry self.current_config_entry = config_entry
async def async_step_init(self, user_input: dict | None = None) -> FlowResult: async def async_step_init(self, user_input: dict | None = None) -> FlowResult:
"""Manage the options.""" """Manage the options."""
@ -119,21 +119,21 @@ class IrmKmiOptionFlow(OptionsFlow):
step_id="init", step_id="init",
data_schema=vol.Schema( data_schema=vol.Schema(
{ {
vol.Optional(CONF_STYLE, default=get_config_value(self.config_entry, CONF_STYLE)): vol.Optional(CONF_STYLE, default=get_config_value(self.current_config_entry, CONF_STYLE)):
SelectSelector(SelectSelectorConfig(options=CONF_STYLE_OPTIONS, SelectSelector(SelectSelectorConfig(options=CONF_STYLE_OPTIONS,
mode=SelectSelectorMode.DROPDOWN, mode=SelectSelectorMode.DROPDOWN,
translation_key=CONF_STYLE)), translation_key=CONF_STYLE)),
vol.Optional(CONF_DARK_MODE, default=get_config_value(self.config_entry, CONF_DARK_MODE)): bool, vol.Optional(CONF_DARK_MODE, default=get_config_value(self.current_config_entry, CONF_DARK_MODE)): bool,
vol.Optional(CONF_USE_DEPRECATED_FORECAST, vol.Optional(CONF_USE_DEPRECATED_FORECAST,
default=get_config_value(self.config_entry, CONF_USE_DEPRECATED_FORECAST)): default=get_config_value(self.current_config_entry, CONF_USE_DEPRECATED_FORECAST)):
SelectSelector(SelectSelectorConfig(options=CONF_USE_DEPRECATED_FORECAST_OPTIONS, SelectSelector(SelectSelectorConfig(options=CONF_USE_DEPRECATED_FORECAST_OPTIONS,
mode=SelectSelectorMode.DROPDOWN, mode=SelectSelectorMode.DROPDOWN,
translation_key=CONF_USE_DEPRECATED_FORECAST)), translation_key=CONF_USE_DEPRECATED_FORECAST)),
vol.Optional(CONF_LANGUAGE_OVERRIDE, vol.Optional(CONF_LANGUAGE_OVERRIDE,
default=get_config_value(self.config_entry, CONF_LANGUAGE_OVERRIDE)): default=get_config_value(self.current_config_entry, CONF_LANGUAGE_OVERRIDE)):
SelectSelector(SelectSelectorConfig(options=CONF_LANGUAGE_OVERRIDE_OPTIONS, SelectSelector(SelectSelectorConfig(options=CONF_LANGUAGE_OVERRIDE_OPTIONS,
mode=SelectSelectorMode.DROPDOWN, mode=SelectSelectorMode.DROPDOWN,
translation_key=CONF_LANGUAGE_OVERRIDE)) translation_key=CONF_LANGUAGE_OVERRIDE))

View file

@ -43,6 +43,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
super().__init__( super().__init__(
hass, hass,
_LOGGER, _LOGGER,
config_entry=entry,
# Name of the data. For logging purposes. # Name of the data. For logging purposes.
name="IRM KMI weather", name="IRM KMI weather",
# Polling interval. Will only be polled if there are subscribers. # Polling interval. Will only be polled if there are subscribers.
@ -52,11 +53,10 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
self._zone = get_config_value(entry, CONF_ZONE) self._zone = get_config_value(entry, CONF_ZONE)
self._dark_mode = get_config_value(entry, CONF_DARK_MODE) self._dark_mode = get_config_value(entry, CONF_DARK_MODE)
self._style = get_config_value(entry, CONF_STYLE) self._style = get_config_value(entry, CONF_STYLE)
self._config_entry = entry
self.shared_device_info = DeviceInfo( self.shared_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE, entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, entry.entry_id)}, identifiers={(DOMAIN, entry.entry_id)},
manufacturer=IRM_KMI_NAME.get(preferred_language(self.hass, self._config_entry)), manufacturer=IRM_KMI_NAME.get(preferred_language(self.hass, self.config_entry)),
name=f"{entry.title}" name=f"{entry.title}"
) )
@ -92,7 +92,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
_LOGGER.error(f"The zone {self._zone} is now out of Benelux and forecast is only available in Benelux. " _LOGGER.error(f"The zone {self._zone} is now out of Benelux and forecast is only available in Benelux. "
f"Associated device is now disabled. Move the zone back in Benelux and re-enable to fix " f"Associated device is now disabled. Move the zone back in Benelux and re-enable to fix "
f"this") f"this")
disable_from_config(self.hass, self._config_entry) disable_from_config(self.hass, self.config_entry)
issue_registry.async_create_issue( issue_registry.async_create_issue(
self.hass, self.hass,
@ -101,7 +101,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
is_fixable=True, is_fixable=True,
severity=issue_registry.IssueSeverity.ERROR, severity=issue_registry.IssueSeverity.ERROR,
translation_key='zone_moved', translation_key='zone_moved',
data={'config_entry_id': self._config_entry.entry_id, 'zone': self._zone}, data={'config_entry_id': self.config_entry.entry_id, 'zone': self._zone},
translation_placeholders={'zone': self._zone} translation_placeholders={'zone': self._zone}
) )
return ProcessedCoordinatorData() return ProcessedCoordinatorData()
@ -131,7 +131,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
localisation = images_from_api[0] localisation = images_from_api[0]
images_from_api = images_from_api[1:] images_from_api = images_from_api[1:]
lang = preferred_language(self.hass, self._config_entry) lang = preferred_language(self.hass, self.config_entry)
radar_animation = RadarAnimationData( radar_animation = RadarAnimationData(
hint=api_data.get('animation', {}).get('sequenceHint', {}).get(lang), hint=api_data.get('animation', {}).get('sequenceHint', {}).get(lang),
unit=api_data.get('animation', {}).get('unit', {}).get(lang), unit=api_data.get('animation', {}).get('unit', {}).get(lang),
@ -367,7 +367,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
return None return None
forecasts = list() forecasts = list()
lang = preferred_language(self.hass, self._config_entry) lang = preferred_language(self.hass, self.config_entry)
tz = await dt.async_get_time_zone('Europe/Brussels') tz = await dt.async_get_time_zone('Europe/Brussels')
forecast_day = dt.now(tz) forecast_day = dt.now(tz)
@ -502,7 +502,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
if warning_data is None or not isinstance(warning_data, list) or len(warning_data) == 0: if warning_data is None or not isinstance(warning_data, list) or len(warning_data) == 0:
return [] return []
lang = preferred_language(self.hass, self._config_entry) lang = preferred_language(self.hass, self.config_entry)
result = list() result = list()
for data in warning_data: for data in warning_data:
try: try:

View file

@ -12,5 +12,5 @@
"svgwrite==1.4.3", "svgwrite==1.4.3",
"aiofile==3.9.0" "aiofile==3.9.0"
], ],
"version": "0.2.24" "version": "0.2.25"
} }