midea_ac_lan icon indicating copy to clipboard operation
midea_ac_lan copied to clipboard

Replaced deprecated constants and wildcard imports (HA >= 2023.1)

Open caibinqing opened this issue 1 year ago • 20 comments

Replaced deprecated constants, which fixed warning (or error in some cases) in HA 2024.1.0

And replaced wildcard imports, fixed warning in HA 2024.1.1

This will require HA 2023.1

see https://developers.home-assistant.io/blog/2023/12/19/constant-deprecation/

Fixed #415 Fixed #429 Fixed #433 Fixed #444 Fixed #455 Fixed #463 Fixed #476 Fixed #480 Fixed #510


Fixed a typo in hacs.json


Also supported the new climate entity features flag, fixed warning in HA 2024.2

https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded

Fixed #479


Merged PR #486 for convenience


Fix blocking call to import_module inside the event loop. (Warning in 2024.5)

caibinqing avatar Jan 04 '24 07:01 caibinqing

are you sure about 2023.1 ? the deprication for these changes came with 2024.1 - so this should be the min. version (earlier versions would not be supported)

ChristophCaina avatar Jan 04 '24 13:01 ChristophCaina

are you sure about 2023.1 ? the deprication for these changes came with 2024.1 - so this should be the min. version (earlier versions would not be supported)

Yes, I have tested, it works in 2023.1

All deprecation came before 2023.1, and the warning starts from 2024.1

caibinqing avatar Jan 04 '24 13:01 caibinqing

Latest Unit were introduced in 2023.1 so since there you can use them safely. Please merge this PR and release an updated version of this fantastic integration.

chemelli74 avatar Jan 07 '24 14:01 chemelli74

Did a quick test and I this is the result:

2024-01-09 16:45:50.779 INFO (MainThread) [homeassistant.setup] Setup of domain min_max took 0.0 seconds
2024-01-09 16:46:06.247 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.midea_ac_lan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 822, in get_component
  File "/usr/local/lib/python3.11/enum.py", line 784, in __getattr__
    raise AttributeError(name) from None
2024-01-09 16:46:06.870 ERROR (MainThread) [homeassistant.setup] 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 822, in get_component

Does latest code works fine for you ?

chemelli74 avatar Jan 09 '24 15:01 chemelli74

Did a quick test and I this is the result:

2024-01-09 16:45:50.779 INFO (MainThread) [homeassistant.setup] Setup of domain min_max took 0.0 seconds
2024-01-09 16:46:06.247 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.midea_ac_lan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 822, in get_component
  File "/usr/local/lib/python3.11/enum.py", line 784, in __getattr__
    raise AttributeError(name) from None
2024-01-09 16:46:06.870 ERROR (MainThread) [homeassistant.setup] 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 822, in get_component

Does latest code works fine for you ?

Yes, works on my device without error. But I only have one Water Drinking Appliance.

What's your HA version?

caibinqing avatar Jan 10 '24 07:01 caibinqing

Yes, works on my device without error. But I only have one Water Drinking Appliance.

My devices are Air Conditioner 00000Q18

What's your HA version?

2024.1.2

chemelli74 avatar Jan 10 '24 11:01 chemelli74

I found the issue and is not related to this PR as expected.

Is related to the commit "restore status sensors of dhw & tbh". If I remove from midea_devices.py the related changes, all is fine.

This changes are not in use currently as latest release is dated Oct 16th, while the changes were committed on Oct 17th.

chemelli74 avatar Jan 27 '24 17:01 chemelli74

I found the issue and is not related to this PR as expected.

Is related to the commit "restore status sensors of dhw & tbh". If I remove from midea_devices.py the related changes, all is fine.

This changes are not in use currently as latest release is dated Oct 16th, while the changes were committed on Oct 17th.

Thanks for testing. Does this mean that this PR is safe to merge? And we need open another issue for the error you encountered.

caibinqing avatar Jan 29 '24 05:01 caibinqing

Yes this PR is safe to be merged. We need to understand the issue in the previous commit that is unrelated

chemelli74 avatar Jan 29 '24 08:01 chemelli74

Any movement on this one?

m4rkireland avatar Mar 14 '24 11:03 m4rkireland

I found the issue and is not related to this PR as expected.

Is related to the commit "restore status sensors of dhw & tbh". If I remove from midea_devices.py the related changes, all is fine.

This changes are not in use currently as latest release is dated Oct 16th, while the changes were committed on Oct 17th.

