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: Add MideaACFreshAirFan feature turn_on and turn_off #285

Merged
merged 10 commits into from
Aug 23, 2024
Merged

fix: Add MideaACFreshAirFan feature turn_on and turn_off #285

merged 10 commits into from
Aug 23, 2024

Conversation

elcajon
Copy link
Contributor

@elcajon elcajon commented Aug 16, 2024

PR Description

SSIA

https://developers.home-assistant.io/blog/2024/07/19/fan-fanentityfeatures-turn-on_off/

Reason & Detail

from the current HA (2024.8.2) logs

2024-08-16 20:31:49.478 WARNING (MainThread) [homeassistant.components.fan] Entity midea_ac_lan.153931628304529_fresh_air (<class 'custom_components.midea_ac_lan.fan.MideaACFreshAirFan'>) does not set FanEntityFeature.TURN_OFF but implements the turn_off method. Please create a bug report at https://github.com/wuwentao/midea_ac_lan/issues
2024-08-16 20:31:49.478 WARNING (MainThread) [homeassistant.components.fan] Entity midea_ac_lan.153931628304529_fresh_air (<class 'custom_components.midea_ac_lan.fan.MideaACFreshAirFan'>) does not set FanEntityFeature.TURN_ON but implements the turn_on method. Please create a bug report at https://github.com/wuwentao/midea_ac_lan/issues

Related issue

none

@elcajon elcajon changed the title Add MideaACFreshAirFan feature turn_on and turn_off fix: Add MideaACFreshAirFan feature turn_on and turn_off Aug 16, 2024
@wuwentao
Copy link
Owner

@elcajon
thank you very much for you PR.
we need more contributors for current project, welcome to join us.

for current PR lint checking, we still keep both python 3.11 for old HA version:
https://github.com/wuwentao/midea_ac_lan/blob/master/requirements-all-3.11.txt
https://github.com/wuwentao/midea_ac_lan/blob/master/requirements-all-3.12.txt

as user may not upgrade to the latest verion and continue using old HA version.
they may have more integration and not only for midea_ac_lan, so we can do HA version check in our codes.

@elcajon
Copy link
Contributor Author

elcajon commented Aug 19, 2024

Sure, always willing to help in my spare time :)

@wuwentao
Copy link
Owner

wuwentao commented Aug 20, 2024

it can't works in HA 2024.3.3(with python 3.11)

************* Module midea_ac_lan.fan
custom_components/midea_ac_lan/fan.py:67:5: E1101: Class 'FanEntityFeature' has no 'TURN_ON' member (no-member)
custom_components/midea_ac_lan/fan.py:67:32: E1101: Class 'FanEntityFeature' has no 'TURN_OFF' member (no-member)

it will read FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF with HA 2024.3.3 and return error as PR lint error msg

FAN_FEATURE_TURN_ON_OFF: FanEntityFeature = (
    (FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF)
    if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 8)
    else FanEntityFeature(0)
)

maybe we can refer to this changes:

if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 2):

@caibinqing
Copy link
Collaborator

it can't works in HA 2024.3.3(with python 3.11)

************* Module midea_ac_lan.fan
custom_components/midea_ac_lan/fan.py:67:5: E1101: Class 'FanEntityFeature' has no 'TURN_ON' member (no-member)
custom_components/midea_ac_lan/fan.py:67:32: E1101: Class 'FanEntityFeature' has no 'TURN_OFF' member (no-member)

it will read FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF with HA 2024.3.3 and return error as PR lint error msg

FAN_FEATURE_TURN_ON_OFF: FanEntityFeature = (
    (FanEntityFeature.TURN_ON | FanEntityFeature.TURN_OFF)
    if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 8)
    else FanEntityFeature(0)
)

maybe we can refer to this changes:

if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 2):

Already added version check (line 3), it actually doesn't have any problems, but mypy doesn't know.

Maybe could use hasattr(FanEntityFeature, "TURN_ON") to pass mypy.

@wuwentao wuwentao merged commit 2d466d5 into wuwentao:master Aug 23, 2024
10 checks passed
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.

3 participants