On removal, only unload config entry if loaded (#16844)

* On removal, only unload config entry if loaded

* Fix test
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2018-09-25 14:29:13 +02:00
1 parent 093285f92f
commit a1c914dfeb
3 files changed
+42 -4

No files matched your search

+4 -1
View File
@@ -340,7 +340,10 @@ class ConfigEntries:
entry = self._entries.pop(found)
self._async_schedule_save()
unloaded = await entry.async_unload(self.hass)
if entry.state == ENTRY_STATE_LOADED:
unloaded = await entry.async_unload(self.hass)
else:
unloaded = True
device_registry = await \
self.hass.helpers.device_registry.async_get_registry()