pnbruckner/ha-sun2

Error with restart of HA

vingerha opened this issue · 6 comments

Although everything seems to be working fine, every restart of HA shows this below

Logger: homeassistant
Source: config_entries.py:1578
First occurred: 09:44:07 (1 occurrences)
Last logged: 09:44:07

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1606, in async_reload
    unload_result = await self.async_unload(entry_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1578, in async_unload
    raise OperationNotAllowed(
homeassistant.config_entries.OperationNotAllowed: The config entry Home (sun2) with entry_id 4f8256a91b07df988d01eb9b69907d38 cannot be unloaded because it is not in a recoverable state (ConfigEntryState.SETUP_IN_PROGRESS)

HA Container v 2024.3.1
My yaml:

sun2:
  - unique_id: home
    binary_sensors:
      - unique_id: bs1
        name: dawndusk
        elevation: -6
    sensors:
      - unique_id: s1
        name: sun2
        time_at_elevation: 0  

What version of this integration are you using?

That does seem familiar, although I can't say I've seen it recently. I'm working on a fairly big overhaul of the integration for allowing different ways to specify what affects sunrise & sunset times (i.e., horizon vs an obstruction.) I may have already addressed this. But, I'll check, just to be sure.

Thanks for reporting it!

I figured out why this sounded familiar. Apparently, I had the same issue with my Illuminance integration, where I fixed the problem.

I am using the latest version... and I would like to understand (a bit) what you do/did to fix it :)

Basically, don't call async_reload if the config entry isn't loaded. I do that by checking entry.state.recoverable. I'll try to get a fix out shortly, independent of the other enhancements I'm working on.

@vingerha please try 3.2.1b0 and let me know if it fixes the issue for you.

I applied this to my dev instance and the error no longer shows, the few sensors I have setup (above) and use are fine for as far as I can see on this short time...looks good and thanks for the speedy response !!