casambi-bt-revamped 0.3.6.dev9__py3-none-any.whl → 0.3.6.dev11__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 -20
- {casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/METADATA +1 -1
- {casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/RECORD +6 -6
- {casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/WHEEL +0 -0
- {casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/licenses/LICENSE +0 -0
- {casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/top_level.txt +0 -0
CasambiBt/_client.py
CHANGED
|
@@ -551,7 +551,14 @@ 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, we need to pass additional data beyond the declared payload
|
|
555
|
+
if message_type == 0x10:
|
|
556
|
+
# Extend to include at least 10 bytes from message start for state byte
|
|
557
|
+
extended_end = min(oldPos + 11, len(data))
|
|
558
|
+
full_message_data = data[oldPos:extended_end]
|
|
559
|
+
else:
|
|
560
|
+
full_message_data = data
|
|
561
|
+
self._processSwitchMessage(message_type, flags, parameter, payload, full_message_data, oldPos, packet_seq, raw_packet, android_switch_event)
|
|
555
562
|
elif message_type == 0x29:
|
|
556
563
|
# This shouldn't happen due to check above, but just in case
|
|
557
564
|
self._logger.debug(f"Ignoring embedded type 0x29 message")
|
|
@@ -585,14 +592,14 @@ class CasambiClient:
|
|
|
585
592
|
self._logger.error("Switch message has empty payload")
|
|
586
593
|
return
|
|
587
594
|
|
|
588
|
-
# For type 0x10 messages, the structure
|
|
589
|
-
if message_type == 0x10 and len(payload) >= 3
|
|
590
|
-
#
|
|
595
|
+
# For type 0x10 messages, the structure is different
|
|
596
|
+
if message_type == 0x10 and len(payload) >= 3:
|
|
597
|
+
# Type 0x10: unit_id is at payload[2]
|
|
591
598
|
unit_id = payload[2]
|
|
592
599
|
action = payload[1]
|
|
593
600
|
extra_data = payload[3:] if len(payload) > 3 else b''
|
|
594
601
|
else:
|
|
595
|
-
# Standard parsing
|
|
602
|
+
# Standard parsing for other message types
|
|
596
603
|
unit_id = payload[0]
|
|
597
604
|
action = None
|
|
598
605
|
if len(payload) > 1:
|
|
@@ -610,11 +617,12 @@ class CasambiClient:
|
|
|
610
617
|
is_release = (action >> 1) & 1
|
|
611
618
|
event_string = "button_release" if is_release else "button_press"
|
|
612
619
|
elif message_type == 0x10:
|
|
613
|
-
# Type 0x10:
|
|
614
|
-
#
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
620
|
+
# Type 0x10: The state byte is at position 9 (0-indexed) from message start
|
|
621
|
+
# This applies to all units, not just unit 31
|
|
622
|
+
# full_data for type 0x10 is the message data starting from position 0
|
|
623
|
+
state_pos = 9
|
|
624
|
+
if len(full_data) > state_pos:
|
|
625
|
+
state_byte = full_data[state_pos]
|
|
618
626
|
if state_byte == 0x01:
|
|
619
627
|
event_string = "button_press"
|
|
620
628
|
elif state_byte == 0x02:
|
|
@@ -624,20 +632,21 @@ class CasambiClient:
|
|
|
624
632
|
elif state_byte == 0x0c:
|
|
625
633
|
event_string = "button_release_after_hold"
|
|
626
634
|
else:
|
|
627
|
-
self._logger.
|
|
628
|
-
|
|
629
|
-
|
|
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
|
+
self._logger.debug(f"Type 0x10: Unknown state byte 0x{state_byte:02x} at message pos {state_pos}")
|
|
636
|
+
# Fallback: check if extra_data starts with 0x12 (indicates release)
|
|
637
|
+
if len(extra_data) >= 1 and extra_data[0] == 0x12:
|
|
635
638
|
event_string = "button_release"
|
|
636
639
|
else:
|
|
637
640
|
event_string = "button_press"
|
|
638
|
-
|
|
641
|
+
else:
|
|
642
|
+
# Fallback when message is too short
|
|
643
|
+
if len(extra_data) >= 1 and extra_data[0] == 0x12:
|
|
644
|
+
event_string = "button_release"
|
|
645
|
+
self._logger.debug(f"Type 0x10: Using extra_data pattern for release detection")
|
|
639
646
|
else:
|
|
640
|
-
|
|
647
|
+
# Cannot determine state
|
|
648
|
+
self._logger.warning(f"Type 0x10 message missing state info, unit_id={unit_id}, payload={b2a(payload)}")
|
|
649
|
+
event_string = "unknown"
|
|
641
650
|
|
|
642
651
|
action_display = f"{action:#04x}" if action is not None else "N/A"
|
|
643
652
|
|
{casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.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=mC-U6CKr8prcm3C3t6g5trXjV5vf5nUaq4pK5YvQ6Ac,29157
|
|
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.dev11.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
|
|
16
|
+
casambi_bt_revamped-0.3.6.dev11.dist-info/METADATA,sha256=UOJXQeaYs4RsfJ_7FhCpwnnhLsHteuPa_GspiQccSv8,3050
|
|
17
|
+
casambi_bt_revamped-0.3.6.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
casambi_bt_revamped-0.3.6.dev11.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
|
|
19
|
+
casambi_bt_revamped-0.3.6.dev11.dist-info/RECORD,,
|
{casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
{casambi_bt_revamped-0.3.6.dev9.dist-info → casambi_bt_revamped-0.3.6.dev11.dist-info}/top_level.txt
RENAMED
|
File without changes
|