From 66752a6c8843f5cfaf896a2766d7daa9b1234df8 Mon Sep 17 00:00:00 2001 From: KRKeegan Date: Thu, 25 Jun 2020 16:15:06 -0700 Subject: [PATCH] Improved Handling of New Zone Faults Avoids some inaccuracies where a newly faulted zone could cause other faulted zones to appear as ready temporarily. Fixes #50 --- alarmdecoder/zonetracking.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/alarmdecoder/zonetracking.py b/alarmdecoder/zonetracking.py index e56ec12..ca3b15f 100644 --- a/alarmdecoder/zonetracking.py +++ b/alarmdecoder/zonetracking.py @@ -198,6 +198,9 @@ class Zonetracker(object): self._update_zone(zone) self._clear_zones(zone) + # Save our spot for the next message. + self._last_zone_fault = zone + else: status = Zone.FAULT if message.check_zone: @@ -207,8 +210,8 @@ class Zonetracker(object): self._zones_faulted.append(zone) self._zones_faulted.sort() - # Save our spot for the next message. - self._last_zone_fault = zone + # A new zone fault, so it is out of sequence. + self._last_zone_fault = 0 self._clear_expired_zones() @@ -245,6 +248,11 @@ class Zonetracker(object): :param zone: current zone being processed :type zone: int """ + + if self._last_zone_fault == 0: + # We don't know what the last faulted zone was, nothing to do + return + cleared_zones = [] found_last_faulted = found_current = at_end = False