casambi-bt-revamped 0.3.6.dev8__py3-none-any.whl → 0.3.6.dev10__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 +34 -24
- {casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/METADATA +1 -1
- {casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/RECORD +6 -6
- {casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/WHEEL +0 -0
- {casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/licenses/LICENSE +0 -0
- {casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/top_level.txt +0 -0
CasambiBt/_client.py
CHANGED
|
@@ -551,7 +551,10 @@ class CasambiClient:
|
|
|
551
551
|
# Process based on message type
|
|
552
552
|
if message_type == 0x08 or message_type == 0x10: # Switch/button events
|
|
553
553
|
switch_events_found += 1
|
|
554
|
-
|
|
554
|
+
# For type 0x10 messages, include the full data from start position to current position
|
|
555
|
+
# This ensures we capture any additional bytes after the declared payload
|
|
556
|
+
full_message_data = data[oldPos:pos] if message_type == 0x10 else data
|
|
557
|
+
self._processSwitchMessage(message_type, flags, parameter, payload, full_message_data, oldPos, packet_seq, raw_packet, android_switch_event)
|
|
555
558
|
elif message_type == 0x29:
|
|
556
559
|
# This shouldn't happen due to check above, but just in case
|
|
557
560
|
self._logger.debug(f"Ignoring embedded type 0x29 message")
|
|
@@ -585,15 +588,21 @@ class CasambiClient:
|
|
|
585
588
|
self._logger.error("Switch message has empty payload")
|
|
586
589
|
return
|
|
587
590
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
591
|
+
# For type 0x10 messages, the structure is different
|
|
592
|
+
if message_type == 0x10 and len(payload) >= 3:
|
|
593
|
+
# Type 0x10: unit_id is at payload[2]
|
|
594
|
+
unit_id = payload[2]
|
|
592
595
|
action = payload[1]
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
596
|
+
extra_data = payload[3:] if len(payload) > 3 else b''
|
|
597
|
+
else:
|
|
598
|
+
# Standard parsing for other message types
|
|
599
|
+
unit_id = payload[0]
|
|
600
|
+
action = None
|
|
601
|
+
if len(payload) > 1:
|
|
602
|
+
action = payload[1]
|
|
603
|
+
extra_data = b''
|
|
604
|
+
if len(payload) > 2:
|
|
605
|
+
extra_data = payload[2:]
|
|
597
606
|
|
|
598
607
|
event_string = "unknown"
|
|
599
608
|
|
|
@@ -604,11 +613,11 @@ class CasambiClient:
|
|
|
604
613
|
is_release = (action >> 1) & 1
|
|
605
614
|
event_string = "button_release" if is_release else "button_press"
|
|
606
615
|
elif message_type == 0x10:
|
|
607
|
-
# Type 0x10:
|
|
608
|
-
#
|
|
609
|
-
|
|
610
|
-
if
|
|
611
|
-
state_byte = full_data[
|
|
616
|
+
# Type 0x10: The state byte is at position 9 (0-indexed) from message start
|
|
617
|
+
# This applies to all units, not just unit 31
|
|
618
|
+
state_pos = 9
|
|
619
|
+
if len(full_data) > state_pos:
|
|
620
|
+
state_byte = full_data[state_pos]
|
|
612
621
|
if state_byte == 0x01:
|
|
613
622
|
event_string = "button_press"
|
|
614
623
|
elif state_byte == 0x02:
|
|
@@ -618,20 +627,21 @@ class CasambiClient:
|
|
|
618
627
|
elif state_byte == 0x0c:
|
|
619
628
|
event_string = "button_release_after_hold"
|
|
620
629
|
else:
|
|
621
|
-
self._logger.
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
# In these cases, check if we have extra_data that might contain state info
|
|
625
|
-
if len(extra_data) >= 3:
|
|
626
|
-
# Pattern observed: extra_data[1] might contain state info
|
|
627
|
-
# 0x12 seems to correlate with button release states
|
|
628
|
-
if extra_data[1] == 0x12:
|
|
630
|
+
self._logger.debug(f"Type 0x10: State byte 0x{state_byte:02x} at pos {state_pos}")
|
|
631
|
+
# Fallback: check if extra_data starts with 0x12 (indicates release)
|
|
632
|
+
if len(extra_data) >= 1 and extra_data[0] == 0x12:
|
|
629
633
|
event_string = "button_release"
|
|
630
634
|
else:
|
|
631
635
|
event_string = "button_press"
|
|
632
|
-
|
|
636
|
+
else:
|
|
637
|
+
# Fallback when message is too short
|
|
638
|
+
if len(extra_data) >= 1 and extra_data[0] == 0x12:
|
|
639
|
+
event_string = "button_release"
|
|
640
|
+
self._logger.debug(f"Type 0x10: Using extra_data pattern for release detection")
|
|
633
641
|
else:
|
|
634
|
-
|
|
642
|
+
# Cannot determine state
|
|
643
|
+
self._logger.warning(f"Type 0x10 message missing state info, unit_id={unit_id}, payload={b2a(payload)}")
|
|
644
|
+
event_string = "unknown"
|
|
635
645
|
|
|
636
646
|
action_display = f"{action:#04x}" if action is not None else "N/A"
|
|
637
647
|
|
{casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.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=BR-Lhv79ntkMTQuxC445BP9B_qaAQNdWE0vJ-fWbR0o,28892
|
|
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.dev10.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
|
|
16
|
+
casambi_bt_revamped-0.3.6.dev10.dist-info/METADATA,sha256=WcVq71w4pxbClRQx4jJ2k_z6CaMpMJxTf6nR1d9WUR8,3050
|
|
17
|
+
casambi_bt_revamped-0.3.6.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
casambi_bt_revamped-0.3.6.dev10.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
|
|
19
|
+
casambi_bt_revamped-0.3.6.dev10.dist-info/RECORD,,
|
{casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
{casambi_bt_revamped-0.3.6.dev8.dist-info → casambi_bt_revamped-0.3.6.dev10.dist-info}/top_level.txt
RENAMED
|
File without changes
|