refactor: replace GraphQL/REST with MQTT-only for Unraid server data
All server stats (CPU, RAM, Docker, shares, disks, array) now come directly from MQTT topics published by the Unraid MQTT Agent. This eliminates the need for API keys, HTTP polling, and the GraphQL/REST fallback chain. - Rewrote unraid_service.py to read from MQTT store (no httpx needed) - Simplified servers router (no cache, no enrichment hack) - Added mqtt_prefix field to UnraidServer config - Updated DB: both Daddelolymp and Adriahub with mqtt_prefix, no api_key - Data is always fresh (MQTT pushes every ~15s) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5d3d4f4015
commit
c6db0ab569
3 changed files with 201 additions and 469 deletions
|
|
@ -19,9 +19,10 @@ logger = logging.getLogger(__name__)
|
|||
@dataclass
|
||||
class UnraidServer:
|
||||
name: str
|
||||
host: str
|
||||
api_key: str = ""
|
||||
port: int = 80
|
||||
host: str = ""
|
||||
mqtt_prefix: str = "" # MQTT topic prefix, e.g. "Adriahub" or "unraid-daddelolymp"
|
||||
api_key: str = "" # Deprecated — kept for backward compat
|
||||
port: int = 80 # Deprecated — kept for backward compat
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
@ -122,11 +123,12 @@ class Settings:
|
|||
UnraidServer(
|
||||
name=srv.get("name", f"Server {i+1}"),
|
||||
host=srv.get("host", ""),
|
||||
mqtt_prefix=srv.get("mqtt_prefix", ""),
|
||||
api_key=srv.get("api_key", ""),
|
||||
port=int(srv.get("port", 80)),
|
||||
)
|
||||
for i, srv in enumerate(servers_data)
|
||||
if srv.get("host")
|
||||
if srv.get("name") or srv.get("host")
|
||||
]
|
||||
s.unraid_enabled = len(s.unraid_servers) > 0
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
|
|
@ -172,11 +174,12 @@ class Settings:
|
|||
UnraidServer(
|
||||
name=s.get("name", ""),
|
||||
host=s.get("host", ""),
|
||||
mqtt_prefix=s.get("mqtt_prefix", ""),
|
||||
api_key=s.get("api_key", ""),
|
||||
port=int(s.get("port", 80)),
|
||||
)
|
||||
for s in servers
|
||||
if s.get("host")
|
||||
if s.get("name") or s.get("host")
|
||||
]
|
||||
self.unraid_enabled = enabled
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue