diff --git a/src/ramses_tx/helpers.py b/src/ramses_tx/helpers.py index 26288701..b092df29 100644 --- a/src/ramses_tx/helpers.py +++ b/src/ramses_tx/helpers.py @@ -37,6 +37,7 @@ SZ_OUTDOOR_TEMP, SZ_POST_HEAT, SZ_PRE_HEAT, + SZ_REL_HUMIDITY, SZ_REMAINING_MINS, SZ_SPEED_CAPABILITIES, SZ_SUPPLY_FAN_SPEED, @@ -537,6 +538,20 @@ def parse_co2_level(value: HexStr4) -> PayDictT.CO2_LEVEL: return {SZ_CO2_LEVEL: level} +def parse_humidity_element(value: str, index: str) -> PayDictT._12A0: + """Return the relative humidity (%) and 2 temperatures + + The result may include current temperature ('C) and include dewpoint temperature ('C). + """ + if index == "01": + return _parse_hvac_humidity(SZ_REL_HUMIDITY, value[:2], value[2:6], value[6:10]) # type: ignore[return-value] + if index == "02": + return _parse_hvac_humidity( + SZ_OUTDOOR_HUMIDITY, value[:2], value[2:6], value[6:10] + ) # type: ignore[return-value] + return _parse_hvac_humidity(SZ_INDOOR_HUMIDITY, value[:2], value[2:6], value[6:10]) # type: ignore[return-value] + + # 31DA[10:12] and 12A0[2:12] def parse_indoor_humidity(value: str) -> PayDictT.INDOOR_HUMIDITY: """Return the relative indoor humidity (%). diff --git a/src/ramses_tx/parsers.py b/src/ramses_tx/parsers.py index 780fb873..5ba04fd7 100644 --- a/src/ramses_tx/parsers.py +++ b/src/ramses_tx/parsers.py @@ -106,6 +106,7 @@ parse_exhaust_temp, parse_fan_info, parse_fault_log_entry, + parse_humidity_element, parse_indoor_humidity, parse_indoor_temp, parse_outdoor_humidity, @@ -1120,9 +1121,20 @@ def parser_1298(payload: str, msg: Message) -> PayDictT._1298: return parse_co2_level(payload[2:6]) -# HVAC: indoor_humidity -def parser_12a0(payload: str, msg: Message) -> PayDictT._12A0: - return parse_indoor_humidity(payload[2:]) +# HVAC: indoor_humidity, array of 3 sets for HRU +def parser_12a0( + payload: str, msg: Message +) -> PayDictT.INDOOR_HUMIDITY | list[PayDictT._12A0]: + if len(payload) <= 14: + return parse_indoor_humidity(payload[2:12]) + + return [ + { + "hvac_idx": payload[i : i + 2], + **parse_humidity_element(payload[i + 2 : i + 12], payload[i : i + 2]), + } + for i in range(0, len(payload), 14) + ] # window_state (of a device/zone) diff --git a/src/ramses_tx/ramses.py b/src/ramses_tx/ramses.py index afa951ab..2b591a3e 100644 --- a/src/ramses_tx/ramses.py +++ b/src/ramses_tx/ramses.py @@ -279,12 +279,9 @@ RQ: r"^00$", }, Code._12A0: { # indoor_humidity - # .I --- 32:168090 --:------ 32:168090 12A0 006 0030093504A8 - # .I --- 32:132125 --:------ 32:132125 12A0 007 003107B67FFF00 # only dev_id with 007 - # RP --- 20:008749 18:142609 --:------ 12A0 002 00EF SZ_NAME: "indoor_humidity", - I_: r"^00[0-9A-F]{2}([0-9A-F]{8}(00)?)?$", - RP: r"^00[0-9A-F]{2}([0-9A-F]{8}(00)?)?$", + I_: r"^(0[0-9A-F]{3}([0-9A-F]{8}(00)?)?)+$", + RP: r"^0[0-9A-F]{3}([0-9A-F]{8}(00)?)?$", SZ_LIFESPAN: td(hours=1), }, Code._12B0: { # window_state (HVAC % window open) diff --git a/src/ramses_tx/typed_dicts.py b/src/ramses_tx/typed_dicts.py index 2b2a2eba..0eba4290 100644 --- a/src/ramses_tx/typed_dicts.py +++ b/src/ramses_tx/typed_dicts.py @@ -67,6 +67,12 @@ class Co2Level(TypedDict): co2_level: float | None +class RelativeHumidity(TypedDict): + relative_humidity: _HexToTempT + temperature: NotRequired[float | None] + dewpoint_temp: NotRequired[float | None] + + class IndoorHumidity(TypedDict): indoor_humidity: _HexToTempT temperature: NotRequired[float | None] @@ -255,6 +261,15 @@ class _1100_IDX(TypedDict): domain_id: str +class _12a0(TypedDict): + hvac_idx: str + indoor_humidity: NotRequired[_HexToTempT | None] + outdoor_humidity: NotRequired[_HexToTempT | None] + relative_humidity: NotRequired[_HexToTempT | None] + temperature: NotRequired[float | None] + dewpoint_temp: NotRequired[float | None] + + class _12b0(TypedDict): window_open: bool | None @@ -421,7 +436,7 @@ class PayDictT: _1280: TypeAlias = OutdoorHumidity _1290: TypeAlias = OutdoorTemp _1298: TypeAlias = Co2Level - _12A0: TypeAlias = IndoorHumidity + _12A0: TypeAlias = _12a0 _12B0: TypeAlias = _12b0 _12C0: TypeAlias = _12c0 _12C8: TypeAlias = AirQuality @@ -453,6 +468,9 @@ class PayDictT: FAULT_LOG_ENTRY_NULL: TypeAlias = FaultLogEntryNull TEMPERATURE: TypeAlias = _Temperature + # 12A0 primitive + RELATIVE_HUMIDITY: TypeAlias = RelativeHumidity + # 31DA primitives AIR_QUALITY: TypeAlias = AirQuality CO2_LEVEL: TypeAlias = Co2Level diff --git a/tests/tests/parsers/code_12a0.log b/tests/tests/parsers/code_12a0.log index f8d9c428..021f4e80 100644 --- a/tests/tests/parsers/code_12a0.log +++ b/tests/tests/parsers/code_12a0.log @@ -1,5 +1,6 @@ 2021-02-12T20:59:47.225210 066 RP --- 20:008749 18:142609 --:------ 12A0 002 00EF # {'indoor_humidity': None} +2024-10-15T12:41:34.415872 075 I --- 29:099029 --:------ 29:099029 12A0 002 0031 # {'indoor_humidity': 0.49} 2022-03-08T11:24:21.138647 076 I --- 29:146052 --:------ 29:146052 12A0 006 00220685004C # {'indoor_humidity': 0.34, 'temperature': 16.69, 'dewpoint_temp': 0.76} @@ -7,3 +8,18 @@ 2022-08-17T02:29:36.718767 056 I --- 32:155617 --:------ 32:155617 12A0 007 003C096E7FFF00 # {'indoor_humidity': 0.60, 'temperature': 24.14, 'dewpoint_temp': None} 2019-12-16T05:19:20.630177 072 I --- 32:168090 --:------ 32:168090 12A0 006 003C06DE03E3 # {'indoor_humidity': 0.60, 'temperature': 17.58, 'dewpoint_temp': 9.95} + +# ClimaRad VenturaV1x array of 3 Indoor_Humidity sets for HRU: Flow In (no dewpoint), Flow Out, Item_3 + +2024-10-15T12:33:21.828292 060 I --- 37:153226 --:------ 37:153226 12A0 021 003307DD7FFF0001EF7FFF7FFF00023E056B02A600 # [{'hvac_idx': '00', 'indoor_humidity': 0.51, 'temperature': 20.13, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.62, 'temperature': 13.87, 'dewpoint_temp': 6.78}] +2024-10-15T12:38:22.145126 060 I --- 37:153226 --:------ 37:153226 12A0 021 003207D27FFF0001EF7FFF7FFF00023F057B02D200 # [{'hvac_idx': '00', 'indoor_humidity': 0.5, 'temperature': 20.02, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.63, 'temperature': 14.03, 'dewpoint_temp': 7.22}] +2024-10-15T12:48:22.825444 060 I --- 37:153226 --:------ 37:153226 12A0 021 003107E47FFF0001EF7FFF7FFF00023E05A802D900 # [{'hvac_idx': '00', 'indoor_humidity': 0.49, 'temperature': 20.2, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.62, 'temperature': 14.48, 'dewpoint_temp': 7.29}] +2024-10-15T13:25:35.121534 062 I --- 37:153226 --:------ 37:153226 12A0 021 0034080C7FFF0001EF7FFF7FFF00023B05C002AF00 # [{'hvac_idx': '00', 'indoor_humidity': 0.52, 'temperature': 20.6, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.59, 'temperature': 14.72, 'dewpoint_temp': 6.87}] +2024-10-15T15:59:04.943042 061 I --- 37:153226 --:------ 37:153226 12A0 021 0033088F7FFF0001EF7FFF7FFF000237065C02D900 # [{'hvac_idx': '00', 'indoor_humidity': 0.51, 'temperature': 21.91, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.55, 'temperature': 16.28, 'dewpoint_temp': 7.29}] +2024-10-15T23:50:36.119335 074 I --- 37:153226 --:------ 37:153226 12A0 021 002B08137FFF0001EF7FFF7FFF00023D05A102CE00 # [{'hvac_idx': '00', 'indoor_humidity': 0.43, 'temperature': 20.67, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.61, 'temperature': 14.41, 'dewpoint_temp': 7.18}] +2024-10-18T13:40:19.208645 067 I --- 37:153226 --:------ 37:153226 12A0 021 0042081D7FFF0001EF7FFF7FFF00024D079205FF00 # [{'hvac_idx': '00', 'indoor_humidity': 0.66, 'temperature': 20.77, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.77, 'temperature': 19.38, 'dewpoint_temp': 15.35}] +2024-10-18T15:45:27.762626 067 I --- 37:153226 --:------ 37:153226 12A0 021 004408327FFF0001EF7FFF7FFF00024707EF05DE00 # [{'hvac_idx': '00', 'indoor_humidity': 0.68, 'temperature': 20.98, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.71, 'temperature': 20.31, 'dewpoint_temp': 15.02}] +2024-10-18T15:50:28.112562 067 I --- 37:153226 --:------ 37:153226 12A0 021 004408377FFF0001EF7FFF7FFF00024707F705E000 # [{'hvac_idx': '00', 'indoor_humidity': 0.68, 'temperature': 21.03, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.71, 'temperature': 20.39, 'dewpoint_temp': 15.04}] +2024-10-18T01:13:47.417683 064 I --- 37:153226 --:------ 37:153226 12A0 021 003F08077FFF0001EF7FFF7FFF00024E06D6055D00 # [{'hvac_idx': '00', 'indoor_humidity': 0.63, 'temperature': 20.55, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.78, 'temperature': 17.5, 'dewpoint_temp': 13.73}] +2024-10-20T15:01:12.576913 072 I --- 37:153226 --:------ 37:153226 12A0 021 0041078D7FFF0001EF7FFF7FFF0002470751054000 # [{'hvac_idx': '00', 'indoor_humidity': 0.65, 'temperature': 19.33, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.71, 'temperature': 18.73, 'dewpoint_temp': 13.44}] +2024-10-21T13:49:35.480133 060 I --- 37:153226 --:------ 37:153226 12A0 021 004108027FFF0001EF7FFF7FFF00024E06E1056500 # [{'hvac_idx': '00', 'indoor_humidity': 0.65, 'temperature': 20.5, 'dewpoint_temp': None}, {'hvac_idx': '01', 'rel_humidity': None}, {'hvac_idx': '02', 'outdoor_humidity': 0.78, 'temperature': 17.61, 'dewpoint_temp': 13.81}]