aiocomfoconnect 0.4.0__tar.gz → 0.4.2__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: aiocomfoconnect
3
- Version: 0.4.0
3
+ Version: 0.4.2
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
@@ -280,6 +280,21 @@ class ComfoConnect(Bridge):
280
280
  raise AioComfoConnectNotConnected("Not connected to bridge")
281
281
  return super().cmd_rmi_request(message, node_id)
282
282
 
283
+ async def _send(self, request, request_type, params: dict = None, reply: bool = True, timeout: float = None) -> Message:
284
+ """Send a request, and close the connection when the bridge dropped our session.
285
+
286
+ The bridge can drop our session without closing the connection, e.g. when another app takes over a session with our
287
+ uuid. It then answers every request with NOT_ALLOWED (or OTHER_SESSION). Closing the connection lets the reconnect
288
+ loop start a new session. The request still raises its error.
289
+ """
290
+ try:
291
+ return await super()._send(request, request_type, params, reply, timeout)
292
+ except (ComfoConnectNotAllowed, ComfoConnectOtherSession):
293
+ if self._connection_state == ConnectionState.CONNECTED and self._writer is not None:
294
+ _LOGGER.warning("The bridge dropped our session, reconnecting")
295
+ self._writer.close()
296
+ raise
297
+
283
298
  async def disconnect(self):
284
299
  """Disconnect from the bridge and stop reconnecting. A connect() that is still busy fails."""
285
300
  _LOGGER.debug("Stopping reconnection and disconnecting")
@@ -418,7 +433,8 @@ class ComfoConnect(Bridge):
418
433
 
419
434
  sensor = self._sensors.get(sensor_id)
420
435
  if sensor is None:
421
- _LOGGER.error("Unknown sensor id: %s", sensor_id)
436
+ # After a quick reconnect, the bridge can still push the sensors of our previous session before we subscribe again.
437
+ _LOGGER.debug("Ignoring a value for sensor %s, that we are not subscribed to", sensor_id)
422
438
  return
423
439
 
424
440
  self._sensors_values[sensor_id] = sensor_value
@@ -2,6 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from .protobuf import zehnder_pb2
6
+
5
7
 
6
8
  class AioComfoConnectError(Exception):
7
9
  """Base class for all errors raised by aiocomfoconnect."""
@@ -12,7 +14,13 @@ class ComfoConnectError(AioComfoConnectError):
12
14
 
13
15
  def __init__(self, message):
14
16
  cmd = getattr(message, "cmd", None)
15
- super().__init__((cmd.resultDescription or f"reference {cmd.reference}") if cmd else str(message))
17
+ if cmd is None:
18
+ text = str(message)
19
+ else:
20
+ result = zehnder_pb2.GatewayOperation.GatewayResult.Name(cmd.result) # pylint: disable=no-member
21
+ description = f": {cmd.resultDescription}" if cmd.resultDescription else ""
22
+ text = f"{result}{description} (reference {cmd.reference})"
23
+ super().__init__(text)
16
24
  self.message = message
17
25
 
18
26
 
@@ -66,6 +66,7 @@ SENSOR_POWER_USAGE_TOTAL_YEAR = 129
66
66
  SENSOR_PREHEATER_POWER = 146
67
67
  SENSOR_PREHEATER_POWER_TOTAL = 145
68
68
  SENSOR_PREHEATER_POWER_TOTAL_YEAR = 144
69
+ SENSOR_PRESET_TIMERS = 337 # The running timers of the preset schedule, as a bit set: bit 6 is boost, bit 11 is away.
69
70
  SENSOR_PROFILE_TEMPERATURE = 67
70
71
  SENSOR_RF_PAIRING_MODE = 176
71
72
  SENSOR_RMOT = 209
@@ -81,6 +82,16 @@ SENSOR_UNIT_TEMPERATURE = 208
81
82
  SENSOR_COMFOCOOL_STATE = 784
82
83
  SENSOR_COMFOCOOL_CONDENSOR_TEMP = 802
83
84
 
85
+ # The CO2 level of the CO2 sensors (ProductId.CO2SENSOR) in zone 1: SENSOR_CO2_1 is the one with the lowest node id.
86
+ SENSOR_CO2_1 = 1024
87
+ SENSOR_CO2_2 = 1025
88
+ SENSOR_CO2_3 = 1026
89
+ SENSOR_CO2_4 = 1027
90
+ SENSOR_CO2_5 = 1028
91
+ SENSOR_CO2_6 = 1029
92
+ SENSOR_CO2_7 = 1030
93
+ SENSOR_CO2_8 = 1031
94
+
84
95
  # ComfoClime sensors. These are only reported when a ComfoClime is present on the ComfoNet bus.
