mirror of
https://github.com/home-assistant/core.git
synced 2026-04-20 12:15:49 +00:00
Don't use async_update_reload_and_abort with update listeners in tele… (#167696)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user