aioccl 2025.6.8__py3-none-any.whl → 2025.7.1__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 CHANGED
@@ -7,7 +7,7 @@ import time
7
7
  from typing import Callable, TypedDict
8
8
 
9
9
  from .exception import CCLDataUpdateException
10
- from .sensor import CCLSensor, CCL_SENSORS
10
+ from .sensor import CCLSensor
11
11
 
12
12
  _LOGGER = logging.getLogger(__name__)
13
13
 
@@ -83,8 +83,7 @@ class CCLDevice:
83
83
  def fw_ver(self) -> str | None:
84
84
  """Return the firmware version."""
85
85
  return self._info["fw_ver"]
86
-
87
- @property
86
+
88
87
  def get_sensors(self) -> dict[str, CCLSensor]:
89
88
  """Get all types of sensor data under this device."""
90
89
  if self._info["last_update_time"] is None:
@@ -92,6 +91,15 @@ class CCLDevice:
92
91
  if len(self._sensors) == 0 or time.monotonic() - self._info["last_update_time"] > 600:
93
92
  raise CCLDataUpdateException("Device is offline or not ready")
94
93
  return self._sensors
94
+
95
+ def set_update_callback(self, callback: Callable[[], None]) -> None:
96
+ """Set the callback function to update sensor data."""
97
+ self._update_callback = callback
98
+
99
+ def set_new_sensor_callback(self, callback: Callable[[], None]) -> None:
100
+ """Set the callback function to add a new sensor."""
101
+ self._new_sensor_callback = callback
102
+
95
103
 
96
104
  def update_info(self, new_info: dict[str, None | str]) -> None:
97
105
  """Add or update device info."""
@@ -102,11 +110,9 @@ class CCLDevice:
102
110
 
103
111
  def push_updates(self) -> None:
104
112
  """Push sensor updates."""
105
- add_count = self._publish_new_sensors()
106
- if add_count > 0:
113
+ if self._publish_new_sensors() is True:
107
114
  _LOGGER.debug(
108
- "Added %s new sensors for device %s at %s.",
109
- add_count,
115
+ "Added new sensors for device %s at %s.",
110
116
  self.device_id,
111
117
  self.last_update_time,
112
118
  )
@@ -128,10 +134,6 @@ class CCLDevice:
128
134
  self._sensors[key].value = value
129
135
  self.push_updates()
130
136
 
131
- def set_update_callback(self, callback: Callable[[], None]) -> None:
132
- """Set the callback function to update sensor data."""
133
- self._update_callback = callback
134
-
135
137
  def _publish_updates(self) -> None:
136
138
  """Call the function to update sensor data."""
137
139
  try:
@@ -143,27 +145,12 @@ class CCLDevice:
143
145
  err,
144
146
  )
145
147
 
146
- def set_new_sensor_callback(self, callback: Callable[[], None]) -> None:
147
- """Set the callback function to add a new sensor."""
148
- self._new_sensor_callback = callback
149
-
150
- def _publish_new_sensors(self) -> int:
148
+ def _publish_new_sensors(self) -> bool | None:
151
149
  """Schedule all registered callbacks to add new sensors."""
152
- success_count = 0
153
- error_count = 0
154
- for sensor in self._new_sensors[:]:
155
- try:
156
- assert self._new_sensor_callback is not None
157
- if self._new_sensor_callback(sensor) is not True:
158
- raise CCLDataUpdateException("Failed to publish new sensor")
159
- self._new_sensors.remove(sensor)
160
- success_count += 1
161
- except Exception: # pylint: disable=broad-exception-caught
162
- error_count += 1
163
- if error_count > 0:
164
- _LOGGER.warning(
165
- "Failed to add %s sensors for device %s",
166
- error_count,
167
- self.device_id,
168
- )
169
- return success_count
150
+ try:
151
+ assert self._new_sensor_callback is not None
152
+ if self._new_sensor_callback(self._new_sensors) is not True:
153
+ raise CCLDataUpdateException("Failed to publish new sensor")
154
+ except Exception: # pylint: disable=broad-exception-caught
155
+ return None
156
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioccl
3
- Version: 2025.6.8
3
+ Version: 2025.7.1
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
@@ -0,0 +1,10 @@
1
+ aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
2
+ aioccl/device.py,sha256=J-C_ajoORM-tq6g_QmUV95c1B_nFw8piq0S_0lGQjjk,5168
3
+ aioccl/exception.py,sha256=iTukjNcnVXVhGV_sMGj2D1jzjVXB0qcyOlX2vB8G4AY,211
4
+ aioccl/sensor.py,sha256=2HFUGEYPvbWpkHsZwrrCvtCZGrI5ZGEuGuBCPE9W-NQ,16650
5
+ aioccl/server.py,sha256=W8OL64dAi2WAeS4isx8usAG-9D3q4mBIl9pxxb4Iuhw,3573
6
+ aioccl-2025.7.1.dist-info/licenses/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
7
+ aioccl-2025.7.1.dist-info/METADATA,sha256=JcubvaoC6oqknFGPGMj19mN8bHnqi1rMts4U99kgNRs,991
8
+ aioccl-2025.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ aioccl-2025.7.1.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
10
+ aioccl-2025.7.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
2
- aioccl/device.py,sha256=I38yGJVSaChQUgi2InPRweX3s4FXchJQLs4IHv4IdAo,5646
3
- aioccl/exception.py,sha256=iTukjNcnVXVhGV_sMGj2D1jzjVXB0qcyOlX2vB8G4AY,211
4
- aioccl/sensor.py,sha256=2HFUGEYPvbWpkHsZwrrCvtCZGrI5ZGEuGuBCPE9W-NQ,16650
5
- aioccl/server.py,sha256=W8OL64dAi2WAeS4isx8usAG-9D3q4mBIl9pxxb4Iuhw,3573
6
- aioccl-2025.6.8.dist-info/licenses/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
7
- aioccl-2025.6.8.dist-info/METADATA,sha256=IJ9BVcileQWwL2OufRHEgHPf-geY5yQO1ggd9eN2gfc,991
8
- aioccl-2025.6.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- aioccl-2025.6.8.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
10
- aioccl-2025.6.8.dist-info/RECORD,,