hon icon indicating copy to clipboard operation
hon copied to clipboard

HA 2025.6 Haier integration not working

Open mdolejsi1 opened this issue 6 months ago • 16 comments

I have updated HA to version 2025.6. Integration is not loading. It is completely broken.

Logger: homeassistant.bootstrap Zdroj: bootstrap.py:999 První výskyt: 06:37:13 (1 výskyt) Naposledy logováno: 06:37:13

Waiting on integrations to complete setup: {('hon', '01JWC38FGT3G8FQ9W1VKT10KY1'): 4386161.504713396}

Logger: homeassistant.util.loop Zdroj: util/loop.py:137 První výskyt: 06:36:55 (6 výskytů) Naposledy logováno: 06:37:38

Detected blocking call to read_text with args (PosixPath('/usr/local/lib/python3.13/site-packages/jaraco/text/Lorem ipsum.txt'),) inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.13/site-packages/jaraco/text/init.py, line 233: files(name).joinpath('Lorem ipsum.txt').read_text(encoding='utf-8')), please create a bug report at https://github.com/Andre0512/hon/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#read_text Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 894, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon( Detected blocking call to open with args (PosixPath('/usr/local/lib/python3.13/site-packages/jaraco/text/Lorem ipsum.txt'),) inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.13/pathlib/_abc.py, line 632: with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:), please create a bug report at https://github.com/Andre0512/hon/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 894, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon( Detected blocking call to listdir with args ('/config',) inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.13/site-packages/pkg_resources/init.py, line 2378: return os.listdir(path)), please create a bug report at https://github.com/Andre0512/hon/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#listdir Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 894, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon( Detected blocking call to listdir with args ('/usr/local/lib/python3.13/site-packages/AEMET_OpenData-0.6.4.dist-info',) inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.13/site-packages/pkg_resources/init.py, line 2392: if len(os.listdir(path)) == 0:), please create a bug report at https://github.com/Andre0512/hon/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#listdir Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 894, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon( Detected blocking call to open with args ('/usr/local/lib/python3.13/site-packages/azure_kusto_data-4.5.1.dist-info/namespace_packages.txt', 'rb') inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.13/site-packages/pkg_resources/init.py, line 1909: with open(path, 'rb') as stream:), please create a bug report at https://github.com/Andre0512/hon/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 227, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 213, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.13/asyncio/base_events.py", line 706, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 677, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2034, in _run_once handle._run() File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 894, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 660, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon(

mdolejsi1 avatar Jun 12 '25 05:06 mdolejsi1

same here

filewalker1 avatar Jun 12 '25 10:06 filewalker1

same problem here :(

AFiREiNSiDE182 avatar Jun 12 '25 10:06 AFiREiNSiDE182

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hon/init.py", line 58, in async_setup_entry hass.config_entries.async_forward_entry_setup(entry, platform) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ConfigEntries' object has no attribute 'async_forward_entry_setup'. Did you mean: 'async_forward_entry_setups'?

I get this error

snattanzi avatar Jun 12 '25 11:06 snattanzi

Same problem.

QuaKim avatar Jun 12 '25 13:06 QuaKim

I noticed the same issue...

dragon791 avatar Jun 12 '25 16:06 dragon791

https://github.com/Andre0512/hon/issues/303#issuecomment-2967595278

QuaKim avatar Jun 12 '25 17:06 QuaKim

change this

 for platform in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setups(entry, platform)
        )

to

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

in custom_components/hon/__init__.py

ugkhan21 avatar Jun 12 '25 19:06 ugkhan21

Many thanks @ugkhan21 ! Now it works!

dragon791 avatar Jun 12 '25 20:06 dragon791

change this

 for platform in PLATFORMS:
        hass.async_create_task(
            hass.config_entries.async_forward_entry_setups(entry, platform)
        )

to

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

in custom_components/hon/__init__.py

This is not work for me, the integration loads the sensors, but fails at te moment

My resolution: https://github.com/Andre0512/hon/issues/303#issuecomment-2968229369

QuaKim avatar Jun 12 '25 21:06 QuaKim

Next i'll copy paste my modified "custom_components/hon/init.py" file.

The errore I got is still the same as before:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hon/init.py", line 58, in async_setup_entry hass.config_entries.async_forward_entry_setup(entry, PLATFORMS) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ConfigEntries' object has no attribute 'async_forward_entry_setup'. Did you mean: 'async_forward_entry_setups'?

import logging from pathlib import Path from typing import Any

import voluptuous as vol # type: ignore[import-untyped] from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.helpers import config_validation as cv, aiohttp_client from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pyhon import Hon

from .const import DOMAIN, PLATFORMS, MOBILE_ID, CONF_REFRESH_TOKEN

_LOGGER = logging.getLogger(name)

HON_SCHEMA = vol.Schema( { vol.Required(CONF_EMAIL): cv.string, vol.Required(CONF_PASSWORD): cv.string, } )

CONFIG_SCHEMA = vol.Schema( {DOMAIN: vol.Schema(vol.All(cv.ensure_list, [HON_SCHEMA]))}, extra=vol.ALLOW_EXTRA, )

