Dateien nach "openhab" hochladen

This commit is contained in:
Till-Immer committed 2026-09-22 13:54:07 +00:00
1 parent 08ff519216
commit 7d9faca720
3 files changed
+74

No files matched your search

+40
View File
@@ -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);
}
}
});