bundles/infobeamer-cms: more and better information
This commit is contained in:
parent
ec1efaafcc
commit
a929f24977
1 changed files with 14 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import datetime, timezone
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ def mqtt_dump_state(device):
|
||||||
return
|
return
|
||||||
mqtt_out(
|
mqtt_out(
|
||||||
"Sync status: {} - Location: {} - Running Setup: {} ({}) - Resolution: {}".format(
|
"Sync status: {} - Location: {} - Running Setup: {} ({}) - Resolution: {}".format(
|
||||||
"yes" if device["is_synced"] else "unknown",
|
"yes" if device["is_synced"] else "syncing",
|
||||||
device["location"],
|
device["location"],
|
||||||
device["setup"]["name"],
|
device["setup"]["name"],
|
||||||
device["setup"]["id"],
|
device["setup"]["id"],
|
||||||
|
@ -84,6 +85,7 @@ while True:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_state = {}
|
new_state = {}
|
||||||
|
online_devices = set()
|
||||||
for device in ib_state:
|
for device in ib_state:
|
||||||
did = str(device["id"])
|
did = str(device["id"])
|
||||||
|
|
||||||
|
@ -154,11 +156,21 @@ while True:
|
||||||
|
|
||||||
if must_dump_state:
|
if must_dump_state:
|
||||||
mqtt_dump_state(device)
|
mqtt_dump_state(device)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
LOG.info("adding device {} to empty state".format(device["id"]))
|
LOG.info("adding device {} to empty state".format(device["id"]))
|
||||||
|
|
||||||
|
if device["is_online"]:
|
||||||
|
online_devices.add(
|
||||||
|
"{} ({})".format(
|
||||||
|
device["id"],
|
||||||
|
device["description"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
state = new_state
|
state = new_state
|
||||||
|
|
||||||
|
if datetime.now(timezone.utc).strftime("%H%M") == "1312" and online_devices:
|
||||||
|
mqtt_out("Online Devices: {}".format(", ".join(sorted(online_devices))))
|
||||||
sleep(30)
|
sleep(30)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue