Skip to content

Commit

Permalink
Add aux heat bits to SetState and StateResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
mill1000 committed Jan 27, 2025
1 parent 294e74b commit 66c0026
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions msmart/device/AC/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ def __init__(self) -> None:
self.follow_me = False
self.purifier = False
self.target_humidity = 40
self.aux_heat = False
self.independent_aux_heat = False

def tobytes(self) -> bytes: # pyright: ignore[reportIncompatibleMethodOverride] # nopep8
# Build beep and power status bytes
Expand Down Expand Up @@ -288,6 +290,7 @@ def tobytes(self) -> bytes: # pyright: ignore[reportIncompatibleMethodOverride]
# Build eco mode and purifier byte
eco = 0x80 if self.eco else 0
purifier = 0x20 if self.purifier else 0
aux_heat = 0x08 if self.aux_heat else 0

# Build sleep, turbo and fahrenheit byte
sleep = 0x01 if self.sleep else 0
Expand All @@ -304,6 +307,9 @@ def tobytes(self) -> bytes: # pyright: ignore[reportIncompatibleMethodOverride]
# Build freeze protection byte
freeze_protect = 0x80 if self.freeze_protection else 0

# Build independent aux heat
independent_aux_heat = 0x08

return super().tobytes(bytes([
# Set state
0x40,
Expand All @@ -319,8 +325,8 @@ def tobytes(self) -> bytes: # pyright: ignore[reportIncompatibleMethodOverride]
swing_mode,
# Follow me and alternate turbo mode
follow_me | turbo_alt,
# ECO mode and purifier/anion
eco | purifier,
# ECO mode, purifier/anion, and aux heat
eco | purifier | aux_heat,
# Sleep mode, turbo mode and fahrenheit
sleep | turbo | fahrenheit,
# Unknown
Expand All @@ -334,8 +340,10 @@ def tobytes(self) -> bytes: # pyright: ignore[reportIncompatibleMethodOverride]
0x00,
# Frost/freeze protection
freeze_protect,
# Independent aux heat
independent_aux_heat,
# Unknown
0x00, 0x00,
0x00,
]))


Expand Down Expand Up @@ -828,6 +836,8 @@ def __init__(self, payload: memoryview) -> None:
self.follow_me = None
self.purifier = None
self.target_humidity = None
self.aux_heat = None
self.independent_aux_heat = None

_LOGGER.debug("State response payload: %s", payload.hex())

Expand Down Expand Up @@ -873,14 +883,15 @@ def _parse(self, payload: memoryview) -> None:
# self.save = (payload[8] & 0x08) > 0
# self.low_frequency_fan = (payload[8] & 0x10) > 0
self.turbo = bool(payload[8] & 0x20)
self.independent_aux_heat = bool(payload[8] & 0x40)
self.follow_me = bool(payload[8] & 0x80)

self.eco = bool(payload[9] & 0x10)
self.purifier = bool(payload[9] & 0x20)
# self.child_sleep = (payload[9] & 0x01) > 0
# self.exchange_air = (payload[9] & 0x02) > 0
# self.dry_clean = (payload[9] & 0x04) > 0
# self.aux_heat = (payload[9] & 0x08) > 0
self.aux_heat = bool(payload[9] & 0x08)
# self.temp_unit = (payload[9] & 0x80) > 0

self.sleep = bool(payload[10] & 0x1)
Expand Down

0 comments on commit 66c0026

Please sign in to comment.