diff --git a/bin/user/interceptor.py b/bin/user/interceptor.py index 438c4ae..2d39970 100644 --- a/bin/user/interceptor.py +++ b/bin/user/interceptor.py @@ -234,7 +234,7 @@ GW1000 - 433MHz GW1000A - 868MHz GW1000B - 915MHz - GW1000BU - 915MHz with better rang + GW1000BU - 915MHz with better range The transmission to wunderground can be captured using the 'wu-client' mode. The transmission using ecowitt protocol (see the 'customize' page in the WSView @@ -694,6 +694,19 @@ def _delta_rain(rain, last_rain): return rain return rain - last_rain + @staticmethod + def _delta_strikes(strikes, last_strikes): + if strikes is None: + return None + if last_strikes is None: + loginf("skipping lightning strikes measurement of %s: no last strikes" % strikes) + return None + if strikes < last_strikes: + loginf("lightning strikes wraparound detected: new=%s last=%s" % + (strikes, last_strikes)) + return strikes + return strikes - last_strikes + @staticmethod def decode_float(x): return None if x is None else float(x) @@ -2361,9 +2374,13 @@ class Parser(Consumer.Parser): 'wh25batt': 'wh25_battery', 'wh26batt': 'wh26_battery', 'wh40batt': 'wh40_battery', + 'wh57batt': 'wh57_battery', 'wh65batt': 'wh65_battery', 'pm25_ch1': 'pm2_5', 'pm25batt1': 'pm25_battery', + 'lightning_num': 'daily_lightning_strikes', + 'lightning_time': 'lightning_time', + 'lightning': 'lightning_distance', } IGNORED_LABELS = [ @@ -2376,6 +2393,7 @@ class Parser(Consumer.Parser): def __init__(self): self._last_rain = None self._rain_mapping_confirmed = False + self._last_strikes_total = None def parse(self, s): pkt = dict() @@ -2419,6 +2437,11 @@ def parse(self, s): pkt['rain'] = self._delta_rain(newtot, self._last_rain) self._last_rain = newtot + if 'daily_lightning_strikes' in pkt: + new_strikes_total = pkt['daily_lightning_strikes'] + pkt['lightning_strikes'] = self._delta_strikes(new_strikes_total, self._last_strikes_total) + self._last_strikes_total = new_strikes_total + except ValueError as e: logerr("parse failed for %s: %s" % (s, e)) return pkt