node-red-contrib-knx-ultimate 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/examples/KNX AI - Conversational Control with Confirmation.json +374 -0
- package/examples/KNX AI - Telegrambot Direct Chat.json +221 -0
- package/examples/Matter Controller - Semantic Flow Input.json +248 -0
- package/nodes/commonFunctions.js +0 -174
- package/nodes/knxUltimateAI.html +254 -90
- package/nodes/knxUltimateAI.js +1286 -61
- package/nodes/knxUltimateMatterBridge.html +144 -11
- package/nodes/knxUltimateMatterControllerDevice.html +80 -55
- package/nodes/locales/de/knxUltimateAI.html +38 -2
- package/nodes/locales/de/knxUltimateAI.json +16 -3
- package/nodes/locales/de/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/de/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/de/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/de/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/locales/en/knxUltimateAI.html +38 -2
- package/nodes/locales/en/knxUltimateAI.json +16 -3
- package/nodes/locales/en/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/en/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/en/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/en/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/locales/es/knxUltimateAI.html +38 -2
- package/nodes/locales/es/knxUltimateAI.json +16 -3
- package/nodes/locales/es/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/es/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/es/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/es/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/locales/fr/knxUltimateAI.html +38 -2
- package/nodes/locales/fr/knxUltimateAI.json +16 -3
- package/nodes/locales/fr/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/fr/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/fr/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/fr/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/locales/it/knxUltimateAI.html +38 -2
- package/nodes/locales/it/knxUltimateAI.json +16 -3
- package/nodes/locales/it/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/it/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/it/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/it/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/locales/zh-CN/knxUltimateAI.html +38 -2
- package/nodes/locales/zh-CN/knxUltimateAI.json +16 -3
- package/nodes/locales/zh-CN/knxUltimateMatterBridge.html +1 -1
- package/nodes/locales/zh-CN/knxUltimateMatterBridge.json +14 -0
- package/nodes/locales/zh-CN/knxUltimateMatterControllerDevice.html +2 -2
- package/nodes/locales/zh-CN/knxUltimateMatterControllerDevice.json +2 -1
- package/nodes/utils/sysLogger.js +0 -109
- package/package.json +1 -2
- package/resources/KNXAIChatAdapterMappings.js +87 -0
- package/nodes/plugins/knxUltimateMonitor-sidebar-plugin.html +0 -922
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
; (function (root) {
|
|
2
|
+
const KNXAIChatAdapterMappings = [
|
|
3
|
+
{
|
|
4
|
+
id: 'windkh-telegrambot',
|
|
5
|
+
title: 'windkh/node-red-contrib-telegrambot',
|
|
6
|
+
inputCode: `// Receiver/Event -> KNX AI
|
|
7
|
+
// Supports "telegram receiver" text messages and "telegram event"
|
|
8
|
+
// callback_query messages produced by inline confirmation buttons.
|
|
9
|
+
const telegram = msg.payload;
|
|
10
|
+
if (!telegram || typeof telegram !== 'object') return;
|
|
11
|
+
|
|
12
|
+
const chatId = telegram.chatId;
|
|
13
|
+
const content = typeof telegram.content === 'string' ? telegram.content.trim() : '';
|
|
14
|
+
if (chatId === undefined || chatId === null || content === '') return;
|
|
15
|
+
|
|
16
|
+
msg.sessionId = String(chatId);
|
|
17
|
+
msg.language =
|
|
18
|
+
(msg.originalMessage && msg.originalMessage.from && msg.originalMessage.from.language_code) ||
|
|
19
|
+
msg.language ||
|
|
20
|
+
'';
|
|
21
|
+
|
|
22
|
+
if (telegram.type === 'callback_query' && (content === 'confirm' || content === 'cancel')) {
|
|
23
|
+
msg.topic = content;
|
|
24
|
+
msg.knxAi = Object.assign({}, msg.knxAi, {
|
|
25
|
+
sessionId: String(chatId),
|
|
26
|
+
confirm: content === 'confirm'
|
|
27
|
+
});
|
|
28
|
+
return msg;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (telegram.type !== 'message') return;
|
|
32
|
+
msg.topic = 'ask';
|
|
33
|
+
msg.prompt = content;
|
|
34
|
+
return msg;`,
|
|
35
|
+
outputCode: `// KNX AI chat output -> Telegram sender
|
|
36
|
+
// Converts the text reply and, when required, adds inline
|
|
37
|
+
// confirmation/cancellation buttons.
|
|
38
|
+
const source = msg.inputMessage && typeof msg.inputMessage === 'object'
|
|
39
|
+
? msg.inputMessage
|
|
40
|
+
: inputMessage;
|
|
41
|
+
const sourcePayload = source && source.payload && typeof source.payload === 'object'
|
|
42
|
+
? source.payload
|
|
43
|
+
: {};
|
|
44
|
+
const chatId = sourcePayload.chatId !== undefined
|
|
45
|
+
? sourcePayload.chatId
|
|
46
|
+
: source && source.chatId;
|
|
47
|
+
if (chatId === undefined || chatId === null) return;
|
|
48
|
+
|
|
49
|
+
let content = msg.payload;
|
|
50
|
+
if (content && typeof content === 'object') {
|
|
51
|
+
content = content.error || content.message || JSON.stringify(content);
|
|
52
|
+
}
|
|
53
|
+
content = String(content === undefined || content === null ? '' : content);
|
|
54
|
+
|
|
55
|
+
const telegramPayload = {
|
|
56
|
+
chatId: chatId,
|
|
57
|
+
type: 'message',
|
|
58
|
+
content: content
|
|
59
|
+
};
|
|
60
|
+
const confirmation = msg.knxAi && msg.knxAi.confirmationRequest;
|
|
61
|
+
if (confirmation && confirmation.required === true && Array.isArray(confirmation.actions)) {
|
|
62
|
+
telegramPayload.options = {
|
|
63
|
+
reply_markup: JSON.stringify({
|
|
64
|
+
inline_keyboard: [
|
|
65
|
+
confirmation.actions.map(function (action) {
|
|
66
|
+
return {
|
|
67
|
+
text: action.label,
|
|
68
|
+
callback_data: action.callbackData
|
|
69
|
+
};
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
msg.payload = telegramPayload;
|
|
77
|
+
return msg;`
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
if (root) {
|
|
82
|
+
root.KNXAIChatAdapterMappings = KNXAIChatAdapterMappings
|
|
83
|
+
}
|
|
84
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
85
|
+
module.exports = KNXAIChatAdapterMappings
|
|
86
|
+
}
|
|
87
|
+
})(typeof window !== 'undefined' ? window : (typeof globalThis !== 'undefined' ? globalThis : this))
|