Skip to content

Commit

Permalink
Merge pull request #6 from lunDreame/fix-elevator
Browse files Browse the repository at this point in the history
Fix elevator
  • Loading branch information
lunDreame authored Jan 3, 2025
2 parents df3deca + 35df60f commit 22244bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/kocom_wallpad/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
BRAND_NAME = "Kocom"
MANUFACTURER = "KOCOM Co., Ltd"
MODEL = "Smart Wallpad"
SW_VERSION = "1.0.4"
SW_VERSION = "1.0.5"

DEVICE_TYPE = "device_type"
ROOM_ID = "room_id"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/kocom_wallpad/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/lunDreame/kocom-wallpad/issues",
"requirements": [],
"version": "1.0.4"
"version": "1.0.5"
}
15 changes: 10 additions & 5 deletions custom_components/kocom_wallpad/pywallpad/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def parse_data(self) -> list[Device]:
)
)

if floor_state > 0 or self._last_data[self.device_id][FLOOR]:
if (isinstance(floor_state, int) and (floor_state > 0)) or self._last_data[self.device_id][FLOOR]:
_LOGGER.debug(f"Support EV floor: {floor_state}")
self._last_data[self.device_id][FLOOR] = True

Expand Down Expand Up @@ -672,10 +672,8 @@ class PacketParser:

@staticmethod
def parse(packet_data: bytes) -> KocomPacket:
"""Parse a raw packet into a specific packet class."""
"""Parse a raw packet into a specific packet class."""
device_type = packet_data[7]
if packet_data[5] == 0x44 and device_type == 0x01:
device_type = 0x44
return PacketParser._get_packet_instance(device_type, packet_data)

@staticmethod
Expand Down Expand Up @@ -720,7 +718,14 @@ def _get_packet_instance(device_type: int, packet_data: bytes) -> KocomPacket:

packet_class = device_class_map.get(device_type)
if packet_class is None:
_LOGGER.error("Unknown device type: %s, data: %s", format(device_type, 'x'), packet_data.hex())
_LOGGER.error(f"Unknown device type: {hex(device_type)}, data: {packet_data.hex()}")
return KocomPacket(packet_data)

if packet_data[5] == DeviceType.EV.value and packet_class == KocomPacket:
packet_data = bytearray(packet_data)
packet_data[5] = 0x01
packet_data[7] = 0x44
_LOGGER.debug(f"EV device detected from wallpad: {packet_data.hex()}")
return EVPacket(bytes(packet_data))

return packet_class(packet_data)

0 comments on commit 22244bb

Please sign in to comment.