async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: session = aiohttp_client.async_get_clientsession(hass) if (config_dir := hass.config.config_dir) is None: raise ValueError("Missing Config Dir") hon = await Hon( email=entry.data[CONF_EMAIL], password=entry.data[CONF_PASSWORD], mobile_id=MOBILE_ID, session=session, test_data_path=Path(config_dir), refresh_token=entry.data.get(CONF_REFRESH_TOKEN, ""), ).create()

# Save the new refresh token
hass.config_entries.async_update_entry(
    entry, data={**entry.data, CONF_REFRESH_TOKEN: hon.api.auth.refresh_token}
)

coordinator: DataUpdateCoordinator[dict[str, Any]] = DataUpdateCoordinator(
    hass, _LOGGER, name=DOMAIN
)
hon.subscribe_updates(coordinator.async_set_updated_data)

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.unique_id] = {"hon": hon, "coordinator": coordinator}

for platform in PLATFORMS:
    hass.async_create_task(
        hass.config_entries.async_forward_entry_setup(entry, PLATFORMS)
    )
return True

async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: refresh_token = hass.data[DOMAIN][entry.unique_id]["hon"].api.auth.refresh_token

hass.config_entries.async_update_entry(
    entry, data={**entry.data, CONF_REFRESH_TOKEN: refresh_token}
)
unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload:
    if not hass.data[DOMAIN]:
        hass.data.pop(DOMAIN, None)
return unload

snattanzi avatar Jun 13 '25 11:06 snattanzi

The fix worked fine for me in hon (and also govee plugin). @snattanzi Did you restart HA after saving changes to the file? I believe it is a necessary step for HA to pick up the changes, simple plugin reload didn't work for me.

B4rt0 avatar Jun 25 '25 10:06 B4rt0

The fix worked fine for me in hon (and also govee plugin). @snattanzi Did you restart HA after saving changes to the file? I believe it is a necessary step for HA to pick up the changes, simple plugin reload didn't work for me.

Just to confirm, you definitely do need to restart HA after applying the fix - it didn't work for me until I did so.

ric355 avatar Jun 27 '25 11:06 ric355

@B4rt0 I did restart but nothing worked for me. Then I double checked the code and modified again the yaml. Now it seems to work. This is the code of my init

"""The Candy integration.""" from future import annotations

import logging from datetime import timedelta

import async_timeout

from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .client import CandyClient, WashingMachineStatus

from .const import *

_LOGGER = logging.getLogger(name)

async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up Candy from a config entry."""

ip_address = config_entry.data[CONF_IP_ADDRESS]
encryption_key = config_entry.data.get(CONF_PASSWORD, "")
use_encryption = config_entry.data.get(CONF_KEY_USE_ENCRYPTION, True)

session = async_get_clientsession(hass)
client = CandyClient(session, ip_address, encryption_key, use_encryption)

async def update_status():
    try:
        async with async_timeout.timeout(40):
            status = await client.status_with_retry()
            _LOGGER.debug("Fetched status: %s", status)
            return status
    except Exception as err:
        raise UpdateFailed(f"Error communicating with API: {repr(err)}") from err

coordinator = DataUpdateCoordinator(
    hass,
    _LOGGER,
    name=DOMAIN,
    update_interval=timedelta(seconds=60),
    update_method=update_status,
)

await coordinator.async_config_entry_first_refresh()

hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = {
    DATA_KEY_COORDINATOR: coordinator
}

await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

return True

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: del hass.data[DOMAIN]

return unload_ok

snattanzi avatar Jul 01 '25 10:07 snattanzi

@B4rt0 I did restart but nothing worked for me. Then I double checked the code and modified again the yaml. Now it seems to work. This is the code of my init

"""The Candy integration.""" from future import annotations

import logging from datetime import timedelta

import async_timeout

from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .client import CandyClient, WashingMachineStatus

from .const import *

_LOGGER = logging.getLogger(name)

async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up Candy from a config entry."""

ip_address = config_entry.data[CONF_IP_ADDRESS]
encryption_key = config_entry.data.get(CONF_PASSWORD, "")
use_encryption = config_entry.data.get(CONF_KEY_USE_ENCRYPTION, True)

session = async_get_clientsession(hass)
client = CandyClient(session, ip_address, encryption_key, use_encryption)

async def update_status():
    try:
        async with async_timeout.timeout(40):
            status = await client.status_with_retry()
            _LOGGER.debug("Fetched status: %s", status)
            return status
    except Exception as err:
        raise UpdateFailed(f"Error communicating with API: {repr(err)}") from err

coordinator = DataUpdateCoordinator(
    hass,
    _LOGGER,
    name=DOMAIN,
    update_interval=timedelta(seconds=60),
    update_method=update_status,
)

await coordinator.async_config_entry_first_refresh()

hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = {
    DATA_KEY_COORDINATOR: coordinator
}

await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

return True

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) if unload_ok: del hass.data[DOMAIN]

return unload_ok

Can you post full code or init.py files? Thank you

AFiREiNSiDE182 avatar Jul 01 '25 13:07 AFiREiNSiDE182

The Candy integration..txt

This is my code of the init file

snattanzi avatar Jul 01 '25 13:07 snattanzi

The Candy integration..txt

This is my code of the init file

Thank you! Doesn't work for me.

AFiREiNSiDE182 avatar Jul 01 '25 15:07 AFiREiNSiDE182