node-red-contrib-ccu 4.12.0 → 4.14.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.
@@ -0,0 +1,178 @@
1
+ /*
2
+ * task 32: system variables and programs on openccu-lite. The system has no ReGaHSS; the addon
3
+ * Logic (lite-addon-logic) offers them as devices of an interface of its own, which the system's
4
+ * lite-rpc carries like the radio interfaces:
5
+ *
6
+ * system variable `regen` device var-regen (LOGIC-VARIABLE), channel var-regen:1, VALUE
7
+ * (an alarm variable also ACKNOWLEDGE, COUNT, FIRST, LAST)
8
+ * program `markise` device prg-markise (LOGIC-PROGRAM), channel prg-markise:1,
9
+ * ACTIVE, RUN (with the conditions), RUN_THEN (the CCU's "Start"),
10
+ * LAST_RUN (an event at every run)
11
+ *
12
+ * The address is the object's key and stays across a rename; the name is the system's metadata
13
+ * name of the channel (or the device), which the addon writes. The sysvar and program nodes find
14
+ * an object by that name, as they did by the ReGa name on a CCU, so a flow written for a CCU
15
+ * keeps working after the switch once the variables and programs were imported.
16
+ *
17
+ * Pure helpers, no connection state: the connection (ccu-connection.js) keeps the tables.
18
+ */
19
+
20
+ /** the interface's name as lite-addon-logic registers it */
21
+ const LOGIC_IFACE = 'Logic';
22
+
23
+ /** the addon's id, `addon` in GET /api/rpc/v1/interfaces */
24
+ const LOGIC_ADDON = 'logic';
25
+
26
+ /**
27
+ * Whether an interface the system lists is Logic's: by its addon id, else by its name.
28
+ * @param {string} name
29
+ * @param {{addon?: string}} [info] the entry of GET /api/rpc/v1/interfaces
30
+ * @returns {boolean}
31
+ */
32
+ function isLogicIface(name, info) {
33
+ if (info && info.addon) {
34
+ return info.addon === LOGIC_ADDON;
35
+ }
36
+
37
+ return name === LOGIC_IFACE;
38
+ }
39
+
40
+ /**
41
+ * What a Logic address stands for: a variable's or a program's value channel (`:1`), else null.
42
+ * @param {string} channel e.g. var-regen:1
43
+ * @returns {{kind: 'variable'|'program', key: string, device: string, channel: string}|null}
44
+ */
45
+ function parseAddress(channel) {
46
+ const match = /^(var|prg)-(.+):1$/.exec(String(channel || ''));
47
+ if (!match) {
48
+ return null;
49
+ }
50
+
51
+ return {
52
+ kind: match[1] === 'var' ? 'variable' : 'program',
53
+ key: match[2],
54
+ device: match[1] + '-' + match[2],
55
+ channel: match[1] + '-' + match[2] + ':1',
56
+ };
57
+ }
58
+
59
+ /**
60
+ * The name a node finds an object by: the channel's metadata name, else the device's, else its key
61
+ * (a connection without a credential for the names).
62
+ * @param {object} names channelNames, by address
63
+ * @param {{key: string, device: string, channel: string}} ref from parseAddress()
64
+ * @returns {string}
65
+ */
66
+ function nameOf(names, ref) {
67
+ const map = names || {};
68
+ return map[ref.channel] || map[ref.device] || ref.key;
69
+ }
70
+
71
+ /**
72
+ * The CCU's shape of a system variable (homematic-rega's getVariables) from the description of
73
+ * Logic's VALUE datapoint: `valueType` boolean | number | string, `enum` (the texts for false and
74
+ * true of a logic value, the entries of a value list), `unit`, and the Homematic type.
75
+ * Without a description (not fetched yet) the type follows the value.
76
+ * @param {object} [description] the paramset description of VALUE
77
+ * @param {*} [value] the current value, for the fallback
78
+ * @returns {{valueType: string, enum: string[], unit: string, type: string|undefined, min?: number, max?: number}}
79
+ */
80
+ function variableShape(description, value) {
81
+ const list = description && Array.isArray(description.VALUE_LIST) ? description.VALUE_LIST.map(String) : [];
82
+ const unit = (description && typeof description.UNIT === 'string' && description.UNIT) || '';
83
+ const type = description && description.TYPE;
84
+ const shape = {valueType: 'number', enum: [], unit, type};
85
+ switch (type) {
86
+ case 'BOOL':
87
+ case 'ACTION':
88
+ shape.valueType = 'boolean';
89
+ shape.enum = list;
90
+ break;
91
+ case 'STRING':
92
+ shape.valueType = 'string';
93
+ break;
94
+ case 'ENUM':
95
+ shape.enum = list;
96
+ break;
97
+ case 'FLOAT':
98
+ case 'INTEGER':
99
+ break;
100
+ default:
101
+ if (typeof value === 'boolean') {
102
+ shape.valueType = 'boolean';
103
+ } else if (typeof value === 'string') {
104
+ shape.valueType = 'string';
105
+ }
106
+ }
107
+
108
+ if (description && typeof description.MIN === 'number' && shape.valueType === 'number' && type !== 'ENUM') {
109
+ shape.min = description.MIN;
110
+ }
111
+
112
+ if (description && typeof description.MAX === 'number' && shape.valueType === 'number' && type !== 'ENUM') {
113
+ shape.max = description.MAX;
114
+ }
115
+
116
+ return shape;
117
+ }
118
+
119
+ /**
120
+ * A value for Logic's VALUE, cast the way the CCU path casts a variable (castSysvar): a logic
121
+ * value takes true/false, a number, or one of its two texts; a value list its entry's number or
122
+ * text; a number a number; a string a string. A FLOAT goes out as homematic-xmlrpc's
123
+ * `{explicitDouble}`, which lite.js turns into lite-rpc's double. Limits are the addon's to check:
124
+ * it refuses a number outside them and an entry the list does not have, and the refusal is said.
125
+ * @param {*} value
126
+ * @param {{valueType: string, enum: string[], type?: string}} shape from variableShape()
127
+ * @returns {*}
128
+ */
129
+ function castVariable(value, shape) {
130
+ const list = shape.enum || [];
131
+ switch (shape.valueType) {
132
+ case 'boolean':
133
+ if (typeof value === 'string') {
134
+ if (list.includes(value)) {
135
+ return list.indexOf(value) === 1;
136
+ }
137
+
138
+ if (value === 'false' || value === '0') {
139
+ return false;
140
+ }
141
+ }
142
+
143
+ return Boolean(value);
144
+ case 'string':
145
+ return value === null || value === undefined ? '' : String(value);
146
+ default: {
147
+ if (typeof value === 'string' && list.includes(value)) {
148
+ return list.indexOf(value);
149
+ }
150
+
151
+ if (typeof value === 'boolean') {
152
+ value = value ? 1 : 0;
153
+ }
154
+
155
+ const number = Number.parseFloat(value);
156
+ const safe = Number.isFinite(number) ? number : 0;
157
+ if (shape.type === 'ENUM' || shape.type === 'INTEGER') {
158
+ return Math.round(safe);
159
+ }
160
+
161
+ if (shape.type === 'FLOAT') {
162
+ return {explicitDouble: safe};
163
+ }
164
+
165
+ return safe;
166
+ }
167
+ }
168
+ }
169
+
170
+ module.exports = {
171
+ LOGIC_IFACE,
172
+ LOGIC_ADDON,
173
+ isLogicIface,
174
+ parseAddress,
175
+ nameOf,
176
+ variableShape,
177
+ castVariable,
178
+ };
@@ -63,3 +63,34 @@ module.exports = (that, data) => {
63
63
  that.currentStatus = 'red';
64
64
  }
