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.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/examples/KNX AI - Conversational Control with Confirmation.json +374 -0
  3. package/examples/KNX AI - Telegrambot Direct Chat.json +221 -0
  4. package/examples/Matter Controller - Semantic Flow Input.json +248 -0
  5. package/nodes/commonFunctions.js +0 -174
  6. package/nodes/knxUltimateAI.html +254 -90
  7. package/nodes/knxUltimateAI.js +1286 -61
  8. package/nodes/knxUltimateMatterBridge.html +144 -11
  9. package/nodes/knxUltimateMatterControllerDevice.html +80 -55
  10. package/nodes/locales/de/knxUltimateAI.html +38 -2
  11. package/nodes/locales/de/knxUltimateAI.json +16 -3
  12. package/nodes/locales/de/knxUltimateMatterBridge.html +1 -1
  13. package/nodes/locales/de/knxUltimateMatterBridge.json +14 -0
  14. package/nodes/locales/de/knxUltimateMatterControllerDevice.html +2 -2
  15. package/nodes/locales/de/knxUltimateMatterControllerDevice.json +2 -1
  16. package/nodes/locales/en/knxUltimateAI.html +38 -2
  17. package/nodes/locales/en/knxUltimateAI.json +16 -3
  18. package/nodes/locales/en/knxUltimateMatterBridge.html +1 -1
  19. package/nodes/locales/en/knxUltimateMatterBridge.json +14 -0
  20. package/nodes/locales/en/knxUltimateMatterControllerDevice.html +2 -2
  21. package/nodes/locales/en/knxUltimateMatterControllerDevice.json +2 -1
  22. package/nodes/locales/es/knxUltimateAI.html +38 -2
  23. package/nodes/locales/es/knxUltimateAI.json +16 -3
  24. package/nodes/locales/es/knxUltimateMatterBridge.html +1 -1
  25. package/nodes/locales/es/knxUltimateMatterBridge.json +14 -0
  26. package/nodes/locales/es/knxUltimateMatterControllerDevice.html +2 -2
  27. package/nodes/locales/es/knxUltimateMatterControllerDevice.json +2 -1
  28. package/nodes/locales/fr/knxUltimateAI.html +38 -2
  29. package/nodes/locales/fr/knxUltimateAI.json +16 -3
  30. package/nodes/locales/fr/knxUltimateMatterBridge.html +1 -1
  31. package/nodes/locales/fr/knxUltimateMatterBridge.json +14 -0
  32. package/nodes/locales/fr/knxUltimateMatterControllerDevice.html +2 -2
  33. package/nodes/locales/fr/knxUltimateMatterControllerDevice.json +2 -1
  34. package/nodes/locales/it/knxUltimateAI.html +38 -2
  35. package/nodes/locales/it/knxUltimateAI.json +16 -3
  36. package/nodes/locales/it/knxUltimateMatterBridge.html +1 -1
  37. package/nodes/locales/it/knxUltimateMatterBridge.json +14 -0
  38. package/nodes/locales/it/knxUltimateMatterControllerDevice.html +2 -2
  39. package/nodes/locales/it/knxUltimateMatterControllerDevice.json +2 -1
  40. package/nodes/locales/zh-CN/knxUltimateAI.html +38 -2
  41. package/nodes/locales/zh-CN/knxUltimateAI.json +16 -3
  42. package/nodes/locales/zh-CN/knxUltimateMatterBridge.html +1 -1
  43. package/nodes/locales/zh-CN/knxUltimateMatterBridge.json +14 -0
  44. package/nodes/locales/zh-CN/knxUltimateMatterControllerDevice.html +2 -2
  45. package/nodes/locales/zh-CN/knxUltimateMatterControllerDevice.json +2 -1
  46. package/nodes/utils/sysLogger.js +0 -109
  47. package/package.json +1 -2
  48. package/resources/KNXAIChatAdapterMappings.js +87 -0
  49. 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))