From 7d9faca720a6a0f5e20003de4d01d0468d6db904 Mon Sep 17 00:00:00 2001 From: Till Immer Date: Tue, 22 Sep 2026 13:54:07 +0000 Subject: [PATCH] Dateien nach "openhab" hochladen --- openhab/ai_bridge.items | 11 +++++++++++ openhab/ai_bridge.rules.js | 40 ++++++++++++++++++++++++++++++++++++++ openhab/ai_bridge.things | 23 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 openhab/ai_bridge.items create mode 100644 openhab/ai_bridge.rules.js create mode 100644 openhab/ai_bridge.things diff --git a/openhab/ai_bridge.items b/openhab/ai_bridge.items new file mode 100644 index 0000000..2fdbd7b --- /dev/null +++ b/openhab/ai_bridge.items @@ -0,0 +1,11 @@ +Group gAI_Bridge "AI Bridge" + +String AI_Bridge_Availability "AI Bridge Online [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:availability"} +String AI_Bridge_Status "AI Bridge Status [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:status"} +String AI_Bridge_LastResponse "KI Antwort [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:last_response"} +String AI_Bridge_ActiveSession "Aktive Session [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:active_session"} +String AI_Bridge_Notify "AI Notify [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:notify"} +String AI_Bridge_DialogInput "Dialog Input [%s]" (gAI_Bridge) {channel="mqtt:topic:ai_bridge:dialog_input"} + +// Textfeld in der UI – Befehl löst die JS-Regel aus +String AI_Bridge_DialogCommand "KI fragen" (gAI_Bridge) diff --git a/openhab/ai_bridge.rules.js b/openhab/ai_bridge.rules.js new file mode 100644 index 0000000..d6085e7 --- /dev/null +++ b/openhab/ai_bridge.rules.js @@ -0,0 +1,40 @@ +// openHAB JS Scripting – Dialog an die Bridge senden +// JavaScript Scripting Add-on muss installiert/aktiviert sein. +// +// Token und URL anpassen! + +const { rules, triggers, actions } = require('openhab'); + +const BRIDGE_URL = 'http://192.168.178.60:8090/api/v1/dialog'; +const BRIDGE_TOKEN = 'REPLACE_WITH_BRIDGE_TOKEN'; + +rules.JSRule({ + name: 'AI Bridge - Dialog senden', + description: 'Sendet Text aus AI_Bridge_DialogCommand an die Bridge und startet den Claude-Flow', + tags: ['AI', 'MCP'], + triggers: [triggers.ItemCommandTrigger('AI_Bridge_DialogCommand')], + execute: (event) => { + const text = String(event.receivedCommand || '').trim(); + if (!text) return; + + try { + actions.HTTP.sendHttpPostRequest( + BRIDGE_URL, + 'application/json', + JSON.stringify({ + text: text, + title: 'openHAB Dialog', + notify_text: 'KI_DIALOG' + }), + { + 'Authorization': 'Bearer ' + BRIDGE_TOKEN, + 'Content-Type': 'application/json' + }, + 8000 + ); + console.info('AI Bridge dialog sent: ' + text.substring(0, 80)); + } catch (e) { + console.error('AI Bridge dialog failed: ' + e); + } + } +}); diff --git a/openhab/ai_bridge.things b/openhab/ai_bridge.things new file mode 100644 index 0000000..add747b --- /dev/null +++ b/openhab/ai_bridge.things @@ -0,0 +1,23 @@ +// Broker-UID an deine Installation anpassen: +// Dein Broker: mqtt:broker:72a3b87ef9 +Thing mqtt:topic:ai_bridge "AI Bridge" (mqtt:broker:72a3b87ef9) { + Channels: + Type string : availability "Availability" [ + stateTopic="openhab/ai_bridge/availability" + ] + Type string : status "Status" [ + stateTopic="openhab/ai_bridge/status" + ] + Type string : last_response "Last response" [ + stateTopic="openhab/ai_bridge/last_response" + ] + Type string : active_session "Active session" [ + stateTopic="openhab/ai_bridge/active_session" + ] + Type string : notify "Notify" [ + stateTopic="openhab/ai_bridge/notify" + ] + Type string : dialog_input "Dialog input" [ + stateTopic="openhab/ai_bridge/dialog/input" + ] +}