65
65
  };
66
+
67
+ /**
68
+ * task 32: the status of a node of system variables or programs (sysvar, program, poll): on a CCU
69
+ * the ReGaHSS's, on openccu-lite the Logic interface's - or why there is none (the addon is not
70
+ * installed, the connection does not use lite-rpc).
71
+ * @param {object} that the node; `that.ccu.sysvarSource()` decides
72
+ * @param {object} data what the connection pushes
73
+ */
74
+ module.exports.sysvar = (that, data) => {
75
+ const source = that.ccu && typeof that.ccu.sysvarSource === 'function' ? that.ccu.sysvarSource() : {};
76
+ if (source.iface) {
77
+ that.iface = source.iface;
78
+ }
79
+
80
+ if (source.error) {
81
+ if (that.currentStatus !== 'error:' + source.error) {
82
+ that.status({fill: 'red', shape: 'ring', text: source.error});
83
+ that.currentStatus = 'error:' + source.error;
84
+ }
85
+
86
+ return;
87
+ }
88
+
89
+ if (source.waiting) {
90
+ that.status(WAITING);
91
+ that.currentStatus = 'waiting';
92
+ return;
93
+ }
94
+
95
+ module.exports(that, data);
96
+ };
@@ -7,9 +7,36 @@
7
7
  <p>Den Ausgang mit demselben <b>mqtt out</b>-Node verbinden wie den ccu-mqtt-Node. Der Node sendet
