Skip to content

Commit 7841384

Browse files
committed
Only trust/use water reports from new firmware
1 parent e69d1a8 commit 7841384

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/powersensor_local/xlatemsg.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,23 @@ def _make_summation_energy_event(message: dict):
5454
def _make_average_flow_event(message: dict):
5555
ev = {}
5656
_pick_list(ev, message, _MAC_TS_ROLE)
57+
# Old firmware not providing averge_flow don't account for meter scaling,
58+
# so the reported flow is likely wrong. To avoid displaying incorrect data
59+
# we only accept the newer average_new field.
5760
_pick_list(ev, message, [
61+
('average_flow', 'litres_per_minute', True, 3),
5862
('duration', 'duration_s', True, 3),
5963
])
60-
# report is in cl/min
61-
ev['litres_per_minute'] = round(float(message['power'])/100.0, 3)
6264
return ev
6365

6466
def _make_summation_volume_event(message: dict):
6567
ev = {}
6668
_pick_list(ev, message, _MAC_TS_ROLE)
69+
# Old firmware not providing summation_volume don't account for meter
70+
# scaling, so the reported summation is likely wrong. To avoid displaying
71+
# incorrect data we only accept the summation_volume field
6772
_pick_list(ev, message, [
68-
('summation', 'summation_litres', True, 3),
73+
('summation_volume', 'summation_litres', True, 3),
6974
('summation_start', 'summation_resettime_utc', True, 0),
7075
])
7176
return ev

0 commit comments

Comments
 (0)