aioccl 2025.4__py3-none-any.whl → 2025.6__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.
- aioccl/device.py +11 -25
- aioccl/sensor.py +15 -43
- aioccl/server.py +11 -10
- {aioccl-2025.4.dist-info → aioccl-2025.6.dist-info}/METADATA +1 -1
- aioccl-2025.6.dist-info/RECORD +9 -0
- {aioccl-2025.4.dist-info → aioccl-2025.6.dist-info}/WHEEL +1 -1
- aioccl-2025.4.dist-info/RECORD +0 -9
- {aioccl-2025.4.dist-info → aioccl-2025.6.dist-info}/licenses/LICENSE +0 -0
- {aioccl-2025.4.dist-info → aioccl-2025.6.dist-info}/top_level.txt +0 -0
aioccl/device.py
CHANGED
@@ -27,11 +27,7 @@ class CCLDevice:
|
|
27
27
|
model: str | None
|
28
28
|
passkey: str
|
29
29
|
serial_no: str | None
|
30
|
-
|
31
|
-
class Data(TypedDict):
|
32
|
-
"""Store sensor data."""
|
33
|
-
binary_sensors: dict[str, CCLSensor]
|
34
|
-
sensors: dict[str, CCLSensor]
|
30
|
+
|
35
31
|
|
36
32
|
self._info: Info = {
|
37
33
|
"fw_ver": None,
|
@@ -41,15 +37,11 @@ class CCLDevice:
|
|
41
37
|
"passkey": passkey,
|
42
38
|
"serial_no": None,
|
43
39
|
}
|
44
|
-
|
45
|
-
self.
|
46
|
-
|
47
|
-
"sensors": {}
|
48
|
-
}
|
49
|
-
|
40
|
+
|
41
|
+
self._sensors: dict[str, CCLSensor] = {}
|
42
|
+
|
50
43
|
self._update_callback = {}
|
51
44
|
|
52
|
-
self._new_binary_sensor_callbacks = set()
|
53
45
|
self._new_sensors: list[CCLSensor] | None = []
|
54
46
|
self._new_sensor_callbacks = set()
|
55
47
|
|
@@ -93,9 +85,9 @@ class CCLDevice:
|
|
93
85
|
return self._info["fw_ver"]
|
94
86
|
|
95
87
|
@property
|
96
|
-
def
|
88
|
+
def get_sensors(self) -> dict[str, CCLSensor]:
|
97
89
|
"""Get all types of sensor data under this device."""
|
98
|
-
return self.
|
90
|
+
return self._sensors
|
99
91
|
|
100
92
|
def update_info(self, new_info: dict[str, None | str]) -> None:
|
101
93
|
"""Add or update device info."""
|
@@ -107,16 +99,10 @@ class CCLDevice:
|
|
107
99
|
def process_data(self, data: dict[str, None | str | int | float]) -> None:
|
108
100
|
"""Add or update all sensor values."""
|
109
101
|
for key, value in data.items():
|
110
|
-
if
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
self._data["binary_sensors"][key].value = value
|
115
|
-
else:
|
116
|
-
if key not in self._data["sensors"]:
|
117
|
-
self._data["sensors"][key] = CCLSensor(key)
|
118
|
-
self._new_sensors.append(self._data["sensors"][key])
|
119
|
-
self._data["sensors"][key].value = value
|
102
|
+
if key not in self._sensors:
|
103
|
+
self._sensors[key] = CCLSensor(key)
|
104
|
+
self._new_sensors.append(self._sensors[key])
|
105
|
+
self._sensors[key].value = value
|
120
106
|
|
121
107
|
add_count = self._publish_new_sensors()
|
122
108
|
_LOGGER.debug(
|
@@ -140,7 +126,7 @@ class CCLDevice:
|
|
140
126
|
def _publish_updates(self) -> None:
|
141
127
|
"""Call the function to update sensor data."""
|
142
128
|
try:
|
143
|
-
self._update_callback(self.
|
129
|
+
self._update_callback(self._sensors)
|
144
130
|
except Exception as err: # pylint: disable=broad-exception-caught
|
145
131
|
_LOGGER.warning(
|
146
132
|
"Error while updating sensors for device %s: %s",
|
aioccl/sensor.py
CHANGED
@@ -38,11 +38,6 @@ class CCLSensor:
|
|
38
38
|
return CCL_SENSORS[self._key].compartment.value
|
39
39
|
return None
|
40
40
|
|
41
|
-
@property
|
42
|
-
def binary(self) -> bool:
|
43
|
-
"""Decide if the sensor is binary."""
|
44
|
-
return CCL_SENSORS[self._key].binary
|
45
|
-
|
46
41
|
@property
|
47
42
|
def value(self) -> None | str | int | float:
|
48
43
|
"""Return the intrinsic sensor value."""
|
@@ -62,7 +57,6 @@ class CCLSensorPreset:
|
|
62
57
|
name: str
|
63
58
|
sensor_type: str
|
64
59
|
compartment: CCLDeviceCompartment | None = None
|
65
|
-
binary: bool = False
|
66
60
|
|
67
61
|
|
68
62
|
class CCLSensorTypes(enum.Enum):
|
@@ -335,25 +329,25 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
335
329
|
),
|
336
330
|
# Status 78-119
|
337
331
|
"t234c1bat": CCLSensorPreset(
|
338
|
-
"Battery: CH1", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
332
|
+
"Battery: CH1", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
339
333
|
),
|
340
334
|
"t234c2bat": CCLSensorPreset(
|
341
|
-
"Battery: CH2", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
335
|
+
"Battery: CH2", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
342
336
|
),
|
343
337
|
"t234c3bat": CCLSensorPreset(
|
344
|
-
"Battery: CH3", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
338
|
+
"Battery: CH3", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
345
339
|
),
|
346
340
|
"t234c4bat": CCLSensorPreset(
|
347
|
-
"Battery: CH4", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
341
|
+
"Battery: CH4", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
348
342
|
),
|
349
343
|
"t234c5bat": CCLSensorPreset(
|
350
|
-
"Battery: CH5", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
344
|
+
"Battery: CH5", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
351
345
|
),
|
352
346
|
"t234c6bat": CCLSensorPreset(
|
353
|
-
"Battery: CH6", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
347
|
+
"Battery: CH6", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
354
348
|
),
|
355
349
|
"t234c7bat": CCLSensorPreset(
|
356
|
-
"Battery: CH7", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
350
|
+
"Battery: CH7", CCLSensorTypes.BATTERY_BINARY, CCLDeviceCompartment.STATUS
|
357
351
|
),
|
358
352
|
"t11bat": CCLSensorPreset(
|
359
353
|
"Battery Level: CO", CCLSensorTypes.BATTERY, CCLDeviceCompartment.STATUS
|
@@ -365,7 +359,6 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
365
359
|
"Battery: Console",
|
366
360
|
CCLSensorTypes.BATTERY_BINARY,
|
367
361
|
CCLDeviceCompartment.STATUS,
|
368
|
-
True,
|
369
362
|
),
|
370
363
|
"t9bat": CCLSensorPreset(
|
371
364
|
"Battery Level: HCHO/VOC", CCLSensorTypes.BATTERY, CCLDeviceCompartment.STATUS
|
@@ -374,55 +367,46 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
374
367
|
"Battery: Leakage CH1",
|
375
368
|
CCLSensorTypes.BATTERY_BINARY,
|
376
369
|
CCLDeviceCompartment.STATUS,
|
377
|
-
True,
|
378
370
|
),
|
379
371
|
"t6c2bat": CCLSensorPreset(
|
380
372
|
"Battery: Leakage CH2",
|
381
373
|
CCLSensorTypes.BATTERY_BINARY,
|
382
374
|
CCLDeviceCompartment.STATUS,
|
383
|
-
True,
|
384
375
|
),
|
385
376
|
"t6c3bat": CCLSensorPreset(
|
386
377
|
"Battery: Leakage CH3",
|
387
378
|
CCLSensorTypes.BATTERY_BINARY,
|
388
379
|
CCLDeviceCompartment.STATUS,
|
389
|
-
True,
|
390
380
|
),
|
391
381
|
"t6c4bat": CCLSensorPreset(
|
392
382
|
"Battery: Leakage CH4",
|
393
383
|
CCLSensorTypes.BATTERY_BINARY,
|
394
384
|
CCLDeviceCompartment.STATUS,
|
395
|
-
True,
|
396
385
|
),
|
397
386
|
"t6c5bat": CCLSensorPreset(
|
398
387
|
"Battery: Leakage CH5",
|
399
388
|
CCLSensorTypes.BATTERY_BINARY,
|
400
389
|
CCLDeviceCompartment.STATUS,
|
401
|
-
True,
|
402
390
|
),
|
403
391
|
"t6c6bat": CCLSensorPreset(
|
404
392
|
"Battery: Leakage CH6",
|
405
393
|
CCLSensorTypes.BATTERY_BINARY,
|
406
394
|
CCLDeviceCompartment.STATUS,
|
407
|
-
True,
|
408
395
|
),
|
409
396
|
"t6c7bat": CCLSensorPreset(
|
410
397
|
"Battery: Leakage CH7",
|
411
398
|
CCLSensorTypes.BATTERY_BINARY,
|
412
399
|
CCLDeviceCompartment.STATUS,
|
413
|
-
True,
|
414
400
|
),
|
415
401
|
"t5lsbat": CCLSensorPreset(
|
416
402
|
"Battery: Lightning Sensor",
|
417
403
|
CCLSensorTypes.BATTERY_BINARY,
|
418
404
|
CCLDeviceCompartment.STATUS,
|
419
|
-
True,
|
420
405
|
),
|
421
406
|
"t1bat": CCLSensorPreset(
|
422
407
|
"Battery: Sensor Array",
|
423
408
|
CCLSensorTypes.BATTERY_BINARY,
|
424
409
|
CCLDeviceCompartment.STATUS,
|
425
|
-
True,
|
426
410
|
),
|
427
411
|
"t1batvt": CCLSensorPreset(
|
428
412
|
"Battery Voltage: Sensor Array",
|
@@ -433,99 +417,87 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
433
417
|
"Battery Level: PM2.5/10", CCLSensorTypes.BATTERY, CCLDeviceCompartment.STATUS
|
434
418
|
),
|
435
419
|
"t234c1cn": CCLSensorPreset(
|
436
|
-
"Connection: CH1", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
420
|
+
"Connection: CH1", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
437
421
|
),
|
438
422
|
"t234c2cn": CCLSensorPreset(
|
439
|
-
"Connection: CH2", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
423
|
+
"Connection: CH2", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
440
424
|
),
|
441
425
|
"t234c3cn": CCLSensorPreset(
|
442
|
-
"Connection: CH3", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
426
|
+
"Connection: CH3", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
443
427
|
),
|
444
428
|
"t234c4cn": CCLSensorPreset(
|
445
|
-
"Connection: CH4", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
429
|
+
"Connection: CH4", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
446
430
|
),
|
447
431
|
"t234c5cn": CCLSensorPreset(
|
448
|
-
"Connection: CH5", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
432
|
+
"Connection: CH5", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
449
433
|
),
|
450
434
|
"t234c6cn": CCLSensorPreset(
|
451
|
-
"Connection: CH6", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
435
|
+
"Connection: CH6", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
452
436
|
),
|
453
437
|
"t234c7cn": CCLSensorPreset(
|
454
|
-
"Connection: CH7", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
438
|
+
"Connection: CH7", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
455
439
|
),
|
456
440
|
"t6c1cn": CCLSensorPreset(
|
457
441
|
"Connection: Leakage CH1",
|
458
442
|
CCLSensorTypes.CONNECTION,
|
459
443
|
CCLDeviceCompartment.STATUS,
|
460
|
-
True,
|
461
444
|
),
|
462
445
|
"t6c2cn": CCLSensorPreset(
|
463
446
|
"Connection: Leakage CH2",
|
464
447
|
CCLSensorTypes.CONNECTION,
|
465
448
|
CCLDeviceCompartment.STATUS,
|
466
|
-
True,
|
467
449
|
),
|
468
450
|
"t6c3cn": CCLSensorPreset(
|
469
451
|
"Connection: Leakage CH3",
|
470
452
|
CCLSensorTypes.CONNECTION,
|
471
453
|
CCLDeviceCompartment.STATUS,
|
472
|
-
True,
|
473
454
|
),
|
474
455
|
"t6c4cn": CCLSensorPreset(
|
475
456
|
"Connection: Leakage CH4",
|
476
457
|
CCLSensorTypes.CONNECTION,
|
477
458
|
CCLDeviceCompartment.STATUS,
|
478
|
-
True,
|
479
459
|
),
|
480
460
|
"t6c5cn": CCLSensorPreset(
|
481
461
|
"Connection: Leakage CH5",
|
482
462
|
CCLSensorTypes.CONNECTION,
|
483
463
|
CCLDeviceCompartment.STATUS,
|
484
|
-
True,
|
485
464
|
),
|
486
465
|
"t6c6cn": CCLSensorPreset(
|
487
466
|
"Connection: Leakage CH6",
|
488
467
|
CCLSensorTypes.CONNECTION,
|
489
468
|
CCLDeviceCompartment.STATUS,
|
490
|
-
True,
|
491
469
|
),
|
492
470
|
"t6c7cn": CCLSensorPreset(
|
493
471
|
"Connection: Leakage CH7",
|
494
472
|
CCLSensorTypes.CONNECTION,
|
495
473
|
CCLDeviceCompartment.STATUS,
|
496
|
-
True,
|
497
474
|
),
|
498
475
|
"t5lscn": CCLSensorPreset(
|
499
476
|
"Connection: Lightning Sensor",
|
500
477
|
CCLSensorTypes.CONNECTION,
|
501
478
|
CCLDeviceCompartment.STATUS,
|
502
|
-
True,
|
503
479
|
),
|
504
480
|
"t11cn": CCLSensorPreset(
|
505
|
-
"Connection: CO", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
481
|
+
"Connection: CO", CCLSensorTypes.CONNECTION, CCLDeviceCompartment.STATUS
|
506
482
|
),
|
507
483
|
"t10cn": CCLSensorPreset(
|
508
484
|
"Connection: CO\u2082",
|
509
485
|
CCLSensorTypes.CONNECTION,
|
510
486
|
CCLDeviceCompartment.STATUS,
|
511
|
-
True,
|
512
487
|
),
|
513
488
|
"t9cn": CCLSensorPreset(
|
514
489
|
"Connection: HCHO/VOC",
|
515
490
|
CCLSensorTypes.CONNECTION,
|
516
491
|
CCLDeviceCompartment.STATUS,
|
517
|
-
True,
|
518
492
|
),
|
519
493
|
"t1cn": CCLSensorPreset(
|
520
494
|
"Connection: Sensor Array",
|
521
495
|
CCLSensorTypes.CONNECTION,
|
522
496
|
CCLDeviceCompartment.STATUS,
|
523
|
-
True,
|
524
497
|
),
|
525
498
|
"t8cn": CCLSensorPreset(
|
526
499
|
"Connection: PM2.5/10",
|
527
500
|
CCLSensorTypes.CONNECTION,
|
528
501
|
CCLDeviceCompartment.STATUS,
|
529
|
-
True,
|
530
502
|
),
|
531
503
|
}
|
aioccl/server.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
+
from http import HTTPStatus
|
5
6
|
import logging
|
6
7
|
|
7
8
|
from aiohttp import web
|
@@ -43,22 +44,22 @@ class CCLServer:
|
|
43
44
|
if passkey == ref_passkey:
|
44
45
|
device = ref_device
|
45
46
|
break
|
46
|
-
assert isinstance(device, CCLDevice),
|
47
|
+
assert isinstance(device, CCLDevice), HTTPStatus.NOT_FOUND
|
47
48
|
|
48
|
-
assert request.content_type == "application/json",
|
49
|
-
assert 0 < request.content_length <= 5000,
|
49
|
+
assert request.content_type == "application/json", HTTPStatus.BAD_REQUEST
|
50
|
+
assert 0 < request.content_length <= 5000, HTTPStatus.BAD_REQUEST
|
50
51
|
|
51
52
|
body = await request.json()
|
52
53
|
|
53
54
|
except Exception as err: # pylint: disable=broad-exception-caught
|
54
55
|
status = err.args[0]
|
55
|
-
if status ==
|
56
|
-
text = "400 Bad Request"
|
57
|
-
elif status ==
|
58
|
-
text = "404 Not Found"
|
56
|
+
if status == HTTPStatus.BAD_REQUEST:
|
57
|
+
text = "400 Bad Request."
|
58
|
+
elif status == HTTPStatus.NOT_FOUND:
|
59
|
+
text = "404 Not Found."
|
59
60
|
else:
|
60
|
-
status =
|
61
|
-
text = "500 Internal Server Error"
|
61
|
+
status = HTTPStatus.INTERNAL_SERVER_ERROR
|
62
|
+
text = "500 Internal Server Error."
|
62
63
|
_LOGGER.debug("Request exception occured: %s", err)
|
63
64
|
return web.Response(status=status, text=text)
|
64
65
|
|
@@ -70,7 +71,7 @@ class CCLServer:
|
|
70
71
|
|
71
72
|
device.update_info(info)
|
72
73
|
device.process_data(data)
|
73
|
-
status =
|
74
|
+
status = HTTPStatus.OK
|
74
75
|
text = "200 OK"
|
75
76
|
_LOGGER.debug("Request processed: %s", passkey)
|
76
77
|
return web.Response(status=status, text=text)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
|
2
|
+
aioccl/device.py,sha256=t3-3MP-RjaX7FM14A0axh9YDg-Xh2ICkgAMR-OHKYKg,5017
|
3
|
+
aioccl/sensor.py,sha256=dtBC4hXH6ac3Tw4iUEtDfCB4qGepJBpPgobIVjx8QEc,16346
|
4
|
+
aioccl/server.py,sha256=niD0h2i6rS1qr4vCmepwEBhVIylvVGt7_WbBO0-Z1Rs,3377
|
5
|
+
aioccl-2025.6.dist-info/licenses/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
|
6
|
+
aioccl-2025.6.dist-info/METADATA,sha256=8MrzFaaelX_71yiD2ZieCpEvZ9Wmvq3KNNKRNhRuL-g,989
|
7
|
+
aioccl-2025.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
+
aioccl-2025.6.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
+
aioccl-2025.6.dist-info/RECORD,,
|
aioccl-2025.4.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
|
2
|
-
aioccl/device.py,sha256=7UUEcg__1Q-gug8E5nuTAP_TWVeyoeuZSvNNUjIwJ1g,5691
|
3
|
-
aioccl/sensor.py,sha256=-yWdgBzOzLPHP2GBqvhVVGbIlt17y_3OSHibhB_DsQ8,16905
|
4
|
-
aioccl/server.py,sha256=RvWH6hqlQDq82u_8oO69SA0qeCDWGdVoi0wb5uYKQrs,3216
|
5
|
-
aioccl-2025.4.dist-info/licenses/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
|
6
|
-
aioccl-2025.4.dist-info/METADATA,sha256=e5mkGmPL4RnVj1XCNqXRW8NOybwroWVyhlezyIe6yCY,989
|
7
|
-
aioccl-2025.4.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
8
|
-
aioccl-2025.4.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
-
aioccl-2025.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|