Skip to content

Commit

Permalink
feat(ed): add new query01 msg for ed device
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed Oct 16, 2024
1 parent ea90491 commit 2b88e7a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
15 changes: 12 additions & 3 deletions midealocal/devices/ed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
from midealocal.device import MideaDevice
from midealocal.message import ListTypes

from .message import MessageEDResponse, MessageNewSet, MessageOldSet, MessageQuery
from .message import (
MessageEDResponse,
MessageNewSet,
MessageOldSet,
MessageQuery,
MessageQuery01,
)

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -77,9 +83,12 @@ def _use_new_set(self) -> bool:
# if (self.sub_type > 342 or self.sub_type == 340) else False
return True

def build_query(self) -> list[MessageQuery]:
def build_query(self) -> list[MessageQuery | MessageQuery01]:
"""Midea ED device build query."""
return [MessageQuery(self._message_protocol_version, self._device_class)]
return [
MessageQuery(self._message_protocol_version),
MessageQuery01(self._message_protocol_version),
]

def process_message(self, msg: bytes) -> dict[str, Any]:
"""Midea ED device process message."""
Expand Down
26 changes: 25 additions & 1 deletion midealocal/devices/ed/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def _body(self) -> bytearray:
class MessageQuery(MessageEDBase):
"""ED message query."""

def __init__(self, protocol_version: int, body_type: ListTypes) -> None:
def __init__(
self,
protocol_version: int,
body_type: ListTypes = ListTypes.X00,
) -> None:
"""Initialize ED message query."""
super().__init__(
protocol_version=protocol_version,
Expand All @@ -77,6 +81,26 @@ def _body(self) -> bytearray:
return bytearray([0x01])


class MessageQuery01(MessageEDBase):
"""ED message query01."""

def __init__(
self,
protocol_version: int,
body_type: ListTypes = ListTypes.X01,
) -> None:
"""Initialize ED message query01."""
super().__init__(
protocol_version=protocol_version,
message_type=MessageType.query,
body_type=body_type,
)

@property
def _body(self) -> bytearray:
return bytearray([0x01])


class MessageNewSet(MessageEDBase):
"""ED message new set."""

Expand Down

0 comments on commit 2b88e7a

Please sign in to comment.