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(ac): correct attributes based on msg type #251

Merged
merged 1 commit into from
Jul 29, 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
22 changes: 15 additions & 7 deletions midealocal/devices/ac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None:
"""Midea AC device set attribute."""
# if nat a sensor
message: (
MessageToggleDisplay | MessageNewProtocolSet | MessageGeneralSet | None
MessageToggleDisplay
| MessageNewProtocolSet
| MessageSubProtocolSet
| MessageGeneralSet
| None
) = None
if attr not in [
DeviceAttributes.indoor_temperature,
Expand Down Expand Up @@ -355,7 +359,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None:
)
setattr(message, str(self._fresh_air_version), fresh_air)
elif attr in self._attributes:
message = self.make_message_set()
message = self.make_message_uniq_set()
if attr in [
DeviceAttributes.boost_mode,
DeviceAttributes.sleep_mode,
Expand All @@ -365,9 +369,10 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None:
]:
message.boost_mode = False
message.sleep_mode = False
message.comfort_mode = False
message.eco_mode = False
message.frost_protect = False
if not isinstance(message, MessageSubProtocolSet):
message.comfort_mode = False
message.frost_protect = False
setattr(message, str(attr), value)
if attr == DeviceAttributes.mode:
setattr(message, str(DeviceAttributes.power.value), True)
Expand All @@ -392,9 +397,12 @@ def set_target_temperature(

def set_swing(self, swing_vertical: bool, swing_horizontal: bool) -> None:
"""Midea AC device set swing."""
message: MessageGeneralSet = self.make_message_set()
message.swing_vertical = swing_vertical
message.swing_horizontal = swing_horizontal
message: MessageSubProtocolSet | MessageGeneralSet = (
self.make_message_uniq_set()
)
if isinstance(message, MessageGeneralSet):
message.swing_vertical = swing_vertical
message.swing_horizontal = swing_horizontal
self.build_send(message)

def set_customize(self, customize: str) -> None:
Expand Down
Loading