mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 18:57:57 +00:00
Config entry update data (#16843)
* WIP * Allow updating data of a config entry
This commit is contained in:
parent
2b2502c91c
commit
f4974f58fe
@ -379,6 +379,12 @@ class ConfigEntries:
|
||||
CONN_CLASS_UNKNOWN))
|
||||
for entry in config['entries']]
|
||||
|
||||
@callback
|
||||
def async_update_entry(self, entry, *, data):
|
||||
"""Update a config entry."""
|
||||
entry.data = data
|
||||
self._async_schedule_save()
|
||||
|
||||
async def async_forward_entry_setup(self, entry, component):
|
||||
"""Forward the setup of an entry to a different component.
|
||||
|
||||
|
@ -315,3 +315,20 @@ async def test_loading_default_config(hass):
|
||||
await manager.async_load()
|
||||
|
||||
assert len(manager.async_entries()) == 0
|
||||
|
||||
|
||||
async def test_updating_entry_data(manager):
|
||||
"""Test that we can update an entry data."""
|
||||
entry = MockConfigEntry(
|
||||
domain='test',
|
||||
data={'first': True},
|
||||
)
|
||||
entry.add_to_manager(manager)
|
||||
|
||||
manager.async_update_entry(entry, data={
|
||||
'second': True
|
||||
})
|
||||
|
||||
assert entry.data == {
|
||||
'second': True
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user