forgotten last_status check

This commit is contained in:
Tomáš Mládek 2021-02-22 23:58:18 +01:00
parent 6d68f00afa
commit 30e78ee2f0

View file

@ -101,7 +101,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
autoescape=select_autoescape(['html', 'xml'])
)
last_state = None
last_status = None
while True:
logging.info(f"Querying router at {address}...")
@ -150,7 +150,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
])
db.commit()
if webhook_url:
if webhook_url and last_status != status:
requests.post(webhook_url, json={
"text": f"Anabasis is now <b>{status.description}</b>! ({status.text})",
"format": "html",
@ -240,6 +240,8 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
)
file.write(out_str)
last_status = status
logging.info(f"Sleeping for {period} seconds.")
sleep(period)