Don't use async_update_reload_and_abort with update listeners in tele… (#167696)

This commit is contained in:
G Johansson
2026-04-09 23:44:42 +02:00
committed by GitHub
parent 5f8483ba07
commit 86b5efaf2c
4 changed files with 11 additions and 4 deletions

View File

@@ -913,6 +913,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: TelegramBotConfigEntry)
async def update_listener(hass: HomeAssistant, entry: TelegramBotConfigEntry) -> None:
"""Handle config changes."""
entry.runtime_data.parse_mode = entry.options[ATTR_PARSER]
if entry.runtime_data.old_config_data != entry.data:
# Reload if config data has changed
hass.config_entries.async_schedule_reload(entry.entry_id)
# reload entities
await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@@ -302,6 +302,7 @@ class TelegramNotificationService:
"""Initialize the service."""
self.app = app
self.config = config
self.old_config_data = config.data.copy()
self._parsers: dict[str, str | None] = {
PARSER_HTML: ParseMode.HTML,
PARSER_MD: ParseMode.MARKDOWN,

View File

@@ -369,7 +369,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN):
if self.source == SOURCE_RECONFIGURE:
user_input.update(self._step_user_data)
return self.async_update_reload_and_abort(
return self.async_update_and_abort(
self._get_reconfigure_entry(),
title=self._bot_name,
data_updates=user_input,
@@ -534,7 +534,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN):
if user_input[CONF_PLATFORM] != PLATFORM_WEBHOOKS:
await self._shutdown_bot()
return self.async_update_reload_and_abort(
return self.async_update_and_abort(
self._get_reconfigure_entry(), title=bot_name, data_updates=user_input
)
@@ -579,7 +579,7 @@ class TelegramBotConfigFlow(ConfigFlow, domain=DOMAIN):
description_placeholders=description_placeholders,
)
return self.async_update_reload_and_abort(
return self.async_update_and_abort(
self._get_reauth_entry(), title=bot_name, data_updates=updated_data
)

View File

@@ -75,11 +75,14 @@ async def test_options_flow(
async def test_reconfigure_flow_broadcast(
hass: HomeAssistant,
mock_webhooks_config_entry: MockConfigEntry,
mock_register_webhook: None,
mock_external_calls: None,
mock_webhooks_config_entry: MockConfigEntry,
) -> None:
"""Test reconfigure flow for broadcast bot."""
mock_webhooks_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_webhooks_config_entry.entry_id)
await hass.async_block_till_done()
result = await mock_webhooks_config_entry.start_reconfigure_flow(hass)
assert result["step_id"] == "reconfigure"