Allow platform unloading (#13784)

* Allow platform unloading

* Add tests

* Add last test
This commit is contained in:
Paulus Schoutsen
2018-04-12 08:28:54 -04:00
committed by Pascal Vizeli
parent dd7e6edf61
commit f47572d3c0
12 changed files with 218 additions and 14 deletions

View File

@@ -113,6 +113,18 @@ class EntityComponent(object):
return await self._platforms[key].async_setup_entry(config_entry)
async def async_unload_entry(self, config_entry):
"""Unload a config entry."""
key = config_entry.entry_id
platform = self._platforms.pop(key, None)
if platform is None:
raise ValueError('Config entry was never loaded!')
await platform.async_reset()
return True
@callback
def async_extract_from_service(self, service, expand_group=True):
"""Extract all known and available entities from a service call.