-
Notifications
You must be signed in to change notification settings - Fork 223
Description
I revived this error:
Logger: homeassistant.config_entries Source: config_entries.py:1006 First occurred: 10:09:43 AM (2 occurrences) Last logged: 2:23:40 PM
Error unloading entry 192.168.1.186 for solarman
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1006, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solarman/init.py", line 28, in async_unload_entry hass.data[DOMAIN].pop(entry.entry_id) ~~~~~~~~~^^^^^^^^ KeyError: 'solarman'
Solution:
Here's what was fixed in /homeassistant/custom_components/solarman/init.py:
Problem: async_setup_entry never populates hass.data[DOMAIN], but async_unload_entry (line 28) and update_listener (line 35) both tried to access it, causing KeyError: 'solarman'.
Changes:
Line 28-29: Added a check that DOMAIN exists in hass.data before popping, and used .pop(entry.entry_id, None) to avoid a second potential KeyError on the entry_id.
Line 36: Added a guard checking both DOMAIN in hass.data and entry.entry_id in hass.data[DOMAIN] before calling .config().
Restart Home Assistant to apply the fix. The error should no longer appear when unloading/reloading the solarman integration.