Refactored pydantic implementation, cleaner with nested validation

This commit is contained in:
2026-02-18 11:18:06 +01:00
parent 501ba01bed
commit 1e874d6c5f
8 changed files with 247 additions and 122 deletions

View File

@@ -5,7 +5,7 @@ import logging
import json
import projrequest as projrequest
from commands import ShowStatus, PowerStatusList
from commands import ShowStatus, PowerStatus, DCPImportJobList, DCPInfoList, StorageInfo
from utils import *
from influxdb_client_3 import InfluxDBClient3, Point
@@ -39,21 +39,17 @@ def main() -> int:
username=env['PROJECTOR_USER'],
password=env['PROJECTOR_PASSWORD']
)
ps = PowerStatusList(projector=projector)
ss = ShowStatus(projector=projector)
while handler.running:
try:
now:float = time.time()
ps.get()
ss.get()
print(ps.dump())
print(ss.dump())
ret = projector.request(ShowStatus)
print(ret)
last: float = time.time()
cycle_time: float = last - now
LOGGER.debug(f"Cycle Time: {cycle_time:4.3f}")
time.sleep(INTERVAL-cycle_time)
if cycle_time < INTERVAL:
time.sleep(INTERVAL-cycle_time)
except Exception as e:
print(f"Unexpected exception: [{e}]")
return 1