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

feat(ed): add new query01 msg for ed device #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

wuwentao
Copy link
Member

add new query01 msg for ed devices
fix wuwentao/midea_ac_lan#352

@wuwentao wuwentao requested a review from rokam October 16, 2024 09:07
@github-actions github-actions bot added the enhancement New feature or request label Oct 16, 2024
rokam
rokam previously requested changes Oct 16, 2024
Copy link
Contributor

@rokam rokam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to create another class and not to use the body_type parameter?
I prefer that you create the query message twice each one with a different body type.

@wuwentao
Copy link
Member Author

@rokam please check the source code from device.py with refresh_status steps.
it can't work anymore

@wuwentao wuwentao dismissed rokam’s stale review October 17, 2024 04:31

it can't works

Copy link
Contributor

@rokam rokam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it with suggestions to be clear. It will work.

return [MessageQuery(self._message_protocol_version, self._device_class)]
return [
MessageQuery(self._message_protocol_version),
MessageQuery01(self._message_protocol_version),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MessageQuery01(self._message_protocol_version),
MessageQuery(self._message_protocol_version, ListTypes.X01),

"""Midea ED device build query."""
return [MessageQuery(self._message_protocol_version, self._device_class)]
return [
MessageQuery(self._message_protocol_version),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MessageQuery(self._message_protocol_version),
MessageQuery(self._message_protocol_version, ListTypes.X00),

assert isinstance(queries[0], MessageQuery)
assert isinstance(queries[1], MessageQuery01)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check body_type value here.

@@ -14,6 +14,7 @@
MessageEDResponse,
MessageNewSet,
MessageQuery,
MessageQuery01,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MessageQuery01,

@@ -77,6 +81,26 @@ def _body(self) -> bytearray:
return bytearray([0x01])


class MessageQuery01(MessageEDBase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class isn't needed

Copy link
Contributor

@rokam rokam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, self._device_class = ListTypes.X00 isn't needed anymore.

@@ -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]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def build_query(self) -> list[MessageQuery | MessageQuery01]:
def build_query(self) -> list[MessageQuery]:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if device NOT support MessageQuery and ONLY support MessageQuery01, we only use MessageQuery with the same name, when device send MessageQuery with body 00, it will add MessageQuery to self._unsupported_protocol, so MessageQuery with body 01 will be ignored and can't work anymore.
this is the reason why we need to add it with a different class name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature(ED): 厨下式净水器所有传感器都显示 未知
2 participants