8
8
  <code>msg.topic</code>, <code>msg.payload</code> und <code>msg.retain</code>.</p>
9
9
  <h3>Geräteauswahl</h3>
10
- <p>Nur angehakte Geräte werden an Home Assistant gemeldet (ein HA-Gerät pro Homematic-Gerät).
11
- Wird ein zuvor angehaktes Gerät abgehakt, sendet der Node beim nächsten Deploy eine leere
10
+ <p>Nur angehakte Geräte werden an Home Assistant gemeldet. Wird ein zuvor angehaktes Gerät abgehakt, sendet der Node beim nächsten Deploy eine leere
12
11
  Konfiguration, die das Gerät in Home Assistant entfernt.</p>
12
+ <h3>Kanäle als Geräte</h3>
13
+ <p>Die Option <i>Channels</i> legt fest, wie Home Assistant ein Homematic-Gerät mit mehreren Kanälen sieht:</p>
14
+ <ul>
15
+ <li><b>one device</b> (Standard): ein Home-Assistant-Gerät pro Homematic-Gerät, wie bisher;</li>
16
+ <li><b>child devices</b>: jeder Kanal wird ein Untergerät (Child Device) des Geräts (Home Assistant 2026.11
17
+ oder neuer). Die Entitäten ziehen an Ort und Stelle um: IDs, Verlauf und Einstellungen bleiben, und der
18
+ Weg zurück geht jederzeit. Ein Untergerät liegt im Bereich seines Geräts, bis man ihm in Home Assistant
19
+ einen anderen gibt (für MQTT-Untergeräte nimmt Home Assistant keinen Bereichsvorschlag an). Ein älteres
20
+ Home Assistant lehnt die ganze Gerätekonfiguration ab („not a valid option at 'cdevs'“ im Log);</li>
21
+ <li><b>own devices</b>: jeder Kanal wird ein eigenes Gerät, im Raum seines Kanals, mit dem Homematic-Gerät
22
+ verknüpft. Der Wechsel dorthin oder zurück entfernt die Entitäten und legt sie am neuen Gerät neu an: Home
23
+ Assistant stellt ihre Entitäts-IDs und Bereiche meist wieder her, die Einstellungen der Geräte selbst
24
+ aber nicht, und Automationen, die ein Gerät über seine Geräte-ID ansprechen, müssen angepasst werden.</li>
25
+ </ul>
26
+ <p>Ein Kanal ist hier eine Funktion: der Kanal eines HmIP-Schalt-, Dimm- oder Rollladenaktors zählt mit seinen
27
+ drei virtuellen Kanälen als einer, eine Taste oder ein Eingang als einer. Der Wartungskanal (<code>:0</code>:
28
+ Erreichbarkeit, Batterie, Signal) bleibt immer am Gerät, und ein Gerät mit nur einer Funktion (ein
29
+ Zwischenstecker, ein Kontakt) wird nicht aufgeteilt. Die Hauptentität eines Kanals trägt den Namen ihres
30
+ Geräts, die übrigen den ihres Datenpunkts.</p>
31
+ <p>In der Gerätetabelle öffnet der Pfeil die Kanäle eines Geräts. Pro Gerät übersteuert eine Einstellung die
32
+ Option des Nodes; pro Kanal schaltet <i>publish</i> ihn für Home Assistant ab (seine MQTT-Topics bleiben), und
33
+ die Auswahl legt ihn ans Gerät, in ein Untergerät oder in ein eigenes Gerät, egal was Gerät und Node sagen. Ein
34
+ unveränderter Kanal folgt seinem Gerät, das Gerät dem Node. Die Sammelaktion unter dem Filter gilt für jedes
35
+ aufgelistete, angehakte Gerät oder für dessen Kanäle, auf die der Filter passt (z. B. alle Kanäle im Raum
36
+ „Küche“: eigenes Gerät); gespeichert werden die einzelnen Werte.</p>
37
+ <p>Ein Kanal, der nicht mehr veröffentlicht wird oder in ein anderes Gerät wandert, wird beim nächsten Deploy
38
+ aus Home Assistant entfernt. Was er veröffentlicht hat, merkt sich der Node in
39
+ <code>ccu_homeassistant_&lt;Node-ID&gt;.json</code> im Benutzerverzeichnis von Node-RED.</p>
13
40
  <h3>Entitäten</h3>
