casambi-bt-revamped 0.3.7.dev7__py3-none-any.whl → 0.3.7.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/_casambi.py CHANGED
@@ -98,6 +98,16 @@ class Casambi:
98
98
  and self._casaClient._connectionState == ConnectionState.AUTHENTICATED
99
99
  )
100
100
 
101
+ @property
102
+ def rawNetworkData(self) -> dict | None:
103
+ """Get the raw network configuration data if available.
104
+
105
+ :return: The raw network JSON data or None if not connected.
106
+ """
107
+ if self._casaNetwork:
108
+ return self._casaNetwork.rawNetworkData
109
+ return None
110
+
101
111
  async def connect(
102
112
  self,
103
113
  addr_or_device: str | BLEDevice,
CasambiBt/_client.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import asyncio
2
2
  import logging
3
3
  import struct
4
- from binascii import b2a_hex as b2a, hexlify
4
+ from binascii import b2a_hex as b2a
5
5
  from collections.abc import Callable
6
6
  from enum import IntEnum, unique
7
7
  from hashlib import sha256
@@ -417,9 +417,6 @@ class CasambiClient:
417
417
 
418
418
  # Store raw encrypted packet for reference
419
419
  raw_encrypted_packet = data[:]
420
-
421
- # Log raw encrypted packet with special marker for easy filtering
422
- self._logger.info(f"[CASAMBI_RAW_PACKET] Encrypted #{self._inPacketCount}: {b2a(raw_encrypted_packet)}")
423
420
 
424
421
  try:
425
422
  decrypted_data = self._encryptor.decryptAndVerify(
@@ -432,9 +429,6 @@ class CasambiClient:
432
429
 
433
430
  packetType = decrypted_data[0]
434
431
  self._logger.debug(f"Incoming data of type {packetType}: {b2a(decrypted_data)}")
435
-
436
- # Log decrypted packet with special marker
437
- self._logger.info(f"[CASAMBI_DECRYPTED] Type={packetType} #{self._inPacketCount}: {b2a(decrypted_data)}")
438
432
 
439
433
  if packetType == IncommingPacketType.UnitState:
440
434
  self._parseUnitStates(decrypted_data[1:])
@@ -502,9 +496,6 @@ class CasambiClient:
502
496
  self._logger.info(
503
497
  f"Parsing incoming switch event packet #{packet_seq}... Data: {b2a(data)}"
504
498
  )
505
-
506
- # Log complete packet structure with marker
507
- self._logger.info(f"[CASAMBI_SWITCH_PACKET] Full data #{packet_seq}: hex={b2a(data)} len={len(data)}")
508
499
 
509
500
  # Special handling for message type 0x29 - not a switch event
510
501
  if len(data) >= 1 and data[0] == 0x29:
@@ -516,7 +507,6 @@ class CasambiClient:
516
507
  pos = 0
517
508
  oldPos = 0
518
509
  switch_events_found = 0
519
- all_messages_found = []
520
510
 
521
511
  try:
522
512
  while pos <= len(data) - 3:
@@ -528,12 +518,6 @@ class CasambiClient:
528
518
  length = ((data[pos + 2] >> 4) & 15) + 1
529
519
  parameter = data[pos + 2] # Full byte, not just lower 4 bits
530
520
  pos += 3
531
-
532
- # Log every message found with detailed structure
533
- self._logger.info(
534
- f"[CASAMBI_MSG_FOUND] At pos={oldPos}: type=0x{message_type:02x} flags=0x{flags:02x} "
535
- f"len={length} param=0x{parameter:02x}"
536
- )
537
521
 
538
522
  # Sanity check: message type should be reasonable
539
523
  if message_type > 0x80:
@@ -555,21 +539,6 @@ class CasambiClient:
555
539
  # Extract the payload
556
540
  payload = data[pos : pos + length]
557
541
  pos += length
558
-
559
- # Log the payload
560
- self._logger.info(
561
- f"[CASAMBI_MSG_PAYLOAD] Type 0x{message_type:02x} payload: {b2a(payload)} "
562
- f"(bytes {oldPos+3} to {oldPos+3+length-1})"
563
- )
564
-
565
- # Track all messages
566
- all_messages_found.append({
567
- 'type': message_type,
568
- 'pos': oldPos,
569
- 'flags': flags,
570
- 'param': parameter,
571
- 'payload': b2a(payload)
572
- })
573
542
 
574
543
  # Process based on message type
575
544
  if message_type == 0x08 or message_type == 0x10: # Switch/button events
@@ -631,17 +600,6 @@ class CasambiClient:
631
600
  f"Remaining data {b2a(data[oldPos:])} in {b2a(data)}."
632
601
  )
633
602
 
634
- # Log summary of all messages found
635
- self._logger.info(
636
- f"[CASAMBI_PARSE_SUMMARY] Packet #{packet_seq}: Found {len(all_messages_found)} messages, "
637
- f"{switch_events_found} switch events"
638
- )
639
- for i, msg in enumerate(all_messages_found):
640
- self._logger.info(
641
- f"[CASAMBI_MSG_{i+1}] Type=0x{msg['type']:02x} Pos={msg['pos']} "
642
- f"Flags=0x{msg['flags']:02x} Param=0x{msg['param']:02x} Payload={msg['payload']}"
643
- )
644
-
645
603
  if switch_events_found == 0:
646
604
  self._logger.debug(f"No switch events found in packet: {b2a(data)}")
647
605
 
@@ -736,13 +694,8 @@ class CasambiClient:
736
694
  f"action={action_display} ({event_string}), flags=0x{flags:02x}"
737
695
  )
