casambi-bt-revamped 0.3.6.dev13__py3-none-any.whl → 0.3.6.dev15__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 CHANGED
@@ -551,8 +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
- # Extract button ID from parameter field (consistent for all message types)
555
- button = parameter
554
+ # Extract button ID using Android-inspired approach
555
+ # Android principle: button should be consistent for same physical button
556
+ if len(payload) > 4:
557
+ # Use payload[4] which is consistent across message types (0 for both)
558
+ button = payload[4]
559
+ else:
560
+ # Fallback to parameter for short payloads
561
+ button = parameter
556
562
 
557
563
  # For type 0x10 messages, we need to pass additional data beyond the declared payload
558
564
  if message_type == 0x10:
@@ -595,21 +601,30 @@ class CasambiClient:
595
601
  self._logger.error("Switch message has empty payload")
596
602
  return
597
603
 
598
- # For type 0x10 messages, the structure is different
604
+ # Extract unit_id based on message type
599
605
  if message_type == 0x10 and len(payload) >= 3:
600
606
  # Type 0x10: unit_id is at payload[2]
601
607
  unit_id = payload[2]
602
- action = payload[1]
603
608
  extra_data = payload[3:] if len(payload) > 3 else b''
604
609
  else:
605
610
  # Standard parsing for other message types
606
611
  unit_id = payload[0]
607
- action = None
608
- if len(payload) > 1:
609
- action = payload[1]
610
612
  extra_data = b''
611
613
  if len(payload) > 2:
612
614
  extra_data = payload[2:]
615
+
616
+ # Extract action using Android-inspired approach for consistency
617
+ if len(payload) > 4:
618
+ # Use payload[4] which is consistent across message types (0 for both)
619
+ action = payload[4]
620
+ else:
621
+ # Fallback to traditional extraction for short payloads
622
+ if message_type == 0x10 and len(payload) > 1:
623
+ action = payload[1]
624
+ elif len(payload) > 1:
625
+ action = payload[1]
626
+ else:
627
+ action = None
613
628
 
614
629
  event_string = "unknown"
615
630
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: casambi-bt-revamped
3
- Version: 0.3.6.dev13
3
+ Version: 0.3.6.dev15
4
4
  Summary: Enhanced Casambi Bluetooth client library with switch event support
5
5
  Home-page: https://github.com/rankjie/casambi-bt
6
6
  Author: rankjie
@@ -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=JvufY9Pr26tN3OSH7tnuANx5lK3b1XrvqkalcHSuCfw,29310
4
+ CasambiBt/_client.py,sha256=qzlGobl2ktwkQTeZUOM0Wx8-DGq5YU74p7vPbWN3Nik,30038
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.dev13.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
- casambi_bt_revamped-0.3.6.dev13.dist-info/METADATA,sha256=CiAMqS3VojyMxBx-wGHULFxKoMc6_cgfODJ3vosZXdM,3050
17
- casambi_bt_revamped-0.3.6.dev13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- casambi_bt_revamped-0.3.6.dev13.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
- casambi_bt_revamped-0.3.6.dev13.dist-info/RECORD,,
15
+ casambi_bt_revamped-0.3.6.dev15.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
+ casambi_bt_revamped-0.3.6.dev15.dist-info/METADATA,sha256=N5XlFjqP2Du298VQqPFBagFKzhatuz1loohA0dYLHQg,3050
17
+ casambi_bt_revamped-0.3.6.dev15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ casambi_bt_revamped-0.3.6.dev15.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
+ casambi_bt_revamped-0.3.6.dev15.dist-info/RECORD,,