14
41
  <p>Schalter, Dimmer (light), Rollladen/Jalousie (cover), Thermostate (climate), Kontakte/Bewegung/
15
42
  Rauch/Wasser (binary_sensor), Tasten (event), KeyMatic (lock), Energie/Wetter (sensor). Mit der
@@ -21,7 +48,8 @@
21
48
  <code>&lt;Präfix&gt;/status</code>) anschließt, bekommt beides nach jedem Neustart von Home Assistant
22
49
  neu; dessen <code>offline</code> auf diesem Topic wird ignoriert.</p>
23
50
  <h3>Voraussetzungen</h3>
24
- <p>Home Assistant ≥ 2024.11 (gerätebasierte Discovery).</p>
51
+ <p>Home Assistant ≥ 2024.11 (gerätebasierte Discovery); für Kanäle als Untergeräte Home Assistant
52
+ ≥ 2026.11.</p>
25
53
  <h3>Verfügbarkeit</h3>
26
54
  <p>Die Verfügbarkeit der Geräte wird aus dem UNREACH-Datenpunkt des Wartungskanals abgeleitet
27
55
  (<code>…:0/UNREACH</code>). Home Assistant zeigt alle Entitäten eines Geräts als „nicht verfügbar“,
@@ -1,5 +1,7 @@
1
1
  <script type="text/html" data-help-name="ccu-poll">
2
2
  <p>Führt einen sofortigen Poll von ReGaHSS Systemvariablen durch.</p>
3
+ <p><b>openccu-lite:</b> die Variablen und Programme des Addons <i>Logic</i> kommen als Ereignisse; es gibt nichts
4
+ zu pollen, eine Nachricht bewirkt nichts.</p>
3
5
  <p>Dieser Node ist dazu vorgesehen die Änderung von Systemvariablen mit möglichst geringer Verzögerung zu empfangen.
4
6
  Hierzu kann man ein Programm auf der CCU anlegen dass bei Änderung von Variablen einen virtuellen Taster betätigt.
5
7
  In Node-RED wird dann ein <i>rpc event</i> oder <i>value</i> Node so konfiguriert dass er diese
@@ -1,5 +1,10 @@
1
1
  <script type="text/html" data-help-name="ccu-program">
2
2
  <p>Führt ein ReGaHSS Programm aus.</p>
3
+ <p><b>openccu-lite:</b> die Programme kommen vom Addon <i>Logic</i> über die lite-rpc des Systems (Schnittstelle
4
+ <code>Logic</code>). Ein boolean schaltet <code>ACTIVE</code> des Programms; alles andere startet es wie auf der
5
+ CCU - das erste <i>Dann</i>, ohne die Bedingungen zu prüfen (<code>RUN_THEN</code>). Der Ausgang folgt
6
+ <code>ACTIVE</code> und jedem Lauf des Programms. Ohne das Addon zeigt der Node <i>Logic addon not
7
+ installed</i>.</p>
3
8
  <h3>Inputs</h3>
