casambi-bt-revamped 0.3.6.dev7__py3-none-any.whl → 0.3.6.dev9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CasambiBt/_client.py +29 -26
- {casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/METADATA +1 -1
- {casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/RECORD +6 -6
- {casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/WHEEL +0 -0
- {casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/licenses/LICENSE +0 -0
- {casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/top_level.txt +0 -0
CasambiBt/_client.py
CHANGED
|
@@ -505,7 +505,7 @@ class CasambiClient:
|
|
|
505
505
|
|
|
506
506
|
def _parseSwitchEvent(self, data: bytes, packet_seq: int = None, raw_packet: bytes = None, android_switch_event: dict = None) -> None:
|
|
507
507
|
"""Parse switch event packet which contains multiple message types"""
|
|
508
|
-
self._logger.info(f"Parsing incoming switch event packet... Data: {b2a(data)}")
|
|
508
|
+
self._logger.info(f"Parsing incoming switch event packet #{packet_seq}... Data: {b2a(data)}")
|
|
509
509
|
|
|
510
510
|
# Special handling for message type 0x29 - not a switch event
|
|
511
511
|
if len(data) >= 1 and data[0] == 0x29:
|
|
@@ -585,27 +585,21 @@ class CasambiClient:
|
|
|
585
585
|
self._logger.error("Switch message has empty payload")
|
|
586
586
|
return
|
|
587
587
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
588
|
+
# For type 0x10 messages, the structure might be different
|
|
589
|
+
if message_type == 0x10 and len(payload) >= 3 and payload[2] == 0x1f:
|
|
590
|
+
# Special case: unit_id might be in payload[2] for some type 0x10 messages
|
|
591
|
+
unit_id = payload[2]
|
|
592
592
|
action = payload[1]
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
# If unit_id_echo doesn't match, this might be an internal protocol message
|
|
604
|
-
# Log it for debugging but don't process as a regular switch event
|
|
605
|
-
self._logger.debug(
|
|
606
|
-
f"Ignoring internal protocol message: unit_id={unit_id}, unit_id_echo={unit_id_echo}"
|
|
607
|
-
)
|
|
608
|
-
return # Don't process this as a switch event
|
|
593
|
+
extra_data = payload[3:] if len(payload) > 3 else b''
|
|
594
|
+
else:
|
|
595
|
+
# Standard parsing
|
|
596
|
+
unit_id = payload[0]
|
|
597
|
+
action = None
|
|
598
|
+
if len(payload) > 1:
|
|
599
|
+
action = payload[1]
|
|
600
|
+
extra_data = b''
|
|
601
|
+
if len(payload) > 2:
|
|
602
|
+
extra_data = payload[2:]
|
|
609
603
|
|
|
610
604
|
event_string = "unknown"
|
|
611
605
|
|
|
@@ -632,7 +626,18 @@ class CasambiClient:
|
|
|
632
626
|
else:
|
|
633
627
|
self._logger.warning(f"Unknown state byte: 0x{state_byte:02x}")
|
|
634
628
|
else:
|
|
635
|
-
|
|
629
|
+
# For some units, type 0x10 messages don't have the state byte
|
|
630
|
+
# In these cases, check if we have extra_data that might contain state info
|
|
631
|
+
if len(extra_data) >= 2:
|
|
632
|
+
# Pattern observed: extra_data[0] might contain state info
|
|
633
|
+
# 0x12 seems to correlate with button release states
|
|
634
|
+
if extra_data[0] == 0x12:
|
|
635
|
+
event_string = "button_release"
|
|
636
|
+
else:
|
|
637
|
+
event_string = "button_press"
|
|
638
|
+
self._logger.debug(f"Type 0x10: Using extra_data for state detection: {b2a(extra_data)}")
|
|
639
|
+
else:
|
|
640
|
+
self._logger.warning(f"Type 0x10 message missing state info, payload: {b2a(payload)}")
|
|
636
641
|
|
|
637
642
|
action_display = f"{action:#04x}" if action is not None else "N/A"
|
|
638
643
|
|
|
@@ -660,10 +665,8 @@ class CasambiClient:
|
|
|
660
665
|
|
|
661
666
|
# Extract controlling unit if present
|
|
662
667
|
controlling_unit = None
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if unit_id_echo != unit_id:
|
|
666
|
-
controlling_unit = unit_id_echo
|
|
668
|
+
# This is redundant since we already return early if unit_id_echo != unit_id
|
|
669
|
+
# Removing to avoid confusion
|
|
667
670
|
|
|
668
671
|
self._dataCallback(
|
|
669
672
|
IncommingPacketType.SwitchEvent,
|
{casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/RECORD
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
CasambiBt/__init__.py,sha256=TW445xSu5PV3TyMjJfwaA1JoWvQQ8LXhZgGdDTfWf3s,302
|
|
2
2
|
CasambiBt/_cache.py,sha256=KZ2xbiHAHXUPa8Gw_75Nw9NL4QSY_sTWHbyYXYUDaB0,3865
|
|
3
3
|
CasambiBt/_casambi.py,sha256=gLLkhEcObgapqTx5Mk7WRClyG29UyfZYZCCIhhOg4H4,23101
|
|
4
|
-
CasambiBt/_client.py,sha256=
|
|
4
|
+
CasambiBt/_client.py,sha256=NvOSoWeuh6FN0jKJvIaesE6e9MLGj8-DTndRU-XEj9I,28670
|
|
5
5
|
CasambiBt/_client_android_parser.py,sha256=1lVkVYMO0Nhh9_nkNwgb68hlCS_uD8WxYQDir5hOdHs,7744
|
|
6
6
|
CasambiBt/_constants.py,sha256=_AxkG7Btxl4VeS6mO7GJW5Kc9dFs3s9sDmtJ83ZEKNw,359
|
|
7
7
|
CasambiBt/_discover.py,sha256=H7HpiFYIy9ELvmPXXd_ck-5O5invJf15dDIRk-vO5IE,1696
|
|
@@ -12,8 +12,8 @@ CasambiBt/_operation.py,sha256=-BuC1Bvtg-G-zSN_b_0JMvXdHZaR6LbTw0S425jg96c,842
|
|
|
12
12
|
CasambiBt/_unit.py,sha256=YiQWoHmMDWHHo4XAjtW8rHsBqIqpmp9MVdv1Mbu2xw4,17043
|
|
13
13
|
CasambiBt/errors.py,sha256=0JgDjaKlAKDes0poWzA8nrTUYQ8qdNfBb8dfaqqzCRA,1664
|
|
14
14
|
CasambiBt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
casambi_bt_revamped-0.3.6.
|
|
16
|
-
casambi_bt_revamped-0.3.6.
|
|
17
|
-
casambi_bt_revamped-0.3.6.
|
|
18
|
-
casambi_bt_revamped-0.3.6.
|
|
19
|
-
casambi_bt_revamped-0.3.6.
|
|
15
|
+
casambi_bt_revamped-0.3.6.dev9.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
|
|
16
|
+
casambi_bt_revamped-0.3.6.dev9.dist-info/METADATA,sha256=rZUP2olCMHGkfWt-lnjJDSWZ2DU0c4sMB8LbPHrpitY,3049
|
|
17
|
+
casambi_bt_revamped-0.3.6.dev9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
casambi_bt_revamped-0.3.6.dev9.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
|
|
19
|
+
casambi_bt_revamped-0.3.6.dev9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{casambi_bt_revamped-0.3.6.dev7.dist-info → casambi_bt_revamped-0.3.6.dev9.dist-info}/top_level.txt
RENAMED
|
File without changes
|