forgotten last_status check
This commit is contained in:
parent
6d68f00afa
commit
30e78ee2f0
1 changed files with 4 additions and 2 deletions
|
@ -101,7 +101,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
|
||||||
autoescape=select_autoescape(['html', 'xml'])
|
autoescape=select_autoescape(['html', 'xml'])
|
||||||
)
|
)
|
||||||
|
|
||||||
last_state = None
|
last_status = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
logging.info(f"Querying router at {address}...")
|
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()
|
db.commit()
|
||||||
|
|
||||||
if webhook_url:
|
if webhook_url and last_status != status:
|
||||||
requests.post(webhook_url, json={
|
requests.post(webhook_url, json={
|
||||||
"text": f"Anabasis is now <b>{status.description}</b>! ({status.text})",
|
"text": f"Anabasis is now <b>{status.description}</b>! ({status.text})",
|
||||||
"format": "html",
|
"format": "html",
|
||||||
|
@ -240,6 +240,8 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url:
|
||||||
)
|
)
|
||||||
file.write(out_str)
|
file.write(out_str)
|
||||||
|
|
||||||
|
last_status = status
|
||||||
|
|
||||||
logging.info(f"Sleeping for {period} seconds.")
|
logging.info(f"Sleeping for {period} seconds.")
|
||||||
sleep(period)
|
sleep(period)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue