From 8432ab4448504ac4b01dc4142ed9847eabd60d04 Mon Sep 17 00:00:00 2001 From: host Date: Wed, 29 Jul 2026 19:29:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=20make=5Fexport.py=20-=20=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80=20JSON-=D1=8D?= =?UTF-8?q?=D0=BA=D1=81=D0=BF=D0=BE=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- make_export.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 make_export.py diff --git a/make_export.py b/make_export.py new file mode 100644 index 0000000..3346d48 --- /dev/null +++ b/make_export.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Генератор JSON-экспорта Open WebUI из home_assistant_tools.py. + +Запуск: + 1. Скачайте оба файла в одну папку + 2. python3 make_export.py + 3. Получите home_assistant_tool.json + +Или одной командой (Linux/macOS/TrueNAS/Proxmox): + curl -sSL https://gitea.nasweb.ru/host/home-assistant-tools/raw/branch/main/make_export.py | python3 +""" + +import json +import sys +import urllib.request +from pathlib import Path + + +SRC = Path(__file__).parent / "home_assistant_tools.py" +OUT = Path(__file__).parent / "home_assistant_tool.json" + +# Если запущен из stdin (через curl | python3) — качаем .py сами +if not SRC.exists(): + print("home_assistant_tools.py не найден рядом, скачиваю...", file=sys.stderr) + url = "https://gitea.nasweb.ru/host/home-assistant-tools/raw/branch/main/home_assistant_tools.py" + try: + SRC.write_text(urllib.request.urlopen(url, timeout=15).read().decode("utf-8"), encoding="utf-8") + print("OK: скачан", SRC, file=sys.stderr) + except Exception as e: + print("ОШИБКА скачивания:", e, file=sys.stderr) + sys.exit(1) + + +content = SRC.read_text(encoding="utf-8") + +payload = { + "type": "tool", + "name": "Home Assistant Smart Control", + "version": "2.2.2", + "description": ( + "Управление умным домом через Home Assistant REST API с интерпретацией " + "естественного языка. Управление светом/климатом/шторами/медиа и мониторинг " + "(окна, свет, температура, батарейки, присутствие)." + ), + "author": "ChatGPT (refactored by MiniMax-M3)", + "license": "MIT", + "content": content, + "metadata": { + "ha_default_url": "https://ha.nasweb.ru", + "ha_default_verify_ssl": False, + "source_repo": "https://gitea.nasweb.ru/host/home-assistant-tools", + }, +} + +OUT.write_text( + json.dumps(payload, ensure_ascii=False, indent=2), + encoding="utf-8", +) + +print("OK: создан", OUT) +print("Размер:", OUT.stat().st_size, "байт") +print() +print("Дальше:") +print(" 1. Открой Open WebUI -> Workspace -> Tools -> Импорт") +print(" 2. В поле URL вставь путь к этому JSON или загрузи файл") +print(" 3. Укажи HA Token в Valves") \ No newline at end of file