4
9
  <dl class="message-properties">
5
10
  <dt>payload
@@ -1,5 +1,12 @@
1
1
  <script type="text/html" data-help-name="ccu-sysvar">
2
2
  <p>Setzen und lesen von ReGaHSS Systemvariablen.</p>
3
+ <p><b>openccu-lite:</b> das System hat keine ReGaHSS; die Systemvariablen kommen vom Addon <i>Logic</i>, das sie
4
+ als Geräte seiner Schnittstelle <code>Logic</code> über die lite-rpc des Systems anbietet. Der Node findet eine
5
+ Variable wie auf der CCU über ihren Namen und bekommt bei jedem Schreiben ein Ereignis (<i>Nur geänderte Werte ausgeben</i>
6
+ lässt das Schreiben desselben Werts weg). Die Verbindung braucht lite-rpc (ein Token mit <code>rpc:read</code>
7
+ und <code>rpc:operate</code>, oder RedMatic auf dem System selbst); ohne das Addon zeigt der Node
8
+ <i>Logic addon not installed</i>. <code>msg.iface</code> ist <code>Logic</code>, <code>msg.key</code> der
9
+ Schlüssel der Variablen und <code>msg.address</code> ihr Kanal (<code>var-&lt;key&gt;:1</code>).</p>
3
10
  <h3>Inputs</h3>
4
11
  <dl class="message-properties">
5
12
  <dt>payload
@@ -7,9 +7,35 @@
7
7
  <p>Connect the output to the same <b>mqtt out</b> node as the ccu-mqtt node. The node sends
8
8
  <code>msg.topic</code>, <code>msg.payload</code> and <code>msg.retain</code>.</p>
9
9
  <h3>Device selection</h3>
10
- <p>Only checked devices are announced to Home Assistant (one HA device per Homematic device).
11
- Unchecking a previously checked device publishes an empty config on the next deploy, which
10
+ <p>Only checked devices are announced to Home Assistant. Unchecking a previously checked device publishes an empty config on the next deploy, which
12
11
  removes the device from Home Assistant.</p>
12
+ <h3>Channels as devices</h3>
13
+ <p>The option <i>Channels</i> decides how Home Assistant sees a Homematic device with several channels:</p>
14
+ <ul>
15
+ <li><b>one device</b> (the default): one Home Assistant device per Homematic device, as before;</li>
16
+ <li><b>child devices</b>: each channel becomes a child device of the device (Home Assistant 2026.11 or
17
+ newer). The entities move in place: their IDs, history and settings stay, and switching back is
18
+ possible at any time. A child device is in the area of its device until you give it another one in Home
19
+ Assistant (Home Assistant takes no suggested area for an MQTT child device). An older Home Assistant
20
+ refuses the whole device configuration ("not a valid option at 'cdevs'" in its log);</li>
21
+ <li><b>own devices</b>: each channel becomes a device of its own, in the room of its channel, linked to the
22
+ Homematic device. Switching to or from it removes the entities and creates them again under the new
23
+ device: Home Assistant usually restores their entity IDs and areas, but the settings of the devices
24
+ themselves do not carry over, and automations that target a device by its device ID must be adjusted.</li>
25
+ </ul>
26
+ <p>A channel here is a function: an HmIP switch, dimmer or blind actuator's channel with its three virtual
27
+ channels counts as one, a key or an input as one. The maintenance channel (<code>:0</code>: reachability,
28
+ battery, signal) always stays on the device, and a device with a single function (a plug, a contact) is not
29
+ split. The main entity of a channel takes the name of its device, the others the name of their datapoint.</p>
30
+ <p>In the device table the arrow opens a device's channels. Per device a setting overrides the node's option;
31
+ per channel <i>publish</i> switches it off for Home Assistant (its MQTT topics stay) and the select puts it
32
+ on the device, into a child device or into a device of its own, whatever the device and node say. A channel
33
+ left as it is follows its device, the device the node. The bulk action under the filter applies to every
34
+ listed, ticked device, or to its channels that match the filter (e.g. all channels in the room "Kitchen":
35
+ own device); the single values are stored.</p>
36
+ <p>A channel that is no longer published, or moves to another device, is removed from Home Assistant on the
37
+ next deploy. The node remembers what it published in <code>ccu_homeassistant_&lt;node id&gt;.json</code> in
38
+ the Node-RED user directory.</p>
13
39
  <h3>Entities</h3>