Hi, in v0.3.22 the implementation of the C3 heat pump is still buggy, see https://github.com/georgezhao2010/midea_ac_lan/issues/353. The changes you had removed are currently only included in the master but are important for the C3 heat pump. Unfortunately, no new version has been released since then. You have to use the master as a starting point for the C3 heat pump implementation, not v0.3.22.

erikgieseler avatar Mar 16 '24 19:03 erikgieseler

Hi, in v0.33.2 the implementation of the C3 heat pump is still buggy, see #353. The changes you had removed are currently only included in the master but are important for the C3 heat pump. Unfortunately, no new version has been released since then. You have to use the master as a starting point for the C3 heat pump implementation, not v0.33.2.

Ok, rebased. but it doesn’t really matter, if this PR will be merged

caibinqing avatar Mar 17 '24 05:03 caibinqing

I still get the following warnings in the log for my C3 heat pump with the adjustments:

`2024-03-17 13:10:32.143 WARNING (MainThread) [homeassistant.components.climate] Entity midea_ac_lan.142936511731561_climate_zone1 (<class 'custom_components.midea_ac_lan.climate.MideaC3Climate'>) does not set ClimateEntityFeature.TURN_OFF but implements the turn_off method. Please create a bug report at https://github.com/georgezhao2010/midea_ac_lan/issues

2024-03-17 13:10:32.143 WARNING (MainThread) [homeassistant.components.climate] Entity midea_ac_lan.142936511731561_climate_zone1 (<class 'custom_components.midea_ac_lan.climate.MideaC3Climate'>) does not set ClimateEntityFeature.TURN_ON but implements the turn_on method. Please create a bug report at https://github.com/georgezhao2010/midea_ac_lan/issues

2024-03-17 13:10:32.143 WARNING (MainThread) [homeassistant.components.climate] Entity midea_ac_lan.142936511731561_climate_zone1 (<class 'custom_components.midea_ac_lan.climate.MideaC3Climate'>) implements HVACMode(s): off, auto, cool, heat and therefore implicitly supports the turn_on/turn_off methods without setting the proper ClimateEntityFeature. Please create a bug report at https://github.com/georgezhao2010/midea_ac_lan/issues

`

erikgieseler avatar Mar 17 '24 12:03 erikgieseler

I still get the following warnings in the log for my C3 heat pump with the adjustments:

This is related to another issue, and I also fixed it here.

caibinqing avatar Mar 28 '24 03:03 caibinqing

I still get the following warnings in the log for my C3 heat pump with the adjustments:

This is related to another issue, and I also fixed it here.

Works perfectly. The error messages have disappeared. Thank you!

erikgieseler avatar Mar 28 '24 15:03 erikgieseler

I've come across the same message... we all get it...

javifly avatar Apr 08 '24 17:04 javifly

Not sure if this should be fixed but with HA version 2024.5.0 I get a lot of these:

Logger: homeassistant.components.climate Source: helpers/deprecation.py:206 integration: Climate (documentation, issues) First occurred: 19:53:29 (28 occurrences) Last logged: 19:53:29

SUPPORT_PRESET_MODE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.PRESET_MODE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_SWING_MODE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.SWING_MODE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_HUMIDITY was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_HUMIDITY instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_TEMPERATURE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_TEMPERATURE_RANGE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE_RANGE instead, please report it to the author of the 'midea_ac_lan' custom integration

sanderlv avatar May 02 '24 17:05 sanderlv

Not sure if this should be fixed but with HA version 2024.5.0 I get a lot of these:

Logger: homeassistant.components.climate Source: helpers/deprecation.py:206 integration: Climate (documentation, issues) First occurred: 19:53:29 (28 occurrences) Last logged: 19:53:29

SUPPORT_PRESET_MODE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.PRESET_MODE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_SWING_MODE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.SWING_MODE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_HUMIDITY was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_HUMIDITY instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_TEMPERATURE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE instead, please report it to the author of the 'midea_ac_lan' custom integration SUPPORT_TARGET_TEMPERATURE_RANGE was used from midea_ac_lan, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE_RANGE instead, please report it to the author of the 'midea_ac_lan' custom integration

Hello, I think this has already been fixed by this PR

caibinqing avatar May 03 '24 02:05 caibinqing

Then it's not fixed...

sanderlv avatar May 03 '24 04:05 sanderlv

@Necroneco

as current repo is not active more than 6 months. I have forked it and consider to maintain it in futuer. https://github.com/wuwentao/midea_ac_lan

PR is welcome

in addition, if you need PR merge permission, I will add more contributors later, it will not limit the repo admin permission in one person.

Thanks

wuwentao avatar May 21 '24 09:05 wuwentao