casambi-bt-revamped 0.3.6.dev6__py3-none-any.whl → 0.3.6.dev8__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
@@ -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:
@@ -594,17 +594,6 @@ class CasambiClient:
594
594
  extra_data = b''
595
595
  if len(payload) > 2:
596
596
  extra_data = payload[2:]
597
-
598
- # Validate extra data for type 0x10
599
- if message_type == 0x10 and len(extra_data) >= 3:
600
- # Expected pattern: [unit_id_echo][0x12 or similar][0x00]
601
- unit_id_echo = extra_data[0]
602
- if unit_id_echo != unit_id:
603
- # This might indicate a control relationship
604
- # e.g., unit_id_echo = controlling unit, unit_id = controlled unit
605
- self._logger.info(
606
- f"Control event: unit {unit_id} controlled by unit {unit_id_echo}"
607
- )
608
597
 
609
598
  event_string = "unknown"
610
599
 
@@ -631,7 +620,18 @@ class CasambiClient:
631
620
  else:
632
621
  self._logger.warning(f"Unknown state byte: 0x{state_byte:02x}")
633
622
  else:
634
- self._logger.warning("Type 0x10 message missing state byte information")
623
+ # For some units, type 0x10 messages don't have the state byte
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:
629
+ event_string = "button_release"
630
+ else:
631
+ event_string = "button_press"
632
+ self._logger.debug(f"Type 0x10: Using extra_data for state detection: {b2a(extra_data)}")
633
+ else:
634
+ self._logger.warning("Type 0x10 message missing state byte information, cannot determine event type")
635
635
 
636
636
  action_display = f"{action:#04x}" if action is not None else "N/A"
637
637
 
@@ -659,10 +659,8 @@ class CasambiClient:
659
659
 
660
660
  # Extract controlling unit if present
661
661
  controlling_unit = None
662
- if message_type == 0x10 and len(extra_data) >= 1:
663
- unit_id_echo = extra_data[0]
664
- if unit_id_echo != unit_id:
665
- controlling_unit = unit_id_echo
662
+ # This is redundant since we already return early if unit_id_echo != unit_id
663
+ # Removing to avoid confusion
666
664
 
667
665
  self._dataCallback(
668
666
  IncommingPacketType.SwitchEvent,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: casambi-bt-revamped
3
- Version: 0.3.6.dev6
3
+ Version: 0.3.6.dev8
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=J0hK5raNn_RiOtVHxiXK27g6wIDdspcYpf2BSHVm06k,28180
4
+ CasambiBt/_client.py,sha256=6Lg9k_AF0i0axW5TAZKINmhtaKc8MBQ178be5ICOhKE,28251
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.dev6.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
- casambi_bt_revamped-0.3.6.dev6.dist-info/METADATA,sha256=IfbdDC_iGnUvJQjyOAhgf9ePqD6FXj8GdUybUBV2MZ0,3049
17
- casambi_bt_revamped-0.3.6.dev6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- casambi_bt_revamped-0.3.6.dev6.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
- casambi_bt_revamped-0.3.6.dev6.dist-info/RECORD,,
15
+ casambi_bt_revamped-0.3.6.dev8.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
16
+ casambi_bt_revamped-0.3.6.dev8.dist-info/METADATA,sha256=QEh3bPJXW5FC3G6HgHO3wgMo5zEo4nJJaNic5Hw2g38,3049
17
+ casambi_bt_revamped-0.3.6.dev8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ casambi_bt_revamped-0.3.6.dev8.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
19
+ casambi_bt_revamped-0.3.6.dev8.dist-info/RECORD,,