Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adapt new ha constants #635

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vergil-zhao
Copy link

Fix all related deprecated constants

#631 #632 #633 #634

@ThemeIT
Copy link

ThemeIT commented Jan 4, 2025

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

Thanks vergil!

@BassBoi
Copy link

BassBoi commented Jan 4, 2025

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

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

@Kapikontroll
Copy link

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

@debelg2024
Copy link

Thanks Virgil for this quick fix.
Works perfect again.

@javieliyo
Copy link

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

@vergil-zhao
Copy link
Author

vergil-zhao commented Jan 4, 2025

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

@dougle03
Copy link

dougle03 commented Jan 4, 2025

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.

@vergil-zhao
Copy link
Author

vergil-zhao commented Jan 4, 2025

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.

ThemeIT

This comment was marked as duplicate.

@sboixg
Copy link

sboixg commented Jan 4, 2025

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

@pcmike
Copy link

pcmike commented Jan 5, 2025

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)

@francescopeloi
Copy link

francescopeloi commented Jan 5, 2025

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
Copy link

francescopeloi commented Jan 5, 2025

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.

@erikgieseler
Copy link

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.

@Lips2000
Copy link

Lips2000 commented Jan 6, 2025

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.

@Nicorjs
Copy link

Nicorjs commented Jan 6, 2025

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 !!!!

@PhySix66
Copy link

PhySix66 commented Jan 7, 2025

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)

@aghe1965
Copy link

It worked perfectly for me! Thank you

@DirkFace
Copy link

DirkFace commented Jan 18, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.