aioccl 2024.7.6__tar.gz → 2024.7.7__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-2024.7.6 → aioccl-2024.7.7}/PKG-INFO +1 -1
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl/device.py +23 -10
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl.egg-info/PKG-INFO +1 -1
- {aioccl-2024.7.6 → aioccl-2024.7.7}/setup.py +1 -1
- {aioccl-2024.7.6 → aioccl-2024.7.7}/LICENSE +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/README.md +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl/__init__.py +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl/sensor.py +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl/server.py +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl.egg-info/SOURCES.txt +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl.egg-info/dependency_links.txt +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl.egg-info/requires.txt +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/aioccl.egg-info/top_level.txt +0 -0
- {aioccl-2024.7.6 → aioccl-2024.7.7}/setup.cfg +0 -0
@@ -28,6 +28,7 @@ class CCLDevice:
|
|
28
28
|
self._new_sensors: list[CCLSensor] | None = []
|
29
29
|
|
30
30
|
self._update_callbacks = set()
|
31
|
+
self._new_binary_sensor_callbacks = set()
|
31
32
|
self._new_sensor_callbacks = set()
|
32
33
|
|
33
34
|
@property
|
@@ -72,13 +73,13 @@ class CCLDevice:
|
|
72
73
|
def update_sensors(self, sensors: dict[str, None | str | int | float]) -> None:
|
73
74
|
"""Add or update all sensor values."""
|
74
75
|
for key, value in sensors.items():
|
75
|
-
if CCL_SENSORS
|
76
|
-
if not self._binary_sensors
|
76
|
+
if CCL_SENSORS.get(key).binary:
|
77
|
+
if not key in self._binary_sensors:
|
77
78
|
self._binary_sensors[key] = CCLSensor(key)
|
78
79
|
self._new_sensors.append(self._binary_sensors[key])
|
79
80
|
self._binary_sensors[key].value = value
|
80
81
|
else:
|
81
|
-
if not self._sensors
|
82
|
+
if not key in self._sensors:
|
82
83
|
self._sensors[key] = CCLSensor(key)
|
83
84
|
self._new_sensors.append(self._sensors[key])
|
84
85
|
self._sensors[key].value = value
|
@@ -103,6 +104,14 @@ class CCLDevice:
|
|
103
104
|
except Exception as err:
|
104
105
|
_LOGGER.warning("Error while publishing sensor updates: %s", err)
|
105
106
|
|
107
|
+
def register_new_binary_sensor_cb(self, callback: Callable[[], None]) -> None:
|
108
|
+
"""Register callback, called when Sensor changes state."""
|
109
|
+
self._new_binary_sensor_callbacks.add(callback)
|
110
|
+
|
111
|
+
def remove_new_binary_sensor_cb(self, callback: Callable[[], None]) -> None:
|
112
|
+
"""Remove previously registered callback."""
|
113
|
+
self._new_binary_sensor_callbacks.discard(callback)
|
114
|
+
|
106
115
|
def register_new_sensor_cb(self, callback: Callable[[], None]) -> None:
|
107
116
|
"""Register callback, called when Sensor changes state."""
|
108
117
|
self._new_sensor_callbacks.add(callback)
|
@@ -113,11 +122,15 @@ class CCLDevice:
|
|
113
122
|
|
114
123
|
def _publish_new_sensors(self) -> None:
|
115
124
|
"""Schedule call all registered callbacks."""
|
116
|
-
|
117
|
-
|
125
|
+
for sensor in self._new_sensors:
|
126
|
+
try:
|
118
127
|
_LOGGER.debug("Publishing new sensor: %s", sensor)
|
119
|
-
|
120
|
-
callback
|
121
|
-
|
122
|
-
|
123
|
-
|
128
|
+
if sensor.binary:
|
129
|
+
for callback in self._new_binary_sensor_callbacks:
|
130
|
+
callback(sensor)
|
131
|
+
else:
|
132
|
+
for callback in self._new_sensor_callbacks:
|
133
|
+
callback(sensor)
|
134
|
+
self._new_sensors.remove(sensor)
|
135
|
+
except Exception as err:
|
136
|
+
_LOGGER.warning("Error while publishing new sensors: %s", err)
|
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
|