nordicopen / easee_hass

Custom component for Easee EV charger integration with Home Assistant
207 stars 34 forks source link

Error unloading entry #31

Closed tmjo closed 3 years ago

tmjo commented 3 years ago

Sometimes (or always?) when changing custom units in the integration options, I seem to get an error saying "Error unloading entry".

Logger: homeassistant.config_entries
Source: helpers/entity_component.py:176
First occurred: 9:49:01 PM (2 occurrences)
Last logged: 9:49:01 PM

Error unloading entry tmjo for sensor
Error unloading entry tmjo for switch
Traceback (most recent call last):
  File "/workspaces/git/homeassistant/config_entries.py", line 309, in async_unload
    result = await component.async_unload_entry(  # type: ignore
  File "/workspaces/git/homeassistant/components/sensor/__init__.py", line 72, in async_unload_entry
    return await hass.data[DOMAIN].async_unload_entry(entry)
  File "/workspaces/git/homeassistant/helpers/entity_component.py", line 176, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

On one occation I had duplicat sensors made (automatically given an _2 suffix by HA), and it got really messy. Solved by removing entities and adding again, but shouldn't be like this. When this happens, it seems like custom units is not working well although it works as intended when "cleaning up". Anyone see how this can be fixed? Perhaps this is the cause for the error reported by nsimb in #28 as well?

tmjo commented 3 years ago

Fixed by @fondberg and @olalid in work on official component => Proposed fix in PR #34

tmjo commented 3 years ago

Released in 0.9.15, please test and see if ok.

TheAzzi commented 3 years ago

There are still some issues unloading sensors:

After removing a sensor/switch in "Options" -> "Sensors monitored" the sensor/switch entity will reappear in the "Configuration" -> "Entities" list after a few seconds, but with "Sensor" or "Switch" listed in the "Integration" column instead of "Easee charger component".

So if you add back the sensor/switch in "Options" -> "Sensor monitored" you will get the *_2 naming. But if you restart Home Assistant first, the "ghost" entities will disappear and you will get the proper naming when you add them back.

Also I noticed when adding or removing sensors/switches, the integration is reset in some kind of way causing it to loose the configured area if you have set it. (EDIT: Created separate issue #49 for this)

fondberg commented 3 years ago

Fixed in #47

fondberg commented 3 years ago

Can you test with the new release?

TheAzzi commented 3 years ago

Testing new release 0.9.17 When adding or removing sensors, the device disappears and I have to "reload" the component/integration. When I have reloaded the component it works again, but I have duplicate entries of the sensors etc.

TheAzzi commented 3 years ago

Not able to fully test the unloading due to the other bugs, but when removing the component completely I noticed the "ghost" devices popped up again in the entity registry after some seconds, so I suspect the issue is not fully resolved as well.