738
696
 
739
- # Log detailed info about type 0x08 messages before filtering
697
+ # Filter out all type 0x08 messages
740
698
  if message_type == 0x08:
741
- self._logger.info(
742
- f"[CASAMBI_TYPE08_FILTERED] Type 0x08 event detected: button={button}, unit_id={unit_id}, "
743
- f"action={action_display}, event={event_string}, flags=0x{flags:02x}, "
744
- f"payload={hexlify(payload).decode()}, extra_data={hexlify(extra_data).decode() if extra_data else 'none'}"
745
- )
746
699
  self._logger.debug(
747
700
  f"Filtering out type 0x08 event: button={button}, unit_id={unit_id}, "
748
701
  f"action={action_display}, flags=0x{flags:02x}"
CasambiBt/_network.py CHANGED
@@ -44,6 +44,7 @@ class Network:
44
44
  self._networkName: str | None = None
45
45
  self._networkRevision: int | None = None
46
46
  self._protocolVersion: int = -1
47
+ self._rawNetworkData: dict | None = None
47
48
 
48
49
  self._unitTypes: dict[int, tuple[UnitType | None, datetime]] = {}
49
50
  self.units: list[Unit] = []
@@ -153,6 +154,10 @@ class Network:
153
154
  def protocolVersion(self) -> int:
154
155
  return self._protocolVersion
155
156
 
157
+ @property
158
+ def rawNetworkData(self) -> dict | None:
159
+ return self._rawNetworkData
160
+
156
161
  async def logIn(self, password: str, forceOffline: bool = False) -> None:
157
162
  await self.getNetworkId(forceOffline)
158
163
 
@@ -191,6 +196,7 @@ class Network:
191
196
  cachedNetworkPah = cachePath / f"{self._id}.json"
192
197
  if await cachedNetworkPah.exists():
193
198
  network = json.loads(await cachedNetworkPah.read_bytes())
199
+ self._rawNetworkData = network
194
200
  self._networkRevision = network["network"]["revision"]
195
201
  self._logger.info(
196
202
  f"Loaded cached network. Revision: {self._networkRevision}"
@@ -233,6 +239,7 @@ class Network:
233
239
  updateResult = res.json()
234
240
  if updateResult["status"] != "UPTODATE":
235
241
  self._networkRevision = updateResult["network"]["revision"]
242
+ self._rawNetworkData = updateResult
236
243
  async with self._cache as cachePath:
237
244
  cachedNetworkPah = cachePath / f"{self._id}.json"
238
245
  await cachedNetworkPah.write_bytes(res.content)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: casambi-bt-revamped
3
- Version: 0.3.7.dev7
3
+ Version: 0.3.7.dev9
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,18 +1,18 @@
1
1
  CasambiBt/__init__.py,sha256=TW445xSu5PV3TyMjJfwaA1JoWvQQ8LXhZgGdDTfWf3s,302
2
2
  CasambiBt/_cache.py,sha256=KZ2xbiHAHXUPa8Gw_75Nw9NL4QSY_sTWHbyYXYUDaB0,3865
3
- CasambiBt/_casambi.py,sha256=tQgmG-8lHbl4_FDS7NwPrucrqcQZd2kimcJa43TYFaw,23156
4
- CasambiBt/_client.py,sha256=lcF6N8QoVBOvtYK8EAND6emAdIVHutLTzA_A3l1wTng,31235
3
+ CasambiBt/_casambi.py,sha256=NSi4Yiv0KtX4evbYdTO-9BcG0HsXjp88V8yQVLR1qb8,23472
4
+ CasambiBt/_client.py,sha256=w57LoLO3tUWsSaPR28RuMZN1Q-KoOxKcUUsI7suvpNE,28864
5
5
  CasambiBt/_constants.py,sha256=_AxkG7Btxl4VeS6mO7GJW5Kc9dFs3s9sDmtJ83ZEKNw,359
6
6
  CasambiBt/_discover.py,sha256=H7HpiFYIy9ELvmPXXd_ck-5O5invJf15dDIRk-vO5IE,1696
7
7
  CasambiBt/_encryption.py,sha256=CLcoOOrggQqhJbnr_emBnEnkizpWDvb_0yFnitq4_FM,3831
8
8
  CasambiBt/_keystore.py,sha256=Jdiq0zMPDmhfpheSojKY6sTUpmVrvX_qOyO7yCYd3kw,2788
9
- CasambiBt/_network.py,sha256=qcsWn_EsBexzXCv14JcpSIymhuR6Eaf479lZdzpfYBM,14417
9
+ CasambiBt/_network.py,sha256=Gh0n3FEcOUHUMuBXALwcb3tws-AofpYLegKIquqtZl4,14665
10
10
  CasambiBt/_operation.py,sha256=-BuC1Bvtg-G-zSN_b_0JMvXdHZaR6LbTw0S425jg96c,842
11
11
  CasambiBt/_unit.py,sha256=M-Q8-Xd3qjJSUEvsFtic8E4xDc_gtWYakbTGyoIA-P8,16377
12
12
  CasambiBt/errors.py,sha256=0JgDjaKlAKDes0poWzA8nrTUYQ8qdNfBb8dfaqqzCRA,1664
13
13
  CasambiBt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- casambi_bt_revamped-0.3.7.dev7.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
15
- casambi_bt_revamped-0.3.7.dev7.dist-info/METADATA,sha256=euuEUM2dktm9lAZeI8-5FVr913OcTEXUkNppVVHm4F8,3048
16
- casambi_bt_revamped-0.3.7.dev7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- casambi_bt_revamped-0.3.7.dev7.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
18
- casambi_bt_revamped-0.3.7.dev7.dist-info/RECORD,,
14
+ casambi_bt_revamped-0.3.7.dev9.dist-info/licenses/LICENSE,sha256=TAIIitFxpxEDi6Iju7foW4TDQmWvC-IhLVLhl67jKmQ,11341
15
+ casambi_bt_revamped-0.3.7.dev9.dist-info/METADATA,sha256=ayBdRpd11wF6LUrvL1DkoPgExfNKLuwzoq1D97_z9QA,3048
16
+ casambi_bt_revamped-0.3.7.dev9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ casambi_bt_revamped-0.3.7.dev9.dist-info/top_level.txt,sha256=uNbqLjtecFosoFzpGAC89-5icikWODKI8rOjbi8v_sA,10
18
+ casambi_bt_revamped-0.3.7.dev9.dist-info/RECORD,,