rgc99 / irrigation_unlimited

♒Irrigation controller for Home Assistant
MIT License
329 stars 49 forks source link

Irrigation_unlimited will not start in HomeAssistant version 2024.8.0b0 #174

Open XerxesDGreat opened 3 months ago

XerxesDGreat commented 3 months ago

Describe the bug After upgrading to the latest homeassistant beta version, an error is shown in the Notifications and the plugin no longer functions

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to 2024.8.0b0
  2. Restart the HomeAssistant instance
  3. Wait for the database migration to complete
  4. Observe the logs

Expected behavior Irrigation Unlimited should start with no errors

Screenshots

image

Irrigation Unlimited log file These messages are very important in helping to determine the problem. Go into Settings -> System -> Logs. In the search box put in irrigation_unlimited (Note the underscore between the two words) and press the LOAD FULL LOGS button. Copy and paste below.


2024-08-01 10:38:54.661 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration irrigation_unlimited which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-08-01 10:39:07.571 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module with args ('custom_components.irrigation_unlimited',) in /usr/src/homeassistant/homeassistant/loader.py, line 1067: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue
2024-08-01 10:39:07.585 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration 'irrigation_unlimited': Unable to import component: cannot import name 'DATA_INSTANCE' from 'homeassistant.components.recorder.const' (/usr/src/homeassistant/homeassistant/components/recorder/const.py)
File "/config/custom_components/irrigation_unlimited/__init__.py", line 13, in <module>
from .irrigation_unlimited import IUCoordinator
File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 65, in <module>
File "/config/custom_components/irrigation_unlimited/history.py", line 7, in <module>
File "/config/custom_components/irrigation_unlimited/__init__.py", line 13, in <module>
from .irrigation_unlimited import IUCoordinator
File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 65, in <module>
File "/config/custom_components/irrigation_unlimited/history.py", line 7, in <module>

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Due to the database migration, it's unclear whether rolling back to a previous version of HomeAssistant functions. I will test this

XerxesDGreat commented 3 months ago

looks like it's due to this constant being removed: https://github.com/home-assistant/core/compare/2024.7.4...2024.8.0b0#diff-160724e1751b3cad9bbf4404c7f98416d09a60015a3cc07f4a7a307f9621db37L22

edit: thought this would link directly to the change since I copied the permalink, but alas!

Any rate, this is the change: https://github.com/home-assistant/core/commit/5dbd7684ce7433f063445254d0f3485c4b6045af

XerxesDGreat commented 3 months ago

I believe a simple change can be made which works on my local instance:

6 from homeassistant.util import dt
7 - from homeassistant.components.recorder.const import DATA_INSTANCE as RECORDER_INSTANCE
7 + from homeassistant.components.recorder import DATA_INSTANCE as RECORDER_INSTANCE
8 from homeassistant.components.recorder import get_instance

I can submit a merge request if you'd be amenable to that

rgc99 commented 3 months ago

Thanks, perhaps put a try/except incase someone updates/installs on an earlier HA version. I haven't tried it but something like this.

try:
    from homeassistant.components.recorder.const import DATA_INSTANCE as RECORDER_INSTANCE
except ImportError:
    from homeassistant.helpers.recorder import DATA_INSTANCE as RECORDER_INSTANCE

Always happy for some help.

rgc99 commented 3 months ago

I have added your changes. Thanks for your help in spotting this one.

XerxesDGreat commented 2 months ago

no problem; that's a better fix. Thanks for adding it! (apologies for the delay; I was AFK for a couple days)