Allow platform unloading (#13784)

* Allow platform unloading

* Add tests

* Add last test
This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2018-04-12 14:28:54 +02:00
1 parent dd7e6edf61
commit f47572d3c0
12 files changed
+218 -14

No files matched your search

+12
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.