midea_ac_lan icon indicating copy to clipboard operation
midea_ac_lan copied to clipboard

fix: adapt new ha constants

Open vergil-zhao opened this issue 10 months ago • 18 comments

Fix all related deprecated constants

#631 #632 #633 #634

vergil-zhao avatar Jan 04 '25 07:01 vergil-zhao

Tested in my 2025.1 HA environment, works perfectly without error log outputs and fixes the deprecation

Thanks vergil!

leonhuhn avatar Jan 04 '25 09:01 leonhuhn

I'm sorry for n00b question, but how do i import these fixes ?

EDIT: nvm, i have found out, sry ;-)

BassBoi avatar Jan 04 '25 09:01 BassBoi

Thanks for the quick help, it works great! :)

Kapikontroll avatar Jan 04 '25 09:01 Kapikontroll

Thanks Virgil for this quick fix. Works perfect again.

debelg2024 avatar Jan 04 '25 11:01 debelg2024

Fix all related deprecated constants

#631 #632 #633 #634

Could you help me with more details. I don't know what I should do. thank you

javieliyo avatar Jan 04 '25 11:01 javieliyo

Here are a few short instructions on how to apply these changes to your HA before this repo's owner merge this PR. Note: this may only work on HAOS

  1. You must install the Terminal add-on in your HA, then follow the commands below.
git clone https://github.com/vergil-zhao/midea_ac_lan.git
cp -r midea_ac_lan/custom_components/midea_ac_lan config/custom_components/
  1. Restart your HA

vergil-zhao avatar Jan 04 '25 11:01 vergil-zhao

Here are a few short instructions on how to apply these changes to your HA before this repo's owner merge this PR.

This is great, although the instructions are a little different for those running HA Core in Docker... Just need to preceed the commands with sudo and adjust the paths. Also, copy is not a native command, cp should be used instead.

dougle03 avatar Jan 04 '25 13:01 dougle03

This is great, although the instructions are a little different for those running HA Core in Docker... Just need to preceed the commands with sudo and adjust the paths. Also, copy is not a native command, cp should be used instead.

Thanks, just updated the comment.

vergil-zhao avatar Jan 04 '25 17:01 vergil-zhao

Hi, thanks a lot Vergil, is working perfectely. very good job. thanks.

sboixg avatar Jan 04 '25 23:01 sboixg

Thanks for this PR.. what about the following errors that get logged as well..

Logger: homeassistant.helpers.frame Source: helpers/frame.py:234 First occurred: 10:06:33 PM (11 occurrences) Last logged: 10:06:33 PM

Detected code that calls async_forward_entry_setup for integration midea_ac_lan with title: Dehumidifier and entry_id: f0931c97c4092c8bc1715d34c685e994, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1, please report this issue

