Skip to content

Commit

Permalink
feat(ed): add all query msg for ed device
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwentao committed Dec 23, 2024
1 parent 725fb6b commit 511b5f5
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 1 deletion.
25 changes: 24 additions & 1 deletion midealocal/devices/ed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
MessageOldSet,
MessageQuery,
MessageQuery01,
MessageQuery03,
MessageQuery04,
MessageQuery05,
MessageQuery06,
MessageQuery07,
MessageQueryFF,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -83,11 +89,28 @@ 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 | MessageQuery01]:
def build_query(
self,
) -> list[
MessageQuery
| MessageQuery01
| MessageQuery03
| MessageQuery04
| MessageQuery05
| MessageQuery06
| MessageQuery07
| MessageQueryFF
]:
"""Midea ED device build query."""
return [
MessageQuery(self._message_protocol_version),
MessageQuery01(self._message_protocol_version),
MessageQuery03(self._message_protocol_version),
MessageQuery04(self._message_protocol_version),
MessageQuery05(self._message_protocol_version),
MessageQuery06(self._message_protocol_version),
MessageQuery07(self._message_protocol_version),
MessageQueryFF(self._message_protocol_version),
]

def process_message(self, msg: bytes) -> dict[str, Any]:
Expand Down
120 changes: 120 additions & 0 deletions midealocal/devices/ed/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,126 @@ def _body(self) -> bytearray:
return bytearray([0x01])


class MessageQuery03(MessageEDBase):
"""ED message query03."""

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

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


class MessageQuery04(MessageEDBase):
"""ED message query04."""

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

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


class MessageQuery05(MessageEDBase):
"""ED message query05."""

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

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


class MessageQuery06(MessageEDBase):
"""ED message query06."""

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

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


class MessageQuery07(MessageEDBase):
"""ED message query07."""

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

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


class MessageQueryFF(MessageEDBase):
"""ED message queryFF."""

def __init__(
self,
protocol_version: int,
body_type: ListTypes = ListTypes.FF,
) -> None:
"""Initialize ED message queryFF."""
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 511b5f5

Please sign in to comment.