Skip to content

Commit

Permalink
Ventura filter counter parsed as % only
Browse files Browse the repository at this point in the history
  • Loading branch information
silverailscolo committed Oct 16, 2024
1 parent affa23f commit 1ea90be
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
37 changes: 0 additions & 37 deletions src/ramses_tx/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,43 +983,6 @@ def parser_10d0(payload: str, msg: Message) -> dict[str, Any]:

result: dict[str, bool | float | None]

if msg.verb == W_:
result = {"reset_counter": payload[2:4] == "FF"}
else:
result = {"days_remaining": int(payload[2:4], 16)}

if msg.len >= 3:
result.update({"days_lifetime": int(payload[4:6], 16)})

if msg.len >= 4:
result.update({"percent_remaining": hex_to_percent(payload[6:8])})
if (
payload[2:4] == payload[4:6]
): # seen on ClimaRad VenturaV1x 2021, calculate days_remaining
result.update(
{
"days_remaining": int(
int(payload[2:4], 16) * (hex_to_percent(payload[6:8]) or 0)
)
}
)
result: dict[str, bool | float | None]

if msg.verb == W_:
return {"reset_counter": payload[2:4] != "00"}

result = {}

if payload[2:4] not in ("FF", "FE"):
result["days_remaining"] = int(payload[2:4], 16)

if payload[4:6] not in ("FF", "FE"):
result["days_lifetime"] = int(payload[4:6], 16)

result["percent_remaining"] = hex_to_percent(payload[6:8])

result: dict[str, bool | float | None]

if msg.verb == W_:
return {"reset_counter": payload[2:4] != "00"}

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/parsers/code_10d0.log
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
2024-10-15 12:33:55.609000 --- RP --- 32:022222 18:130140 --:------ 10D0 006 00A9B6B90000 # {'days_remaining': 169, 'days_lifetime': 182, 'percent_remaining': 0.925}

2024-10-15T12:33:13.714200 000 RQ --- 18:130140 37:153226 --:------ 10D0 001 00 # {}
2024-10-15T12:33:13.731547 060 RP --- 37:153226 18:130140 --:------ 10D0 006 00FEFE79FFFF # {'days_remaining': 153, 'days_lifetime': 254, 'percent_remaining': 0.605}
2024-10-15T12:33:13.731547 060 RP --- 37:153226 18:130140 --:------ 10D0 006 00FEFE79FFFF # {'percent_remaining': 0.605}

2022-07-03T23:14:23.854089 000 RQ --- 37:155617 32:155617 --:------ 10D0 002 0000 # {}
2022-07-03T23:14:23.876088 084 RP --- 32:155617 37:155617 --:------ 10D0 006 00B4B4C80000 # {'days_remaining': 180, 'days_lifetime': 180, 'percent_remaining': 1.000}
Expand Down

0 comments on commit 1ea90be

Please sign in to comment.