aioccl 2025.6.4__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.4
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,13 +137,9 @@ 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)
143
-
144
- def remove_new_sensor_cb(self, callback: Callable[[], None]) -> None:
145
- """Remove a registered callback."""
146
- self._new_sensor_callbacks.discard(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
147
143
 
148
144
  def _publish_new_sensors(self) -> int:
149
145
  """Schedule all registered callbacks to add new sensors."""
@@ -151,10 +147,9 @@ class CCLDevice:
151
147
  error_count = 0
152
148
  for sensor in self._new_sensors[:]:
153
149
  try:
154
- assert len(self._new_sensor_callbacks) > 0
155
- for callback in self._new_sensor_callbacks:
156
- if callback(sensor) is not True:
157
- raise CCLDataUpdateException("Failed to publish new 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")
158
153
  self._new_sensors.remove(sensor)
159
154
  success_count += 1
160
155
  except Exception: # pylint: disable=broad-exception-caught
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioccl
3
- Version: 2025.6.4
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.4"
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