Backup automatico script del 2026-08-23 12:04
This commit is contained in:
1 parent
11823447a2
commit
795a15a7b6
66 files changed
+8546
No files matched your search
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Verifica P5: tool live Loogle Casa + Home Assistant."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, "/srv" if os.path.isdir("/srv/app") else os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
|
||||
def main() -> int:
|
||||
from app.integrations import casa, homeassistant
|
||||
from app.mcp import tools
|
||||
|
||||
user = os.environ.get("MCP_TEST_USER", "daniele")
|
||||
claims = {
|
||||
"sub": user,
|
||||
"scope": "home:read context:read knowledge:read gitea:read admin",
|
||||
}
|
||||
errors = []
|
||||
|
||||
print("=== P5 integrations ===")
|
||||
print("casa configured:", casa.is_configured(user))
|
||||
print("ha configured:", homeassistant.is_configured())
|
||||
|
||||
if casa.is_configured(user):
|
||||
for tool, args in (
|
||||
("get_home_dashboard", {}),
|
||||
("get_home_weather", {}),
|
||||
("get_network_overview", {}),
|
||||
("get_network_failover_status", {}),
|
||||
):
|
||||
try:
|
||||
out = tools.call_tool(tool, args, claims)
|
||||
text = out["content"][0]["text"]
|
||||
data = json.loads(text)
|
||||
print(f"OK {tool}: keys={list(data.keys())[:8]}")
|
||||
except Exception as exc:
|
||||
print(f"FAIL {tool}: {exc}")
|
||||
errors.append(tool)
|
||||
else:
|
||||
errors.append("casa-not-configured")
|
||||
|
||||
if homeassistant.is_configured():
|
||||
try:
|
||||
cfg = homeassistant.get_config()
|
||||
print(f"OK ha config: version={cfg.get('version')}")
|
||||
except Exception as exc:
|
||||
print(f"FAIL ha config: {exc}")
|
||||
errors.append("ha-config")
|
||||
try:
|
||||
out = tools.call_tool("list_ha_entities", {"domain": "switch", "limit": 5}, claims)
|
||||
data = json.loads(out["content"][0]["text"])
|
||||
print(f"OK list_ha_entities: count={len(data.get('entities', []))}")
|
||||
except Exception as exc:
|
||||
print(f"FAIL list_ha_entities: {exc}")
|
||||
errors.append("list_ha_entities")
|
||||
else:
|
||||
errors.append("ha-not-configured")
|
||||
|
||||
if errors:
|
||||
print("P5 FAILED:", errors)
|
||||
return 1
|
||||
print("P5 OK")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user