diff --git a/bin/weewx/drivers/wmr200.py b/bin/weewx/drivers/wmr200.py index 5750ebc6..340343d8 100644 --- a/bin/weewx/drivers/wmr200.py +++ b/bin/weewx/drivers/wmr200.py @@ -1906,13 +1906,24 @@ class WMR200(weewx.drivers.AbstractDevice): % (cnt, self._archive_threshold, weeutil.weeutil.timestamp_to_string(pkt.timestamp_record()))) elif pkt.timestamp_record() > since_ts: - # Calculate the rain accumulation between valid archive + # Update the timestamp delta previous value even if + # we do not use this packet. This is so the next archive + # packet, if any, has the proper delta timestamp + # calculation. + timestamp_packet_previous = timestamp_packet_current + + # Ensure that the packet has a valid 'interval' field. + packet_record_interval = int(timestamp_packet_interval / 60.0) + if packet_record_interval == 0: + # This packet occurred less than the minimal interval after the + # initial time search space and is discarded. + loginf('genStartup() Discarding received archive record' + ' since interval is zero') + return + pkt.record_update({'interval': packet_record_interval}) + # Calculate the rain accumulation between valid archive # packets. pkt.record_update(adjust_rain(pkt, PacketArchiveData)) - # Ensure that the packet has a valid 'interval' field - pkt.record_update({'interval': int(timestamp_packet_interval / 60.0)}) - - timestamp_packet_previous = timestamp_packet_current cnt += 1 log.debug('genStartup() Yielding received archive' ' record cnt:%d after requested timestamp'