Skip to content

Commit

Permalink
fix: body_type NONE_VALUE checks (#84)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved handling of `body_type` parameter to prevent errors by using
`NONE_VALUE` instead of `None` in message processing.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
chemelli74 authored Jun 5, 2024
1 parent 878f0a3 commit b0337ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion midealocal/devices/e6/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
MessageRequest,
MessageResponse,
MessageType,
NONE_VALUE,
)


Expand All @@ -12,7 +13,7 @@ def __init__(self, protocol_version: int, message_type: int) -> None:
device_type=0xE6,
protocol_version=protocol_version,
message_type=message_type,
body_type=None,
body_type=NONE_VALUE,
)

@property
Expand Down
4 changes: 2 additions & 2 deletions midealocal/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __str__(self) -> str:
"body": self.body.hex(),
"message type": "%02x" % self._message_type,
"body type": (
("%02x" % self._body_type) if self._body_type is not None else "None"
("%02x" % self._body_type) if self._body_type != NONE_VALUE else "None"
),
}
return str(output)
Expand Down Expand Up @@ -144,7 +144,7 @@ def _body(self) -> bytearray:
@property
def body(self) -> bytearray:
body = bytearray([])
if self.body_type is not None:
if self.body_type != NONE_VALUE:
body.append(self.body_type)
if self._body is not None:
body.extend(self._body)
Expand Down

0 comments on commit b0337ba

Please sign in to comment.