[STAGE5] Migrate HomeBot to gateway local-tools
lint / hygiene (pull_request) Failing after 27s
standard / check (pull_request) Successful in 10s
lint / hygiene (push) Failing after 30s
standard / check (push) Successful in 11s

This commit is contained in:
architect committed 2026-11-29 22:08:55 +03:00
1 parent c7be3583e1
commit 7e30c8df13
5 files changed
+30 -3

No files matched your search

+6
View File
@@ -52,6 +52,12 @@ def local_call(handler, q=""):
if handler == "book_search":
rows, err = _photo_local().Books().search(q, 5)
return {"ok": not bool(err), "rows": rows, "error": err}
if handler == "home_stats":
data, err = _photo_local().HomeDb().entities()
return {"ok": not bool(err), "data": data, "error": err}
if handler == "home_status":
data, err = _photo_local().HomeDb().states()
return {"ok": not bool(err), "data": data, "error": err}
raise ValueError("unknown local handler")
+12 -2
View File
@@ -926,7 +926,12 @@ class HomeBot(Bot):
self.cmd("status", "кратко о состоянии дома")(lambda a: self._status())
def _stats(self):
data, err = local.HomeDb().entities()
if os.environ.get("HUB_GATEWAY_HOME") == "1":
from .gateway import call
d = call("home.stats")
data, err = d.get("data"), d.get("error")
else:
data, err = local.HomeDb().entities()
if err:
return f"Не смог прочитать реестр HA: {err}"
lines = ["**Дом**", "", f"• Устройств и сущностей: {data['total']}"]
@@ -939,7 +944,12 @@ class HomeBot(Bot):
return "\n".join(lines)
def _status(self):
data, err = local.HomeDb().states()
if os.environ.get("HUB_GATEWAY_HOME") == "1":
from .gateway import call
d = call("home.status")
data, err = d.get("data"), d.get("error")
else:
data, err = local.HomeDb().states()
if err:
return f"Не удалось прочитать состояние: {err}"
return (f"**Состояние дома**\n\n• Запомненных состояний: {data['restored']}\n\n"