gcobb321 / icloud3_v3

iCloud3 v3, Development Version - This Repo/Version is used for development and testing of new and updated features. It is not the official release of iCloud3 v3, .
MIT License
144 stars 12 forks source link

HA 2024.7.0 Recorder Error #308

Closed scotty1395 closed 5 days ago

scotty1395 commented 1 month ago

Running iCloud3 v3.0.5.2. After upgrading to HA 2024.7.0 I get the below error. Recorder seems to lock up.

Disabling iCloud3 and restarting HA fixes the issue. Enabling iCloud3 triggers the error instantly.

Logger: homeassistant.core
Source: core.py:1559
First occurred: 3:12:49 pm (336 occurrences)
Last logged: 3:13:24 pm

Error running job: <Job listen * HassJobType.Callback <function Recorder.async_initialize.<locals>._event_listener at 0x7fdd0b5b3060>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1559, in async_fire_internal
    self._hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 938, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 330, in _event_listener
    if entity_filter(entity_id):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/icloud3/support/recorder_prefilter.py", line 123, in entity_filter
    return recorder_entity_filter(entity_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable
gcobb321 commented 1 month ago

I am in Switzerland and cannot release an update to iCloud3 to fix this error. However, I have updated the code in GitHub.

  1. Download the _support/recorderprefilter.py file in the iCloud3 GitHub repository here and save it to the icloud3/support directory. (Look for ‘Raw’ in the menu bar above the code on the right. The Download icon is the 2nd icon to the right)
  2. Restart HA.
scotty1395 commented 1 month ago

Appreciate the quick fix while you're travelling Gary. Unfortunately the updated file results in the following warning and errors.

Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 4:29:17 pm (1 occurrences)
Last logged: 4:29:17 pm

Detected blocking call to import_module with args ('custom_components.icloud3',) in /usr/src/homeassistant/homeassistant/loader.py, line 1050: 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 For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/setup.py", line 167, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)
Logger: homeassistant.loader
Source: loader.py:1050
First occurred: 4:29:17 pm (2 occurrences)
Last logged: 4:29:17 pm

Unexpected exception importing component custom_components.icloud3
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/icloud3/__init__.py", line 43, in <module>
    from .support                       import recorder_prefilter
  File "/config/custom_components/icloud3/support/recorder_prefilter.py", line 121
    if entity_id in hass.data['recorder_prefilter']['exclude_entities']):
                                                                       ^
SyntaxError: unmatched ')'
Logger: homeassistant.setup
Source: setup.py:322
First occurred: 4:29:17 pm (1 occurrences)
Last logged: 4:29:17 pm

Setup failed for custom integration 'icloud3': Unable to import component: Exception importing custom_components.icloud3
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/icloud3/__init__.py", line 43, in <module>
    from .support                       import recorder_prefilter
  File "/config/custom_components/icloud3/support/recorder_prefilter.py", line 121
    if entity_id in hass.data['recorder_prefilter']['exclude_entities']):
                                                                       ^
SyntaxError: unmatched ')'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 990, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1061, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.icloud3

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/icloud3/__init__.py", line 43, in <module>
    from .support                       import recorder_prefilter
  File "/config/custom_components/icloud3/support/recorder_prefilter.py", line 121
    if entity_id in hass.data['recorder_prefilter']['exclude_entities']):
                                                                       ^
SyntaxError: unmatched ')'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1010, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1061, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.icloud3
gcobb321 commented 1 month ago

All set. I fixed the unmatched ‘)’ error. Retry and see what happens.

Thx

scotty1395 commented 1 month ago

All working. Thanks Gary. Much appreciated. Enjoy Switzerland!

billraff commented 1 month ago

I downloaded the fixed file and it resolved the issue with the log errors. I am seeing some issues on my Energy Dashboard though. Can they be related to this fix?

Screenshot 2024-07-04 at 9 36 32 AM
asinwang commented 1 month ago

I am in Switzerland and cannot release an update to iCloud3 to fix this error. However, I have updated the code in GitHub.

  1. Download the _support/recorderprefilter.py file in the iCloud3 GitHub repository here and save it to the icloud3/support directory. (Look for ‘Raw’ in the menu bar above the code on the right. The Download icon is the 2nd icon to the right)
  2. Restart HA.

I do that , the error fix. But mysql db table no new date insert .

parklife200 commented 1 month ago

This appears to fix the icloud error, but this integration still appears to break the recorder post 2024.7. I have disabled the integration to get recorder working again

gcobb321 commented 1 month ago

See this issue to follow what others are doing while I am in Switzerland enjoying train rides in the Swiss Alps.

aplsms commented 3 weeks ago

I have warnings in the logs:

2024-07-08 09:59:52.654 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.icloud3_event_log exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2024-07-08 09:59:55.198 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.icloud3_event_log exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2024-07-08 10:00:00.472 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.icloud3_event_log exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2024-07-08 10:00:10.478 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for sensor.icloud3_event_log exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored

how to fix them?

gcobb321 commented 3 weeks ago

That warning is from the Recorder problem with HA 2024.7 where entities are no longer being excluded. You can ignore it for now. It will be addressed in an iCloud3 update when I return home n next week

Friedi1970 commented 3 weeks ago

That warning is from the Recorder problem with HA 2024.7 where entities are no longer being excluded. You can ignore it for now. It will be addressed in an iCloud3 update when I return home n next week

Well, unfortunately it can't be ignored for 2024.7.2 because icloud3 has been blocked :( https://github.com/home-assistant/core/pull/121658

smithbill17 commented 3 weeks ago

The latest update to HomeAssistant (2024.7.2) has simply 'blocked' the current version of iCloud3 integration as apparently it breaks the recorder functionality - so now I can't use iCloud3 until the underlying issue with the integration is fixed & an update released.

https://github.com/home-assistant/core/pull/121658

karaminder commented 3 weeks ago

Let this man enjoy his holiday! Perhaps, instead of whining or moaning, one can be (as I am) thankful for all of his hard work and effort he has provided to this integration.

Cheers to you @gcobb321

JtwoA commented 3 weeks ago

Let this man enjoy his holiday! Perhaps, instead of whining or moaning, one can be (as I am) thankful for all of his hard work and effort he has provided to this integration.

Cheers to you @gcobb321

I have been quietly thinking the same thing. He's in the Alps!!

gcobb321 commented 3 weeks ago

Thanks guys. It’s been a fun trip. Unfortunately, I get on United tomorrow to head home.

See here for a temporary solution to this problem. Scroll to the bottom and follow the instructions to get iCloud3 going again. An update will be released soon.

gcobb321 commented 2 weeks ago

iCloud3 v3.0.5.5 (7/16/2024) has been released that fixes this problem. It should be available on HACS in a day or so. No other changes have been made.