Detected that custom integration 'midea_ac_lan' calls async_forward_entry_setup for integration, midea_ac_lan with title: Dehumidifier and entry_id: f0931c97c4092c8bc1715d34c685e994, which is deprecated, await async_forward_entry_setups instead at custom_components/midea_ac_lan/init.py, line 171: hass.async_create_task(hass.config_entries.async_forward_entry_setup(. This will stop working in Home Assistant 2025.6, please create a bug report at https://github.com/georgezhao2010/midea_ac_lan/issues

Plus a bunch of these…

COLOR_MODE_WHITE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2026.1. Use ColorMode.WHITE instead, please report it to the author of the 'midea_ac_lan' custom integration ATTR_COLOR_TEMP was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2026.1. Use kelvin equivalent (ATTR_COLOR_TEMP_KELVIN) instead, please report it to the author of the 'midea_ac_lan' custom integration ATTR_KELVIN was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2026.1. Use ATTR_COLOR_TEMP_KELVIN instead, please report it to the author of the 'midea_ac_lan' custom integration ATTR_MIN_MIREDS was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2026.1. Use kelvin equivalent (ATTR_MAX_COLOR_TEMP_KELVIN) instead, please report it to the author of the 'midea_ac_lan' custom integration ATTR_MAX_MIREDS was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2026.1. Use kelvin equivalent (ATTR_MIN_COLOR_TEMP_KELVIN) instead, please report it to the author of the 'midea_ac_lan' custom integration

And finally.. Logger: homeassistant.util.loop Source: util/loop.py:136 First occurred: 10:06:30 PM (1 occurrences) Last logged: 10:06:30 PM

Detected blocking call to import_module with args ('.a1.device', 'custom_components.midea_ac_lan.midea.devices') inside the event loop by custom integration 'midea_ac_lan' at custom_components/midea_ac_lan/midea/devices/init.py, line 23: module = import_module(device_path, package) (offender: /config/custom_components/midea_ac_lan/midea/devices/init.py, line 23: module = import_module(device_path, package)), please create a bug report at https://github.com/georgezhao2010/midea_ac_lan/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module 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 707, in run_until_complete self.run_forever() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 678, in run_forever self._run_once() File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2033, 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/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in async_setup_component await asyncio.gather( File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async.py", line 45, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 788, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup await self.__async_setup_with_context(hass, integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 640, in __async_setup_with_context result = await component.async_setup_entry(hass, self) File "/config/custom_components/midea_ac_lan/init.py", line 148, in async_setup_entry device = device_selector( File "/config/custom_components/midea_ac_lan/midea/devices/init.py", line 23, in device_selector module = import_module(device_path, package)

pcmike avatar Jan 05 '25 03:01 pcmike

Hi, it didn't work for me. I copied the 3 files directly into the box, overwritten the original files. I am on version v0.3.22.

This is what I am getting:

Logger: homeassistant.setup
Source: setup.py:334
First occurred: 10:24:32 (1 occurrences)
Last logged: 10:24:32

Setup failed for custom integration 'midea_ac_lan': Unable to import component: Exception importing custom_components.midea_ac_lan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, 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.13/importlib/__init__.py", line 88, 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 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/midea_ac_lan/__init__.py", line 17, in <module>
    from .midea_devices import MIDEA_DEVICES
  File "/config/custom_components/midea_ac_lan/midea_devices.py", line 997, in <module>
    C3Attributes.status_dhw: {
    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'DeviceAttributes' has no attribute 'status_dhw'. Did you mean: 'status_ibh'?

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

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, 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.13/importlib/__init__.py", line 88, 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 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/midea_ac_lan/__init__.py", line 17, in <module>
    from .midea_devices import MIDEA_DEVICES
  File "/config/custom_components/midea_ac_lan/midea_devices.py", line 997, in <module>
    C3Attributes.status_dhw: {
    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'DeviceAttributes' has no attribute 'status_dhw'. Did you mean: 'status_ibh'?

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1035, in async_get_component
    self._component_future.result()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1027, in async_get_component
    comp = self._get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1086, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.midea_ac_lan

francescopeloi avatar Jan 05 '25 09:01 francescopeloi

I think I understand the problem: this change is based on the version on master, not the last released version. Copying the files will not work as they are based on changes that have not been released with v0.3.22 (this change is the one is the one causing the error, not sure if fixing this one will fix everything). Manually editing the files on your local version will work, though.

edit: I've now checked out master, copied the files over, and now it works. So don't copy the files over if you have the latest released version.

francescopeloi avatar Jan 05 '25 09:01 francescopeloi

This reporistory is dead because the maintainer has not been available for a long time and no more pull requests are being merged. You should switch to https://github.com/wuwentao/midea_ac_lan.

erikgieseler avatar Jan 05 '25 15:01 erikgieseler

Here are a few short instructions on how to apply these changes to your HA before this repo's owner merge this PR. Note: this may only work on HAOS

  1. You must install the Terminal add-on in your HA, then follow the commands below.
git clone https://github.com/vergil-zhao/midea_ac_lan.git
cp -r midea_ac_lan/custom_components/midea_ac_lan config/custom_components/
  1. Restart your HA

This worked a treat!

Thank you.

Lips2000 avatar Jan 06 '25 14:01 Lips2000

Here are a few short instructions on how to apply these changes to your HA before this repo's owner merge this PR. Note: this may only work on HAOS

  1. You must install the Terminal add-on in your HA, then follow the commands below.
git clone https://github.com/vergil-zhao/midea_ac_lan.git
cp -r midea_ac_lan/custom_components/midea_ac_lan config/custom_components/
  1. Restart your HA

work 100%

Thanks !!!!

Nicorjs avatar Jan 06 '25 23:01 Nicorjs

This reporistory is dead because the maintainer has not been available for a long time and no more pull requests are being merged. You should switch to https://github.com/wuwentao/midea_ac_lan.

Tested this as well, and works. Even better. With georgezhao2010-s version HA gave me some notification, that in a future version (2025.04?) this implementation will no longer work. Recommend switching for everyone. Nevertheless, thanks for the fixes. (I'm still a noob at HA)

PhySix66 avatar Jan 07 '25 21:01 PhySix66

It worked perfectly for me! Thank you

aghe1965 avatar Jan 12 '25 13:01 aghe1965

Thank you, followed the instructions above & it fixed mine.

DirkFace avatar Jan 18 '25 08:01 DirkFace