From fc5e83c850d349cc736e88b67b613d69a38e056c Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Wed, 5 Jun 2024 06:31:47 +0000 Subject: [PATCH 1/2] fix: body_type NONE_VALUE checks --- midealocal/devices/e6/message.py | 3 ++- midealocal/message.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/midealocal/devices/e6/message.py b/midealocal/devices/e6/message.py index 8a309b83..743c6e31 100644 --- a/midealocal/devices/e6/message.py +++ b/midealocal/devices/e6/message.py @@ -3,6 +3,7 @@ MessageRequest, MessageResponse, MessageType, + NONE_VALUE, ) @@ -12,7 +13,7 @@ def __init__(self, protocol_version, message_type): device_type=0xE6, protocol_version=protocol_version, message_type=message_type, - body_type=None, + body_type=NONE_VALUE, ) @property diff --git a/midealocal/message.py b/midealocal/message.py index 3e192777..4cc4023c 100644 --- a/midealocal/message.py +++ b/midealocal/message.py @@ -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 is not NONE_VALUE else "None" ), } return str(output) @@ -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 is not NONE_VALUE: body.append(self.body_type) if self._body is not None: body.extend(self._body) From a85ea493619067db3a8dfb897f515c76cd777c39 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Wed, 5 Jun 2024 08:29:19 +0000 Subject: [PATCH 2/2] chore: apply review comments --- midealocal/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/midealocal/message.py b/midealocal/message.py index 4cc4023c..601e331a 100644 --- a/midealocal/message.py +++ b/midealocal/message.py @@ -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_VALUE else "None" + ("%02x" % self._body_type) if self._body_type != NONE_VALUE else "None" ), } return str(output) @@ -144,7 +144,7 @@ def _body(self) -> bytearray: @property def body(self) -> bytearray: body = bytearray([]) - if self.body_type is not NONE_VALUE: + if self.body_type != NONE_VALUE: body.append(self.body_type) if self._body is not None: body.extend(self._body)