"""Проверяет HACS через websocket: список репозиториев.""" import asyncio import json import aiohttp TOKEN = open("/tmp/ha-token", encoding="utf-8").read().strip() WS = "ws://127.0.0.1:8123/api/websocket" async def main(): async with aiohttp.ClientSession() as session: async with session.ws_connect(WS) as ws: await ws.receive_json() await ws.send_json({"type": "auth", "access_token": TOKEN}) msg = await ws.receive_json() if msg["type"] != "auth_ok": print(" auth:", msg) return print(" авторизация ок") await ws.send_json({"id": 1, "type": "hacs/repositories/list"}) data = await ws.receive_json() if not data.get("success"): print(" ответ:", json.dumps(data, ensure_ascii=False)[:300]) return repos = data.get("result") or [] print(" репозиториев в HACS:", len(repos)) for r in repos[:10]: print(f" - {r.get('full_name')} | {r.get('category')} | {r.get('installed_version') or '—'}") asyncio.run(main())