14
40
  <p>Switches, dimmers (light), blinds/shutters (cover), thermostats (climate), contacts/motion/
15
41
  smoke/water (binary_sensor), keys (event), KeyMatic (lock), energy/weather (sensor). With the
@@ -21,7 +47,8 @@
21
47
  the input to get both again after every Home Assistant restart; its <code>offline</code> on that
22
48
  topic is ignored.</p>
23
49
  <h3>Requirements</h3>
24
- <p>Home Assistant ≥ 2024.11 (device-based discovery).</p>
50
+ <p>Home Assistant ≥ 2024.11 (device-based discovery); for channels as child devices Home Assistant
51
+ ≥ 2026.11.</p>
25
52
  <h3>Availability</h3>
26
53
  <p>Device availability is derived from the UNREACH datapoint of the maintenance channel
27
54
  (<code>…:0/UNREACH</code>). Home Assistant shows every entity of a device as "unavailable" until
@@ -1,5 +1,7 @@
1
1
  <script type="text/html" data-help-name="ccu-poll">
2
2
  <p>Triggers an immediate polling of Sysvars from ReGaHSS.</p>
3
+ <p><b>openccu-lite:</b> the <i>Logic</i> addon's variables and programs arrive as events; there is nothing to
4
+ poll, a message does nothing.</p>
3
5
  <p>This node is intended to receive changes of variables with lower latency. You can create a CCU Program that
4
6
  reacts to variable changes by pressing a virtual button, this virtual button presses can then be received by a
5
7
  <i>value</i> or <i>rpc event</i> node that triggers an update of the variables through the <i>ccu poll</i>
@@ -1,5 +1,10 @@
1
1
  <script type="text/html" data-help-name="ccu-program">
2
2
  <p>Executes a ReGaHSS program.</p>
3
+ <p><b>openccu-lite:</b> the programs come from the <i>Logic</i> addon through the system's lite-rpc (interface
4
+ <code>Logic</code>). A boolean switches the program's <code>ACTIVE</code>; anything else starts it as on a CCU -
5
+ the first <i>Then</i> without looking at the conditions (<code>RUN_THEN</code>). The output follows
6
+ <code>ACTIVE</code> and every run of the program. Without the addon the node shows <i>Logic addon not
7
+ installed</i>.</p>
3
8
  <h3>Inputs</h3>
4
9
  <dl class="message-properties">
5
10
  <dt>payload
@@ -1,5 +1,12 @@
1
1
  <script type="text/html" data-help-name="ccu-sysvar">
2
2
  <p>Set and read ReGaHSS system variables.</p>
3
+ <p><b>openccu-lite:</b> the system has no ReGaHSS; the system variables come from the <i>Logic</i> addon,
4
+ which offers them as devices of its interface <code>Logic</code> through the system's lite-rpc. The node finds a
5
+ variable by its name, as on a CCU, and gets an event at every write (<i>Emit changed values only</i> leaves out a write of
6
+ the same value). The connection needs lite-rpc (a token with <code>rpc:read</code> and <code>rpc:operate</code>,
7
+ or RedMatic on the system itself); without the addon the node shows <i>Logic addon not installed</i>.
8
+ <code>msg.iface</code> is <code>Logic</code>, <code>msg.key</code> the variable's key and
9
+ <code>msg.address</code> its channel (<code>var-&lt;key&gt;:1</code>).</p>
3
10
  <h3>Inputs</h3>
4
11
  <dl class="message-properties">
5
12
  <dt>payload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-ccu",
3
- "version": "4.12.0",
3
+ "version": "4.14.0",
4
4
  "license": "MIT",
5
5
  "main": "none",
6
6
  "keywords": [