aiocomfoconnect 0.4.3__tar.gz → 0.4.4__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.
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/PKG-INFO +3 -2
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/README.md +2 -1
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/bridge.py +4 -2
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/comfoconnect.py +29 -12
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/pyproject.toml +1 -1
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/LICENSE +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/__init__.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/__main__.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/const.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/discovery.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/exceptions.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/properties.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/protobuf/nanopb_pb2.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/protobuf/zehnder_pb2.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/sensors.py +0 -0
- {aiocomfoconnect-0.4.3 → aiocomfoconnect-0.4.4}/aiocomfoconnect/util.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aiocomfoconnect
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: aiocomfoconnect is an asyncio Python 3 library for communicating with a Zehnder ComfoAir Q350/450/600 ventilation system
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -63,11 +63,12 @@ $ python -m aiocomfoconnect set-property --host 192.168.1.213 30 1 4 6 120 # Se
|
|
|
63
63
|
|
|
64
64
|
## Available methods
|
|
65
65
|
|
|
66
|
-
- `async connect()`: Connect to the bridge. The connection is kept: when it is lost, it reconnects, and when nothing was received for `heartbeat_interval` seconds (30 by default, `None` disables it), it
|
|
66
|
+
- `async connect()`: Connect to the bridge. The connection is kept: when it is lost, it reconnects, and when nothing was sent or received for `heartbeat_interval` seconds (30 by default, `None` disables it), it asks the bridge for its time. That keeps the bridge from closing the connection (it does so after about 90 seconds in which the client sent nothing, even while it pushes sensor values), and detects a bridge that stopped answering.
|
|
67
67
|
- `connection_state_callback`: Pass it to `ComfoConnect()` to be called with a `ConnectionState` when the state of the session changes.
|
|
68
68
|
- `async disconnect()`: Disconnect from the bridge.
|
|
69
69
|
- `async register_sensor(sensor)`: Register a sensor.
|
|
70
70
|
- `async deregister_sensor(sensor)`: Deregister a sensor.
|
|
71
|
+
- `sensor_values`: The latest value of every registered sensor, by sensor id, converted like for the sensor callback (`None` until the bridge sent one).
|
|
71
72
|
- `async get_mode()`: Get the ventilation mode.
|
|
72
73
|
- `async set_mode(mode)`: Set the ventilation mode. (auto / manual) Selecting `auto` also cancels the temporary fan-speed override and returns control to the unit's schedule.
|
|
73
74
|
- `async get_comfocool_mode()`: Get Comfocool mode
|
|
@@ -45,11 +45,12 @@ $ python -m aiocomfoconnect set-property --host 192.168.1.213 30 1 4 6 120 # Se
|
|
|
45
45
|
|
|
46
46
|
## Available methods
|
|
47
47
|
|
|
48
|
-
- `async connect()`: Connect to the bridge. The connection is kept: when it is lost, it reconnects, and when nothing was received for `heartbeat_interval` seconds (30 by default, `None` disables it), it
|
|
48
|
+
- `async connect()`: Connect to the bridge. The connection is kept: when it is lost, it reconnects, and when nothing was sent or received for `heartbeat_interval` seconds (30 by default, `None` disables it), it asks the bridge for its time. That keeps the bridge from closing the connection (it does so after about 90 seconds in which the client sent nothing, even while it pushes sensor values), and detects a bridge that stopped answering.
|
|
49
49
|
- `connection_state_callback`: Pass it to `ComfoConnect()` to be called with a `ConnectionState` when the state of the session changes.
|
|
50
50
|
- `async disconnect()`: Disconnect from the bridge.
|
|
51
51
|
- `async register_sensor(sensor)`: Register a sensor.
|
|
52
52
|
- `async deregister_sensor(sensor)`: Deregister a sensor.
|
|
53
|
+
- `sensor_values`: The latest value of every registered sensor, by sensor id, converted like for the sensor callback (`None` until the bridge sent one).
|
|
53
54
|
- `async get_mode()`: Get the ventilation mode.
|
|
54
55
|
- `async set_mode(mode)`: Set the ventilation mode. (auto / manual) Selecting `auto` also cancels the temporary fan-speed override and returns control to the unit's schedule.
|
|
55
56
|
- `async get_comfocool_mode()`: Get Comfocool mode
|
|
@@ -119,8 +119,9 @@ class Bridge:
|
|
|
119
119
|
self.__alarm_callback_fn: Optional[Callable[[int, ProtobufMessage], None]] = None
|
|
120
120
|
|
|
121
121
|
self._read_task = None
|
|
122
|
-
# The time.monotonic() of the last message we received from the bridge.
|
|
122
|
+
# The time.monotonic() of the last message we received from the bridge, and of the last one we sent.
|
|
123
123
|
self._last_received: float = 0
|
|
124
|
+
self._last_sent: float = 0
|
|
124
125
|
|
|
125
126
|
def __repr__(self):
|
|
126
127
|
return f"<Bridge {self.host}, UID={self.uuid}>"
|
|
@@ -182,7 +183,7 @@ class Bridge:
|
|
|
182
183
|
|
|
183
184
|
self._reference = itertools.count(1)
|
|
184
185
|
self._local_uuid = uuid
|
|
185
|
-
self._last_received = time.monotonic()
|
|
186
|
+
self._last_received = self._last_sent = time.monotonic()
|
|
186
187
|
self._pending = {}
|
|
187
188
|
|
|
188
189
|
# The bridge announces its nodes at the start of every session, so forget what we knew.
|
|
@@ -407,6 +408,7 @@ class Bridge:
|
|
|
407
408
|
try:
|
|
408
409
|
self._writer.write(message.encode())
|
|
409
410
|
await self._writer.drain()
|
|
411
|
+
self._last_sent = time.monotonic()
|
|
410
412
|
except (ConnectionError, OSError) as exc:
|
|
411
413
|
_LOGGER.warning("Failed to send message: %s", exc)
|
|
412
414
|
raise AioComfoConnectNotConnected("Connection lost while sending") from exc
|
|
@@ -96,6 +96,11 @@ def _decode_value(property_type: Optional[int], raw: bytes) -> Any:
|
|
|
96
96
|
return raw
|
|
97
97
|
|
|
98
98
|
|
|
99
|
+
def _sensor_value(sensor: Sensor, raw: int) -> Any:
|
|
100
|
+
"""Convert the raw value of a sensor."""
|
|
101
|
+
return sensor.value_fn(raw) if sensor.value_fn else round(raw, 2)
|
|
102
|
+
|
|
103
|
+
|
|
99
104
|
def _property_value(prop: Property, value: Any) -> Any:
|
|
100
105
|
"""Return the option or the scaled value of a decoded property value."""
|
|
101
106
|
if prop.options is None:
|
|
@@ -145,8 +150,9 @@ class ComfoConnect(Bridge):
|
|
|
145
150
|
):
|
|
146
151
|
"""Initialize the ComfoConnect class.
|
|
147
152
|
|
|
148
|
-
When we received nothing for heartbeat_interval seconds, we ask the bridge for its time, and reconnect when
|
|
149
|
-
doesn't answer. This
|
|
153
|
+
When we sent or received nothing for heartbeat_interval seconds, we ask the bridge for its time, and reconnect when
|
|
154
|
+
it doesn't answer. This keeps the bridge from closing a connection on which we send nothing, and detects a bridge
|
|
155
|
+
that stopped answering without closing the connection. None disables it.
|
|
150
156
|
|
|
151
157
|
The connection_state_callback is called with a ConnectionState when the state of the session changes.
|
|
152
158
|
"""
|
|
@@ -285,10 +291,15 @@ class ComfoConnect(Bridge):
|
|
|
285
291
|
_LOGGER.info("Reconnect loop stopped")
|
|
286
292
|
|
|
287
293
|
async def _wait_for_disconnect(self):
|
|
288
|
-
"""Wait until the connection is lost, or until the bridge doesn't answer the heartbeat.
|
|
294
|
+
"""Wait until the connection is lost, or until the bridge doesn't answer the heartbeat.
|
|
295
|
+
|
|
296
|
+
The heartbeat asks the bridge for its time when we sent or received nothing for heartbeat_interval seconds. The
|
|
297
|
+
bridge closes a connection on which we sent nothing for about 90 seconds, also while it pushes sensor values, and a
|
|
298
|
+
bridge that stopped answering doesn't send anything.
|
|
299
|
+
"""
|
|
289
300
|
# The read task ends when the connection is lost. It has already logged why.
|
|
290
301
|
while not self._read_task.done():
|
|
291
|
-
idle = time.monotonic() - self._last_received
|
|
302
|
+
idle = time.monotonic() - min(self._last_sent, self._last_received)
|
|
292
303
|
if self.heartbeat_interval is None or idle < self.heartbeat_interval:
|
|
293
304
|
timeout = None if self.heartbeat_interval is None else self.heartbeat_interval - idle
|
|
294
305
|
await asyncio.wait([self._read_task], timeout=timeout)
|
|
@@ -302,6 +313,18 @@ class ComfoConnect(Bridge):
|
|
|
302
313
|
_LOGGER.warning("The bridge did not answer the heartbeat")
|
|
303
314
|
return
|
|
304
315
|
|
|
316
|
+
@property
|
|
317
|
+
def sensor_values(self) -> Dict[int, Any]:
|
|
318
|
+
"""The latest value of every subscribed sensor, by sensor id, converted like for the sensor callback.
|
|
319
|
+
|
|
320
|
+
A value is None until the bridge sent one. Right after subscribing, it can be the invalid value that the bridge
|
|
321
|
+
sends first, which the sensor callback holds back (see sensor_delay).
|
|
322
|
+
"""
|
|
323
|
+
return {
|
|
324
|
+
sensor_id: None if self._sensors_values.get(sensor_id) is None else _sensor_value(sensor, self._sensors_values[sensor_id])
|
|
325
|
+
for sensor_id, sensor in self._sensors.items()
|
|
326
|
+
}
|
|
327
|
+
|
|
305
328
|
@property
|
|
306
329
|
def connection_state(self) -> str:
|
|
307
330
|
"""The state of the session, one of ConnectionState. Unlike is_connected(), this is only CONNECTED once the session is up."""
|
|
@@ -520,9 +543,6 @@ class ComfoConnect(Bridge):
|
|
|
520
543
|
|
|
521
544
|
def _sensor_callback(self, sensor_id, sensor_value):
|
|
522
545
|
"""Callback function for sensor updates."""
|
|
523
|
-
if self._sensor_callback_fn is None:
|
|
524
|
-
return
|
|
525
|
-
|
|
526
546
|
sensor = self._sensors.get(sensor_id)
|
|
527
547
|
if sensor is None:
|
|
528
548
|
# After a quick reconnect, the bridge can still push the sensors of our previous session before we subscribe again.
|
|
@@ -540,11 +560,8 @@ class ComfoConnect(Bridge):
|
|
|
540
560
|
_LOGGER.debug("Got a valid value for sensor %s, releasing the hold", sensor_id)
|
|
541
561
|
self._sensor_holds.pop(sensor_id).cancel()
|
|
542
562
|
|
|
543
|
-
if
|
|
544
|
-
|
|
545
|
-
else:
|
|
546
|
-
val = round(sensor_value, 2)
|
|
547
|
-
self._sensor_callback_fn(sensor, val)
|
|
563
|
+
if self._sensor_callback_fn is not None:
|
|
564
|
+
self._sensor_callback_fn(sensor, _sensor_value(sensor, sensor_value))
|
|
548
565
|
|
|
549
566
|
def _alarm_callback(self, node_id, alarm):
|
|
550
567
|
"""Callback function for alarm updates."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "aiocomfoconnect"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.4"
|
|
4
4
|
description = "aiocomfoconnect is an asyncio Python 3 library for communicating with a Zehnder ComfoAir Q350/450/600 ventilation system"
|
|
5
5
|
authors = ["Michaël Arnauts <michael.arnauts@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
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
|
|
File without changes
|