1
mirror of https://github.com/home-assistant/core synced 2024-10-01 05:30:36 +02:00

Config entry update data (#16843)

* WIP

* Allow updating data of a config entry
This commit is contained in:
Paulus Schoutsen 2018-09-25 12:21:11 +02:00 committed by GitHub
parent 2b2502c91c
commit f4974f58fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -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.

View File

@ -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
}