HomeAssistant-Mods / home-assistant-miele

Miele integration for Home assistant
142 stars 30 forks source link

Unable to prepare setup for platform miele.sensor since installation of HA 2023.5 #151

Closed ralfhanke closed 1 year ago

ralfhanke commented 1 year ago

Hi, I'm using v0.9.3 of the Miele Integration. Since I installed HA 2023.5, the Miele integration no longer works. I get numerous error entries in the logs. The entries look like this.

2023-05-04 01:43:30.687 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform miele.sensor: Platform not found (cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)).
2023-05-04 01:43:35.737 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/miele/__init__.py", line 180, in refresh_devices
platform = import_module(".{}".format(component), __name__)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/config/custom_components/miele/sensor.py", line 7, in <module>
from homeassistant.helpers.entity_registry import async_get_registry
ImportError: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)

Is this a bug? If not, can someone help me? Thank you!

BloodyusHellus commented 1 year ago

I get the same issue, also since 2023.5 update

Edit: after reverting back to 2023.4.6 using back-up I still get this error:

Logger: homeassistant.setup
Source: custom_components/miele/miele_at_home.py:174
Integration: miele (documentation, issues)
First occurred: 08:24:51 (1 occurrences)
Last logged: 08:24:51

Error during setup of component miele
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 256, in _async_setup_component
    result = await task
  File "/config/custom_components/miele/__init__.py", line 152, in async_setup
    data_get_devices = await client.get_devices(lang)
  File "/config/custom_components/miele/miele_at_home.py", line 48, in get_devices
    home_devices = await self._get_devices_raw(lang)
  File "/config/custom_components/miele/miele_at_home.py", line 32, in _get_devices_raw
    if await self._session.refresh_token(self.hass):
  File "/config/custom_components/miele/miele_at_home.py", line 165, in refresh_token
    self._token = await hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/miele/miele_at_home.py", line 174, in sync_refresh_token
    return self._session.refresh_token(
  File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 452, in refresh_token
    self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 427, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response
    validate_token_parameters(params)
  File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant)
faibe24 commented 1 year ago

Also for me, with hassio 2023.5 and miele release b.0.9.4.1

chheiss commented 1 year ago

Same here. Seems the component must be updated to use 'async_get' instead of 'async_get_registry'. Hope the developer does that... Thanks!

chheiss commented 1 year ago

Got it working again! In config/custom_components/miele/ the file sensor.py needs to be updated. In line 7, replace 'import async_get_registry' with 'import async_get' Restart, et voila...

beardymarrow commented 1 year ago

Got it working again! In config/custom_components/miele/ the file sensor.py needs to be updated. In line 7, replace 'import async_get_registry' with 'import async_get' Restart, et voila...

Deleting that line completely also works as per @baschte's pull request.

kloknibor commented 1 year ago

Is this issue solved with 0.9.4?

beardymarrow commented 1 year ago

Yes, working for me.

kloknibor commented 1 year ago

ok than I will close this issue