Nice Work
This commit is contained in:
@@ -18,6 +18,9 @@ class AnnounceConfig:
|
||||
server_url: str
|
||||
firmware_version: str
|
||||
capabilities: dict[str, Any]
|
||||
api_port: int
|
||||
setup_port: int
|
||||
media_root: str
|
||||
announce_interval_seconds: int = 30
|
||||
polling_interval_seconds: int = 10
|
||||
|
||||
@@ -33,6 +36,9 @@ def build_payload(
|
||||
"fingerprint": fingerprint,
|
||||
"firmware_version": config.firmware_version,
|
||||
"capabilities": config.capabilities,
|
||||
"api_port": config.api_port,
|
||||
"setup_port": config.setup_port,
|
||||
"media_root": config.media_root,
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +73,9 @@ async def announce_loop(
|
||||
announce_url = f"{config.server_url}/api/boxes/announce"
|
||||
|
||||
while not stop_event.is_set():
|
||||
if not pairing.is_paired():
|
||||
await asyncio.to_thread(_post_json, announce_url, payload)
|
||||
response = await asyncio.to_thread(_post_json, announce_url, payload)
|
||||
if response and response.get("force_unpair") is True:
|
||||
pairing.unpair(reset_state=True)
|
||||
await asyncio.sleep(config.announce_interval_seconds)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user