fix: centralize hass fixture usage and clean domain residue on unload

This commit is contained in:
Joshua King
2026-09-13 19:04:20 -04:00
parent 2dbb309844
commit e2d21f2e39
8 changed files with 394 additions and 488 deletions
+4 -1
View File
@@ -50,7 +50,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
runtime_data = hass.data.setdefault(DOMAIN, {}).pop(entry.entry_id, None)
domain_data = hass.data.setdefault(DOMAIN, {})
runtime_data = domain_data.pop(entry.entry_id, None)
if not domain_data:
hass.data.pop(DOMAIN, None)
if runtime_data is None:
runtime_data = getattr(entry, "runtime_data", None)
if runtime_data is not None: