Skip to content

Commit

Permalink
Tweak 22F4 parser, based upon ClimaRad (#150)
Browse files Browse the repository at this point in the history
* ventura scheme

* typing (akin to 12a0)

* tweak 22F3 regex

* refactor PR for 22F4

* tidy up typed dict

---------

Co-authored-by: Egbert Broerse <dcc2@ebroerse.nl>
  • Loading branch information
zxdavb and silverailscolo authored Oct 19, 2024
1 parent 9826729 commit 225965b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
33 changes: 23 additions & 10 deletions src/ramses_tx/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
SZ_DOMAIN_IDX,
SZ_DURATION,
SZ_FAN_MODE,
SZ_FAN_RATE,
SZ_FAULT_STATE,
SZ_FAULT_TYPE,
SZ_FRAG_LENGTH,
Expand Down Expand Up @@ -1644,20 +1645,32 @@ def parser_22f3(payload: str, msg: Message) -> dict[str, Any]:

# WIP: unknown, HVAC
def parser_22f4(payload: str, msg: Message) -> dict[str, Any]:
# RP --- 32:155617 18:005904 --:------ 22F4 013 00-60-E6-00000000000000-200000
# RP --- 32:153258 18:005904 --:------ 22F4 013 00-60-DD-00000000000000-200000
# RP --- 32:155617 18:005904 --:------ 22F4 013 00-40-B0-00000000000000-200000
# HACK: for dev/test: 37:153226 is ClimaRad Ventura fan/remote
payload = payload[8:14] if msg.src.id == "37:153226" else payload[:6]

# RP --- 32:137185 18:003599 --:------ 22F4 013 00-60-E4-00000000000000-200000
# RP --- 32:137185 18:003599 --:------ 22F4 013 00-60-E5-00000000000000-200000
# RP --- 32:137185 18:003599 --:------ 22F4 013 00-60-E6-00000000000000-200000
MODE_LOOKUP = {
0x00: "off?",
0x20: "paused",
0x40: "auto",
0x60: "manual",
}
mode = int(payload[2:4], 16) & 0x60
assert mode in MODE_LOOKUP, mode

assert payload[:2] == "00"
assert payload[6:] == "00000000000000200000"
RATE_LOOKUP = {
0x00: "speed 0", # "off"?,
0x01: "speed 1", # "low", or trickle?
0x02: "speed 2", # "medium-low", or low?
0x03: "speed 3", # "medium",
0x04: "speed 4", # "medium-high", or high?
0x05: "boost", # "boost", aka purge?
}
rate = int(payload[4:6], 16) & 0x03
assert mode != 0x60 or rate in RATE_LOOKUP, rate

return {
"value_02": payload[2:4],
"value_04": payload[4:6],
SZ_FAN_MODE: MODE_LOOKUP[mode],
SZ_FAN_RATE: RATE_LOOKUP.get(rate),
}


Expand Down
5 changes: 3 additions & 2 deletions src/ramses_tx/ramses.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@
SZ_NAME: "fan_boost",
I_: r"^(00|63)[0-9A-F]{4}([0-9A-F]{8})?$",
}, # minutes only?
Code._22F4: { # unknown_22f4, HVAC, NB: no I
Code._22F4: { # unknown_22f4, HVAC
SZ_NAME: "unknown_22f4",
I_: r"^00[0-9A-F]{24}$",
RQ: r"^00$",
RP: r"^00[0-9A-F]{24}$",
},
Code._22F7: { # fan_bypass_mode (% open), HVAC
SZ_NAME: "fan_bypass_mode",
Expand Down Expand Up @@ -1063,6 +1063,7 @@
Code._1FC9: {W_: {}},
Code._22F1: {},
Code._22F3: {},
Code._22F4: {I_: {}},
Code._22F7: {I_: {}, RP: {}},
Code._2411: {I_: {}, RP: {}},
Code._3120: {I_: {}},
Expand Down
6 changes: 6 additions & 0 deletions src/ramses_tx/typed_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ class _22b0(TypedDict):
enabled: bool


class _22f4(TypedDict): # WIP
fan_mode: str | None
fan_rate: str | None


class _2309(TypedDict):
zone_idx: NotRequired[str]
setpoint: float | None
Expand Down Expand Up @@ -427,6 +432,7 @@ class PayDictT:
_1FC9: TypeAlias = _1fc9
_1FD4: TypeAlias = _1fd4
_22B0: TypeAlias = _22b0
_22F4: TypeAlias = _22f4
_2309: TypeAlias = _2309
_2349: TypeAlias = _2349
_22D9: TypeAlias = _Setpoint
Expand Down
28 changes: 28 additions & 0 deletions tests/tests/parsers/code_22f4.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


#
2024-01-01T01:00:00.000000 ... RP --- 32:153258 18:005904 --:------ 22F4 013 0060DD00000000000000200000 # {'fan_mode': 'manual', 'fan_rate': 'speed 1'}


#
2024-01-01T01:00:00.000000 ... RP --- 32:155617 18:005904 --:------ 22F4 013 0060E600000000000000200000 # {'fan_mode': 'manual', 'fan_rate': 'speed 2'}
2024-01-01T01:00:00.000000 ... RP --- 32:155617 18:005904 --:------ 22F4 013 0040B000000000000000200000 # {'fan_mode': 'auto', 'fan_rate': 'speed 0'}


#
2024-01-01T01:00:00.000000 ... RP --- 32:137185 18:003599 --:------ 22F4 013 0060E400000000000000200000 # {'fan_mode': 'manual', 'fan_rate': 'speed 0'}
2024-01-01T01:00:00.000000 ... RP --- 32:137185 18:003599 --:------ 22F4 013 0060E500000000000000200000 # {'fan_mode': 'manual', 'fan_rate': 'speed 1'}
2024-01-01T01:00:00.000000 ... RP --- 32:137185 18:003599 --:------ 22F4 013 0060E600000000000000200000 # {'fan_mode': 'manual', 'fan_rate': 'speed 2'}


# ClimaRad Ventura V1x, see _22F4_MODE_CLIMARAD
2024-10-15T13:12:46.635997 000 RQ --- 18:130140 37:153226 --:------ 22F4 001 00 # {}
2024-10-15T13:12:46.657580 061 RP --- 37:153226 18:130140 --:------ 22F4 013 00403000000000000000000000 # {'fan_mode': 'off?', 'fan_rate': 'speed 0'}
# (SAME PAYLOAD) appears that payload may be an array? now/next? input/output? other?
2024-10-15T13:12:46.657580 061 RP --- 37:000001 18:130140 --:------ 22F4 013 00403000000000000000000000 # {'fan_mode': 'auto', 'fan_rate': 'speed 0'}

2024-01-01T01:00:00.000000 ... I --- 37:153226 --:------ 37:153226 22F4 013 00403000000000000000000000 # {'fan_mode': 'off?', 'fan_rate': 'speed 0'}
2024-01-01T01:00:00.000000 ... I --- 37:153226 --:------ 37:153226 22F4 013 000000000060C9000000000000 # {'fan_mode': 'manual', 'fan_rate': 'speed 1'}
2024-01-01T01:00:00.000000 ... I --- 37:153226 --:------ 37:153226 22F4 013 000000000060CA000000000000 # {'fan_mode': 'manual', 'fan_rate': 'speed 2'}
2024-01-01T01:00:00.000000 ... I --- 37:153226 --:------ 37:153226 22F4 013 000000000060CB000000000000 # {'fan_mode': 'manual', 'fan_rate': 'speed 3'}
2024-01-01T01:00:00.000000 ... I --- 37:153226 --:------ 37:153226 22F4 013 00200000002000000000000000 # {'fan_mode': 'paused', 'fan_rate': 'speed 0'}

0 comments on commit 225965b

Please sign in to comment.