85
96
  SENSOR_COMFOCLIME_TPMA_TEMPERATURE = 4145
86
97
  SENSOR_COMFOCLIME_TARGET_TEMPERATURE = 4148
@@ -102,6 +113,7 @@ UNIT_CELCIUS = "°C"
102
113
  UNIT_PERCENT = "%"
103
114
  UNIT_RPM = "rpm"
104
115
  UNIT_M3H = "m³/h"
116
+ UNIT_PPM = "ppm"
105
117
 
106
118
 
107
119
  @dataclass
@@ -184,7 +196,7 @@ SENSORS: Dict[int, Sensor] = {
184
196
  Sensor("Supply Air Humidity", UNIT_PERCENT, SENSOR_HUMIDITY_SUPPLY, PdoType.TYPE_CN_UINT8),
185
197
  Sensor("sensor_321", None, 321, PdoType.TYPE_CN_UINT16),
186
198
  Sensor("sensor_325", None, 325, PdoType.TYPE_CN_UINT16),
187
- Sensor("sensor_337", None, 337, PdoType.TYPE_CN_UINT32),
199
+ Sensor("Preset Timers", None, SENSOR_PRESET_TIMERS, PdoType.TYPE_CN_UINT32),
188
200
  Sensor("Bypass Override", None, SENSOR_BYPASS_OVERRIDE, PdoType.TYPE_CN_UINT32),
189
201
  Sensor("sensor_341", None, 341, PdoType.TYPE_CN_UINT32),
190
202
  Sensor("Supply Fan Mode (running timers)", None, SENSOR_FAN_MODE_SUPPLY_3, PdoType.TYPE_CN_UINT32),
@@ -205,6 +217,14 @@ SENSORS: Dict[int, Sensor] = {
205
217
  Sensor("ComfoCool State", None, SENSOR_COMFOCOOL_STATE, PdoType.TYPE_CN_UINT8),
206
218
  Sensor("sensor_785", None, 785, PdoType.TYPE_CN_BOOL, bool),
207
219
  Sensor("ComfoCool Condensor Temperature", UNIT_CELCIUS, SENSOR_COMFOCOOL_CONDENSOR_TEMP, PdoType.TYPE_CN_INT16, lambda x: x / 10),
220
+ Sensor("CO2 Sensor 1", UNIT_PPM, SENSOR_CO2_1, PdoType.TYPE_CN_UINT16),
221
+ Sensor("CO2 Sensor 2", UNIT_PPM, SENSOR_CO2_2, PdoType.TYPE_CN_UINT16),
222
+ Sensor("CO2 Sensor 3", UNIT_PPM, SENSOR_CO2_3, PdoType.TYPE_CN_UINT16),
223
+ Sensor("CO2 Sensor 4", UNIT_PPM, SENSOR_CO2_4, PdoType.TYPE_CN_UINT16),
224
+ Sensor("CO2 Sensor 5", UNIT_PPM, SENSOR_CO2_5, PdoType.TYPE_CN_UINT16),
225
+ Sensor("CO2 Sensor 6", UNIT_PPM, SENSOR_CO2_6, PdoType.TYPE_CN_UINT16),
226
+ Sensor("CO2 Sensor 7", UNIT_PPM, SENSOR_CO2_7, PdoType.TYPE_CN_UINT16),
227
+ Sensor("CO2 Sensor 8", UNIT_PPM, SENSOR_CO2_8, PdoType.TYPE_CN_UINT16),
208
228
  Sensor("ComfoClime TPMA Temperature", UNIT_CELCIUS, SENSOR_COMFOCLIME_TPMA_TEMPERATURE, PdoType.TYPE_CN_INT16, lambda x: x / 10),
209
229
  Sensor("ComfoClime Target Temperature", UNIT_CELCIUS, SENSOR_COMFOCLIME_TARGET_TEMPERATURE, PdoType.TYPE_CN_INT16, lambda x: x / 10),
210
230
  Sensor("ComfoClime Device Mode", None, SENSOR_COMFOCLIME_DEVICE_MODE, PdoType.TYPE_CN_UINT8),
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "aiocomfoconnect"
3
- version = "0.4.0"
3
+ version = "0.4.2"
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