aioccl 2025.6.3__tar.gz → 2025.6.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioccl
3
- Version: 2025.6.3
3
+ Version: 2025.6.5
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/CCL-Electronics-Ltd/aioccl
6
6
  Download-URL: https://github.com/CCL-Electronics-Ltd/aioccl
@@ -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._new_sensor_callbacks = set()
46
+ self._new_sensor_callback: Callable[[], None] | None = None
48
47
 
49
48
  @property
50
49
  def passkey(self) -> str:
@@ -108,12 +107,13 @@ class CCLDevice:
108
107
  self._sensors[key].value = value
109
108
 
110
109
  add_count = self._publish_new_sensors()
111
- _LOGGER.debug(
112
- "Added %s new sensors for device %s at %s.",
113
- add_count,
114
- self.device_id,
115
- self.last_update_time,
116
- )
110
+ if add_count > 0:
111
+ _LOGGER.debug(
112
+ "Added %s new sensors for device %s at %s.",
113
+ add_count,
114
+ self.device_id,
115
+ self.last_update_time,
116
+ )
117
117
 
118
118
  self._publish_updates()
119
119
  _LOGGER.debug(
@@ -137,28 +137,27 @@ class CCLDevice:
137
137
  err,
138
138
  )
139
139
 
140
- def register_new_sensor_cb(self, callback: Callable[[], None]) -> None:
141
- """Register callback of adding a new sensor."""
142
- self._new_sensor_callbacks.add(callback)
140
+ def set_new_sensor_callback(self, callback: Callable[[], None]) -> None:
141
+ """Set the callback function to add a new sensor."""
142
+ self._new_sensor_callback = callback
143
143
 
144
- def remove_new_sensor_cb(self, callback: Callable[[], None]) -> None:
145
- """Remove a registered callback."""
146
- self._new_sensor_callbacks.discard(callback)
147
-
148
- def _publish_new_sensors(self) -> None:
144
+ def _publish_new_sensors(self) -> int:
149
145
  """Schedule all registered callbacks to add new sensors."""
150
- count = 0
146
+ success_count = 0
147
+ error_count = 0
151
148
  for sensor in self._new_sensors[:]:
152
149
  try:
153
- for callback in self._new_sensor_callbacks:
154
- callback(sensor)
150
+ assert self._new_sensor_callback is not None
151
+ if self._new_sensor_callback(sensor) is not True:
152
+ raise CCLDataUpdateException("Failed to publish new sensor")
155
153
  self._new_sensors.remove(sensor)
156
- count += 1
157
- except Exception as err: # pylint: disable=broad-exception-caught
158
- _LOGGER.warning(
159
- "Error while adding sensor %s for device %s: %s",
160
- sensor.key,
154
+ success_count += 1
155
+ except Exception: # pylint: disable=broad-exception-caught
156
+ error_count += 1
157
+ if error_count > 0:
158
+ _LOGGER.warning(
159
+ "Failed to add %s sensors for device %s",
160
+ error_count,
161
161
  self.device_id,
162
- err,
163
162
  )
164
- return count
163
+ return success_count
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioccl
3
- Version: 2025.6.3
3
+ Version: 2025.6.5
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/CCL-Electronics-Ltd/aioccl
6
6
  Download-URL: https://github.com/CCL-Electronics-Ltd/aioccl
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
  from setuptools import find_packages, setup
5
5
 
6
- VERSION = "2025.6.3"
6
+ VERSION = "2025.6.5"
7
7
 
8
8
  ROOT_DIR = Path(__file__).parent.resolve()
9
9
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes