fix last change detection

This commit is contained in:
Tomáš Mládek 2021-04-19 23:45:54 +02:00
parent 191bcae1ff
commit 6b952d8e2f

View file

@ -182,7 +182,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
last_change = None
for ts, leases in groupby(_fetch_leases(db, now - timedelta(days=7)), key=attrgetter('ts')):
humans_present = [lease for lease in leases if _is_human(lease)]
if (len(humans_present) > 0) != status.level > 0:
if (len(humans_present) > 0) != (status.level > 0):
last_change = {'ts': ts, 'leases': humans_present}
break