mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Save config entry after updating system options (#26077)
This commit is contained in:
parent
d1483b6f29
commit
a1dbdbba6a
@ -272,7 +272,11 @@ async def system_options_update(hass, connection, msg):
|
||||
entry_id = changes.pop("entry_id")
|
||||
entry = hass.config_entries.async_get_entry(entry_id)
|
||||
|
||||
if entry and changes:
|
||||
entry.system_options.update(**changes)
|
||||
if entry is None:
|
||||
connection.send_error(
|
||||
msg["id"], websocket_api.const.ERR_NOT_FOUND, "Config entry not found"
|
||||
)
|
||||
return
|
||||
|
||||
connection.send_result(msg["id"], entry.system_options.as_dict())
|
||||
hass.config_entries.async_update_entry(entry, system_options=changes)
|
||||
connection.send_result(msg["id"], entry.system_options.as_dict())
|
||||
|
@ -522,7 +522,9 @@ class ConfigEntries:
|
||||
return await self.async_setup(entry_id)
|
||||
|
||||
@callback
|
||||
def async_update_entry(self, entry, *, data=_UNDEF, options=_UNDEF):
|
||||
def async_update_entry(
|
||||
self, entry, *, data=_UNDEF, options=_UNDEF, system_options=_UNDEF
|
||||
):
|
||||
"""Update a config entry."""
|
||||
if data is not _UNDEF:
|
||||
entry.data = data
|
||||
@ -530,10 +532,12 @@ class ConfigEntries:
|
||||
if options is not _UNDEF:
|
||||
entry.options = options
|
||||
|
||||
if data is not _UNDEF or options is not _UNDEF:
|
||||
for listener_ref in entry.update_listeners:
|
||||
listener = listener_ref()
|
||||
self.hass.async_create_task(listener(self.hass, entry))
|
||||
if system_options is not _UNDEF:
|
||||
entry.system_options.update(**system_options)
|
||||
|
||||
for listener_ref in entry.update_listeners:
|
||||
listener = listener_ref()
|
||||
self.hass.async_create_task(listener(self.hass, entry))
|
||||
|
||||
self._async_schedule_save()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user