bundles/infobeamer-cms: more and better information

This commit is contained in:
Franzi 2023-12-31 08:50:45 +01:00
parent ec1efaafcc
commit a929f24977
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import logging
from datetime import datetime, timezone
from json import dumps
from time import sleep
@ -56,7 +57,7 @@ def mqtt_dump_state(device):
return
mqtt_out(
"Sync status: {} - Location: {} - Running Setup: {} ({}) - Resolution: {}".format(
"yes" if device["is_synced"] else "unknown",
"yes" if device["is_synced"] else "syncing",
device["location"],
device["setup"]["name"],
device["setup"]["id"],
@ -84,6 +85,7 @@ while True:
)
else:
new_state = {}
online_devices = set()
for device in ib_state:
did = str(device["id"])
@ -154,11 +156,21 @@ while True:
if must_dump_state:
mqtt_dump_state(device)
else:
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
if datetime.now(timezone.utc).strftime("%H%M") == "1312" and online_devices:
mqtt_out("Online Devices: {}".format(", ".join(sorted(online_devices))))
sleep(30)
except KeyboardInterrupt:
break