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

Updated deprecated properties #224

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions custom_components/midea_ac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ def __init__(self,
]

# Only add presets supported by device
if self._device.supports_freeze_protection_mode:
if self._device.supports_freeze_protection:
self._preset_modes.append(PRESET_AWAY)

if self._device.supports_eco_mode:
if self._device.supports_eco:
self._preset_modes.append(PRESET_ECO)

if self._device.supports_turbo_mode:
if self._device.supports_turbo:
self._preset_modes.append(PRESET_BOOST)

if self._device.supports_ieco:
Expand Down Expand Up @@ -423,38 +423,38 @@ def preset_modes(self) -> list[str]:
@property
def preset_mode(self) -> str:
"""Get the current preset mode."""
if self._device.eco_mode:
if self._device.eco:
return PRESET_ECO
elif self._device.ieco:
return PRESET_IECO
elif self._device.turbo_mode:
elif self._device.turbo:
return PRESET_BOOST
elif self._device.freeze_protection_mode:
elif self._device.freeze_protection:
return PRESET_AWAY
elif self._device.sleep_mode:
elif self._device.sleep:
return PRESET_SLEEP
else:
return PRESET_NONE

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set the preset mode."""
self._device.eco_mode = False
self._device.eco = False
self._device.ieco = False
self._device.turbo_mode = False
self._device.freeze_protection_mode = False
self._device.sleep_mode = False
self._device.turbo = False
self._device.freeze_protection = False
self._device.sleep = False

# Enable proper mode
if preset_mode == PRESET_BOOST:
self._device.turbo_mode = True
self._device.turbo = True
elif preset_mode == PRESET_ECO:
self._device.eco_mode = True
self._device.eco = True
elif preset_mode == PRESET_IECO:
self._device.ieco = True
elif preset_mode == PRESET_AWAY:
self._device.freeze_protection_mode = True
self._device.freeze_protection = True
elif preset_mode == PRESET_SLEEP:
self._device.sleep_mode = True
self._device.sleep = True

await self._apply()

Expand Down