aioccl 2025.6.4__tar.gz → 2025.6.6__tar.gz
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-2025.6.4 → aioccl-2025.6.6}/PKG-INFO +1 -1
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl/device.py +16 -20
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl/sensor.py +17 -7
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl.egg-info/PKG-INFO +1 -1
- {aioccl-2025.6.4 → aioccl-2025.6.6}/setup.py +1 -1
- {aioccl-2025.6.4 → aioccl-2025.6.6}/LICENSE +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/README.md +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl/__init__.py +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl/exception.py +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl/server.py +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl.egg-info/SOURCES.txt +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl.egg-info/dependency_links.txt +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl.egg-info/requires.txt +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/aioccl.egg-info/top_level.txt +0 -0
- {aioccl-2025.6.4 → aioccl-2025.6.6}/setup.cfg +0 -0
@@ -40,11 +40,10 @@ class CCLDevice:
|
|
40
40
|
}
|
41
41
|
|
42
42
|
self._sensors: dict[str, CCLSensor] = {}
|
43
|
-
|
44
|
-
self._update_callback = {}
|
43
|
+
self._update_callback: Callable[[], None] | None = None
|
45
44
|
|
46
45
|
self._new_sensors: list[CCLSensor] | None = []
|
47
|
-
self.
|
46
|
+
self._new_sensor_callback: Callable[[], None] | None = None
|
48
47
|
|
49
48
|
@property
|
50
49
|
def passkey(self) -> str:
|
@@ -105,15 +104,17 @@ class CCLDevice:
|
|
105
104
|
if key not in self._sensors:
|
106
105
|
self._sensors[key] = CCLSensor(key)
|
107
106
|
self._new_sensors.append(self._sensors[key])
|
107
|
+
self._sensors[key].last_update_time = time.monotonic()
|
108
108
|
self._sensors[key].value = value
|
109
109
|
|
110
110
|
add_count = self._publish_new_sensors()
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
if add_count > 0:
|
112
|
+
_LOGGER.debug(
|
113
|
+
"Added %s new sensors for device %s at %s.",
|
114
|
+
add_count,
|
115
|
+
self.device_id,
|
116
|
+
self.last_update_time,
|
117
|
+
)
|
117
118
|
|
118
119
|
self._publish_updates()
|
119
120
|
_LOGGER.debug(
|
@@ -137,13 +138,9 @@ class CCLDevice:
|
|
137
138
|
err,
|
138
139
|
)
|
139
140
|
|
140
|
-
def
|
141
|
-
"""
|
142
|
-
self.
|
143
|
-
|
144
|
-
def remove_new_sensor_cb(self, callback: Callable[[], None]) -> None:
|
145
|
-
"""Remove a registered callback."""
|
146
|
-
self._new_sensor_callbacks.discard(callback)
|
141
|
+
def set_new_sensor_callback(self, callback: Callable[[], None]) -> None:
|
142
|
+
"""Set the callback function to add a new sensor."""
|
143
|
+
self._new_sensor_callback = callback
|
147
144
|
|
148
145
|
def _publish_new_sensors(self) -> int:
|
149
146
|
"""Schedule all registered callbacks to add new sensors."""
|
@@ -151,10 +148,9 @@ class CCLDevice:
|
|
151
148
|
error_count = 0
|
152
149
|
for sensor in self._new_sensors[:]:
|
153
150
|
try:
|
154
|
-
assert
|
155
|
-
|
156
|
-
|
157
|
-
raise CCLDataUpdateException("Failed to publish new sensor")
|
151
|
+
assert self._new_sensor_callback is not None
|
152
|
+
if self._new_sensor_callback(sensor) is not True:
|
153
|
+
raise CCLDataUpdateException("Failed to publish new sensor")
|
158
154
|
self._new_sensors.remove(sensor)
|
159
155
|
success_count += 1
|
160
156
|
except Exception: # pylint: disable=broad-exception-caught
|
@@ -11,7 +11,8 @@ class CCLSensor:
|
|
11
11
|
|
12
12
|
def __init__(self, key: str):
|
13
13
|
"""Initialize a CCL sensor."""
|
14
|
-
self.
|
14
|
+
self._last_update_time: float | None = None
|
15
|
+
self._value: str | int | float | None = None
|
15
16
|
|
16
17
|
if key in CCL_SENSORS:
|
17
18
|
self._key = key
|
@@ -32,14 +33,23 @@ class CCLSensor:
|
|
32
33
|
return CCL_SENSORS[self._key].sensor_type
|
33
34
|
|
34
35
|
@property
|
35
|
-
def compartment(self) ->
|
36
|
+
def compartment(self) -> str | None:
|
36
37
|
"""Decide which compartment it belongs to."""
|
37
38
|
if CCL_SENSORS[self._key].compartment in CCLDeviceCompartment:
|
38
39
|
return CCL_SENSORS[self._key].compartment.value
|
39
40
|
return None
|
40
41
|
|
41
42
|
@property
|
42
|
-
def
|
43
|
+
def last_update_time(self) -> float | None:
|
44
|
+
"""Return the last update time of the sensor."""
|
45
|
+
return self._last_update_time
|
46
|
+
|
47
|
+
@last_update_time.setter
|
48
|
+
def last_update_time(self, new_value):
|
49
|
+
self._last_update_time = new_value
|
50
|
+
|
51
|
+
@property
|
52
|
+
def value(self) -> str | int | float | None:
|
43
53
|
"""Return the intrinsic sensor value."""
|
44
54
|
if self.sensor_type.name in CCL_SENSOR_VALUES:
|
45
55
|
return CCL_SENSOR_VALUES[self.sensor_type.name].get(self._value)
|
@@ -77,7 +87,7 @@ class CCLSensorTypes(enum.Enum):
|
|
77
87
|
CO = 13
|
78
88
|
CO2 = 14
|
79
89
|
VOLATILE = 15
|
80
|
-
|
90
|
+
VOC_LEVEL = 16
|
81
91
|
PM10 = 17
|
82
92
|
PM25 = 18
|
83
93
|
AQI = 19
|
@@ -92,8 +102,8 @@ class CCLSensorTypes(enum.Enum):
|
|
92
102
|
class CCLDeviceCompartment(enum.Enum):
|
93
103
|
"""Grouping of CCL sensors."""
|
94
104
|
|
95
|
-
MAIN = "Console & Sensor
|
96
|
-
OTHER = "Other
|
105
|
+
MAIN = "Console & Sensor array"
|
106
|
+
OTHER = "Other sensors"
|
97
107
|
STATUS = "Status"
|
98
108
|
|
99
109
|
|
@@ -211,7 +221,7 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
211
221
|
"Air Quality: PM2.5 AQI", CCLSensorTypes.AQI, CCLDeviceCompartment.OTHER
|
212
222
|
),
|
213
223
|
"t9voclv": CCLSensorPreset(
|
214
|
-
"Air Quality: VOC Level", CCLSensorTypes.
|
224
|
+
"Air Quality: VOC Level", CCLSensorTypes.VOC_LEVEL, CCLDeviceCompartment.OTHER
|
215
225
|
),
|
216
226
|
"t234c1tem": CCLSensorPreset(
|
217
227
|
"CH1 Temperature", CCLSensorTypes.TEMPERATURE, CCLDeviceCompartment.OTHER
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|