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

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Necroneco
Copy link

@Necroneco Necroneco commented Jan 4, 2024

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)

@ChristophCaina
Copy link

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)

@Necroneco
Copy link
Author

Necroneco commented Jan 4, 2024

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

@chemelli74
Copy link

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.

@Necroneco Necroneco changed the title Replaced deprecated constants (HA >= 2023.1) Replaced deprecated constants and wildcard imports (HA >= 2023.1) Jan 7, 2024
from homeassistant.components.climate import *
from homeassistant.components.climate.const import *
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import should be done always from root.
I suggest to run mypy/pylint o fix all those minor but important warnings

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fixed this.

@chemelli74
Copy link

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 ?

@Necroneco
Copy link
Author

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?

@chemelli74
Copy link

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

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.

@Necroneco
Copy link
Author

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.

@chemelli74
Copy link

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

Copy link

@chemelli74 chemelli74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @Necroneco, PR works fine

@m4rkireland
Copy link

Any movement on this one?

@erikgieseler
Copy link

erikgieseler commented Mar 16, 2024

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 #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.

@Necroneco
Copy link
Author

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

@erikgieseler
Copy link

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

`

@Necroneco
Copy link
Author

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.

@erikgieseler
Copy link

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!

# Conflicts:
#	custom_components/midea_ac_lan/climate.py
@javifly
Copy link

javifly commented Apr 8, 2024

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

@sanderlv
Copy link

sanderlv commented May 2, 2024

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

@Necroneco
Copy link
Author

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

@sanderlv
Copy link

sanderlv commented May 3, 2024

Then it's not fixed...

@wuwentao
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment