node-red-contrib-unifi-ultimate 1.0.2 → 1.0.3

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.
@@ -5,6 +5,16 @@ const {
5
5
  resolveScopedIdentifiers
6
6
  } = require("./utils/unifi-network-device-registry");
7
7
  const { extractNetworkData } = require("./utils/unifi-network-utils");
8
+ const {
9
+ buildStatusTimestampText,
10
+ appendStatusTimestamp,
11
+ resolveNodeName,
12
+ resolveDeviceName,
13
+ extractDeviceNameFromPayload,
14
+ attachDeviceNameToPayload,
15
+ attachDetails,
16
+ buildErrorOutputMessage
17
+ } = require("./utils/common-utils");
8
18
  const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
9
19
 
10
20
  function normalizeString(value) {
@@ -120,73 +130,6 @@ function resolvePayloadBoolean(value) {
120
130
  return null;
121
131
  }
122
132
 
123
- function resolveNodeName(value) {
124
- return String(value || "").trim();
125
- }
126
-
127
- function resolveDeviceName(value) {
128
- return String(value || "").trim();
129
- }
130
-
131
- function extractDeviceNameFromPayload(payload) {
132
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
133
- return "";
134
- }
135
-
136
- return resolveDeviceName(
137
- payload.name
138
- || payload.displayName
139
- || payload.hostname
140
- || payload.alias
141
- || payload.full_name
142
- || payload.macAddress
143
- || payload.id
144
- );
145
- }
146
-
147
- function attachDeviceNameToPayload(payload, deviceName) {
148
- if (!deviceName) {
149
- return payload;
150
- }
151
-
152
- if (payload && typeof payload === "object" && !Array.isArray(payload)) {
153
- return {
154
- ...payload,
155
- deviceName
156
- };
157
- }
158
-
159
- return payload;
160
- }
161
-
162
- function attachDetails(outputMsg, details) {
163
- if (!outputMsg || typeof outputMsg !== "object" || Array.isArray(outputMsg)) {
164
- return;
165
- }
166
- if (!details || typeof details !== "object" || Array.isArray(details)) {
167
- return;
168
- }
169
-
170
- outputMsg.details = {
171
- ...(outputMsg.details && typeof outputMsg.details === "object" && !Array.isArray(outputMsg.details)
172
- ? outputMsg.details
173
- : {}),
174
- ...details
175
- };
176
- }
177
-
178
- function buildStatusTimestampText() {
179
- const now = new Date();
180
- const time = now.toTimeString().split(" ")[0];
181
- return `(day ${now.getDate()}, ${time})`;
182
- }
183
-
184
- function appendStatusTimestamp(text) {
185
- const normalized = String(text === undefined || text === null ? "" : text).trim();
186
- const suffix = buildStatusTimestampText();
187
- return normalized ? `${normalized} ${suffix}` : suffix;
188
- }
189
-
190
133
  function resolveNumericPortIndex(value) {
191
134
  const parsed = Number(value);
192
135
  return Number.isFinite(parsed) ? Math.trunc(parsed) : NaN;
@@ -821,6 +764,7 @@ module.exports = function(RED) {
821
764
  }
822
765
  } catch (error) {
823
766
  setNodeStatus({ fill: "red", shape: "ring", text: "error" });
767
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
824
768
  if (typeof done === "function") {
825
769
  done(error);
826
770
  } else {
@@ -19,10 +19,10 @@
19
19
  autoEmitInterval: { value: 60, validate: RED.validators.number() }
20
20
  },
21
21
  inputs: 1,
22
- outputs: 1,
22
+ outputs: 2,
23
23
  icon: "unifi-u-logo-light-network.svg",
24
24
  paletteLabel: "NETWORK",
25
- outputLabels: ["result"],
25
+ outputLabels: ["result", "error"],
26
26
  label: function () {
27
27
  return this.name || this.deviceId || "Unifi Network";
28
28
  },
@@ -1287,16 +1287,32 @@
1287
1287
  <li>Input message properties are ignored by this node.</li>
1288
1288
  </ul>
1289
1289
 
1290
- <h3>Output</h3>
1291
- <ul>
1292
- <li>Output 1 emits a new message containing the current state or primary capability response.</li>
1293
- <li><code>msg.payload</code> contains the response payload.</li>
1294
- <li><code>msg.topic</code>: node name from the editor.</li>
1295
- <li><code>msg.deviceName</code>: remembered/observed selected item name.</li>
1296
- <li><code>msg.eventName</code>: trigger/event that produced the message.</li>
1297
- <li><code>msg.details.unifiNetwork</code>: standardized metadata for the selected item and capability.</li>
1298
- </ul>
1299
- <p>Example output:</p>
1290
+ <h3>Outputs</h3>
1291
+ <dl class="message-properties">
1292
+ <dt>Output 1 — result</dt>
1293
+ <dd>Emitted when the action completes successfully.</dd>
1294
+ <dt class="optional">msg.payload</dt>
1295
+ <dd>Response payload from the UniFi API.</dd>
1296
+ <dt class="optional">msg.topic</dt>
1297
+ <dd>Node name from the editor.</dd>
1298
+ <dt class="optional">msg.deviceName</dt>
1299
+ <dd>Remembered/observed name of the selected item.</dd>
1300
+ <dt class="optional">msg.eventName</dt>
1301
+ <dd>Trigger or event that produced the message.</dd>
1302
+ <dt class="optional">msg.details.unifiNetwork</dt>
1303
+ <dd>Standardized metadata for the selected item and capability.</dd>
1304
+ </dl>
1305
+ <dl class="message-properties">
1306
+ <dt>Output 2 — error</dt>
1307
+ <dd>Emitted when the action fails (API error, timeout, or configuration problem). The node status also turns red. Errors are additionally forwarded to any connected <code>catch</code> node.</dd>
1308
+ <dt class="optional">msg.payload</dt>
1309
+ <dd><code>null</code></dd>
1310
+ <dt class="optional">msg.topic</dt>
1311
+ <dd>Node name from the editor.</dd>
1312
+ <dt class="optional">msg.error.message</dt>
1313
+ <dd>Human-readable error description.</dd>
1314
+ </dl>
1315
+ <p>Example output (pin 1):</p>
1300
1316
  <pre><code>{
1301
1317
  "topic": "Switch Soffitta",
1302
1318
  "deviceName": "Soffitta",
@@ -1315,5 +1331,11 @@
1315
1331
  "source": "request"
1316
1332
  }
1317
1333
  }
1334
+ }</code></pre>
1335
+ <p>Example output (pin 2 — error):</p>
1336
+ <pre><code>{
1337
+ "topic": "Switch Soffitta",
1338
+ "payload": null,
1339
+ "error": { "message": "Request timed out" }
1318
1340
  }</code></pre>
1319
1341
  </script>
@@ -8,6 +8,18 @@ const {
8
8
  resolveScopedIdentifiers
9
9
  } = require("./utils/unifi-network-device-registry");
10
10
  const { extractNetworkData } = require("./utils/unifi-network-utils");
11
+ const {
12
+ parseBoolean,
13
+ parseIntervalSeconds,
14
+ buildStatusTimestampText,
15
+ appendStatusTimestamp,
16
+ resolveNodeName,
17
+ resolveDeviceName,
18
+ extractDeviceNameFromPayload,
19
+ attachDeviceNameToPayload,
20
+ attachDetails,
21
+ buildErrorOutputMessage
22
+ } = require("./utils/common-utils");
11
23
  const UNOFFICIAL_NETWORK_STREAM_CAPABILITY = "observeUnofficialEvents";
12
24
  const UNOFFICIAL_POLL_INTERVAL_MS = 3000;
13
25
  const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
@@ -47,18 +59,6 @@ function resolveCapabilityConfig(configuredCapabilityConfig) {
47
59
  return parseCapabilityConfig(configuredCapabilityConfig);
48
60
  }
49
61
 
50
- function parseBoolean(value) {
51
- return value === true || value === "true" || value === 1 || value === "1";
52
- }
53
-
54
- function parseIntervalSeconds(value, fallback) {
55
- const numeric = Number(value);
56
- if (!Number.isFinite(numeric) || numeric < 5) {
57
- return fallback;
58
- }
59
- return Math.trunc(numeric);
60
- }
61
-
62
62
  function normalizeIdentifierKey(value) {
63
63
  return String(value || "").trim().toLowerCase().replace(/[^a-z0-9]/g, "");
64
64
  }
@@ -149,73 +149,6 @@ function buildNodeStatus(deviceType, payload) {
149
149
  return baseName || normalizedType || "ready";
150
150
  }
151
151
 
152
- function resolveNodeName(value) {
153
- return String(value || "").trim();
154
- }
155
-
156
- function resolveDeviceName(value) {
157
- return String(value || "").trim();
158
- }
159
-
160
- function extractDeviceNameFromPayload(payload) {
161
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
162
- return "";
163
- }
164
-
165
- return resolveDeviceName(
166
- payload.name
167
- || payload.displayName
168
- || payload.hostname
169
- || payload.alias
170
- || payload.full_name
171
- || payload.macAddress
172
- || payload.id
173
- );
174
- }
175
-
176
- function attachDeviceNameToPayload(payload, deviceName) {
177
- if (!deviceName) {
178
- return payload;
179
- }
180
-
181
- if (payload && typeof payload === "object" && !Array.isArray(payload)) {
182
- return {
183
- ...payload,
184
- deviceName
185
- };
186
- }
187
-
188
- return payload;
189
- }
190
-
191
- function attachDetails(outputMsg, details) {
192
- if (!outputMsg || typeof outputMsg !== "object" || Array.isArray(outputMsg)) {
193
- return;
194
- }
195
- if (!details || typeof details !== "object" || Array.isArray(details)) {
196
- return;
197
- }
198
-
199
- outputMsg.details = {
200
- ...(outputMsg.details && typeof outputMsg.details === "object" && !Array.isArray(outputMsg.details)
201
- ? outputMsg.details
202
- : {}),
203
- ...details
204
- };
205
- }
206
-
207
- function buildStatusTimestampText() {
208
- const now = new Date();
209
- const time = now.toTimeString().split(" ")[0];
210
- return `(day ${now.getDate()}, ${time})`;
211
- }
212
-
213
- function appendStatusTimestamp(text) {
214
- const normalized = String(text === undefined || text === null ? "" : text).trim();
215
- const suffix = buildStatusTimestampText();
216
- return normalized ? `${normalized} ${suffix}` : suffix;
217
- }
218
-
219
152
  function extractNetworkEventName(payload) {
220
153
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
221
154
  return "event";
@@ -1116,6 +1049,7 @@ module.exports = function(RED) {
1116
1049
  invokeCapability(node.send.bind(node), "interval")
1117
1050
  .catch((error) => {
1118
1051
  setNodeStatus({ fill: "red", shape: "ring", text: "auto error" });
1052
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
1119
1053
  node.error(error);
1120
1054
  })
1121
1055
  .finally(() => {
@@ -1146,6 +1080,7 @@ module.exports = function(RED) {
1146
1080
  }
1147
1081
  } catch (error) {
1148
1082
  setNodeStatus({ fill: "red", shape: "ring", text: "error" });
1083
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
1149
1084
  if (typeof done === "function") {
1150
1085
  done(error);
1151
1086
  } else {
@@ -15,10 +15,10 @@
15
15
  offlineHysteresis: { value: 30, required: true, validate: RED.validators.number() }
16
16
  },
17
17
  inputs: 0,
18
- outputs: 1,
18
+ outputs: 2,
19
19
  icon: "unifi-u-logo-light-network.svg",
20
20
  paletteLabel: "Presence Detection",
21
- outputLabels: ["presence"],
21
+ outputLabels: ["presence", "error"],
22
22
  label: function () {
23
23
  return this.name || "Presence Detection";
24
24
  },
@@ -535,18 +535,36 @@
535
535
  <li>No input pin in this mode: checks run automatically at startup and then on the configured cadence through the shared config scheduler.</li>
536
536
  </ul>
537
537
 
538
- <h3>Output</h3>
539
- <ul>
540
- <li>The node emits a new message when the debounced presence state changes.</li>
541
- <li><code>msg.payload</code>: <code>true</code> when present, <code>false</code> when absent.</li>
542
- <li><code>msg.present</code>: same boolean presence value.</li>
543
- <li><code>msg.topic</code>: node name from the editor.</li>
544
- <li><code>msg.deviceName</code>: remembered selected client name.</li>
545
- <li><code>msg.eventName</code>: reason/source that produced the message.</li>
546
- <li><code>msg.details.client</code>: last known client object when available.</li>
547
- <li><code>msg.details.unifiNetworkPresence</code>: metadata including site/client ids and hysteresis settings.</li>
548
- </ul>
549
- <p>Example output:</p>
538
+ <h3>Outputs</h3>
539
+ <dl class="message-properties">
540
+ <dt>Output 1 — presence</dt>
541
+ <dd>Emitted when the debounced presence state changes.</dd>
542
+ <dt class="optional">msg.payload</dt>
543
+ <dd><code>true</code> when the client is present, <code>false</code> when absent.</dd>
544
+ <dt class="optional">msg.present</dt>
545
+ <dd>Same boolean presence value as <code>msg.payload</code>.</dd>
546
+ <dt class="optional">msg.topic</dt>
547
+ <dd>Node name from the editor.</dd>
548
+ <dt class="optional">msg.deviceName</dt>
549
+ <dd>Remembered name of the selected client.</dd>
550
+ <dt class="optional">msg.eventName</dt>
551
+ <dd>Reason or source that produced the message.</dd>
552
+ <dt class="optional">msg.details.client</dt>
553
+ <dd>Last known client object when available.</dd>
554
+ <dt class="optional">msg.details.unifiNetworkPresence</dt>
555
+ <dd>Metadata including site/client ids and hysteresis settings.</dd>
556
+ </dl>
557
+ <dl class="message-properties">
558
+ <dt>Output 2 — error</dt>
559
+ <dd>Emitted when a presence poll fails (API error, timeout, or configuration problem). The node status also turns red. Errors are additionally forwarded to any connected <code>catch</code> node.</dd>
560
+ <dt class="optional">msg.payload</dt>
561
+ <dd><code>null</code></dd>
562
+ <dt class="optional">msg.topic</dt>
563
+ <dd>Node name from the editor.</dd>
564
+ <dt class="optional">msg.error.message</dt>
565
+ <dd>Human-readable error description.</dd>
566
+ </dl>
567
+ <p>Example output (pin 1):</p>
550
568
  <pre><code>{
551
569
  "topic": "iPhone Massimo Presence",
552
570
  "deviceName": "iPhone-Massimo",
@@ -560,5 +578,11 @@
560
578
  "reason": "connected"
561
579
  }
562
580
  }
581
+ }</code></pre>
582
+ <p>Example output (pin 2 — error):</p>
583
+ <pre><code>{
584
+ "topic": "iPhone Massimo Presence",
585
+ "payload": null,
586
+ "error": { "message": "Presence polling failed" }
563
587
  }</code></pre>
564
588
  </script>
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  const { decodeScopedDeviceId } = require("./utils/unifi-network-device-registry");
4
+ const {
5
+ buildStatusTimestampText,
6
+ appendStatusTimestamp,
7
+ resolveNodeName,
8
+ resolveDeviceName,
9
+ extractDeviceNameFromPayload,
10
+ attachDetails,
11
+ buildErrorOutputMessage
12
+ } = require("./utils/common-utils");
4
13
  const DEFAULT_REQUEST_TIMEOUT_MS = 8000;
5
14
 
6
15
  function parsePositiveSeconds(value, fallbackValue) {
@@ -25,58 +34,6 @@ function resolveClientId(configuredClientId) {
25
34
  return String(configuredClientId || "").trim();
26
35
  }
27
36
 
28
- function resolveNodeName(value) {
29
- return String(value || "").trim();
30
- }
31
-
32
- function resolveDeviceName(value) {
33
- return String(value || "").trim();
34
- }
35
-
36
- function extractDeviceNameFromClient(client) {
37
- if (!client || typeof client !== "object" || Array.isArray(client)) {
38
- return "";
39
- }
40
-
41
- return resolveDeviceName(
42
- client.name
43
- || client.displayName
44
- || client.hostname
45
- || client.alias
46
- || client.full_name
47
- || client.macAddress
48
- || client.id
49
- );
50
- }
51
-
52
- function attachDetails(outputMsg, details) {
53
- if (!outputMsg || typeof outputMsg !== "object" || Array.isArray(outputMsg)) {
54
- return;
55
- }
56
- if (!details || typeof details !== "object" || Array.isArray(details)) {
57
- return;
58
- }
59
-
60
- outputMsg.details = {
61
- ...(outputMsg.details && typeof outputMsg.details === "object" && !Array.isArray(outputMsg.details)
62
- ? outputMsg.details
63
- : {}),
64
- ...details
65
- };
66
- }
67
-
68
- function buildStatusTimestampText() {
69
- const now = new Date();
70
- const time = now.toTimeString().split(" ")[0];
71
- return `(day ${now.getDate()}, ${time})`;
72
- }
73
-
74
- function appendStatusTimestamp(text) {
75
- const normalized = String(text === undefined || text === null ? "" : text).trim();
76
- const suffix = buildStatusTimestampText();
77
- return normalized ? `${normalized} ${suffix}` : suffix;
78
- }
79
-
80
37
  module.exports = function(RED) {
81
38
  function UnifiNetworkPresenceNode(config) {
82
39
  RED.nodes.createNode(this, config);
@@ -125,7 +82,7 @@ module.exports = function(RED) {
125
82
  }
126
83
 
127
84
  function resolveOutputDeviceName(payload) {
128
- const extracted = extractDeviceNameFromClient(payload) || extractDeviceNameFromClient(node.lastKnownClient);
85
+ const extracted = extractDeviceNameFromPayload(payload) || extractDeviceNameFromPayload(node.lastKnownClient);
129
86
  if (extracted) {
130
87
  node.deviceName = extracted;
131
88
  return extracted;
@@ -290,7 +247,9 @@ module.exports = function(RED) {
290
247
 
291
248
  setNodeStatus({ fill: "red", shape: "ring", text: "error" });
292
249
  const errorMessage = String(snapshot && (snapshot.error || snapshot.message) || "Presence polling failed");
293
- node.error(new Error(errorMessage));
250
+ const presenceError = new Error(errorMessage);
251
+ node.send([null, buildErrorOutputMessage(presenceError, node.name)]);
252
+ node.error(presenceError);
294
253
  }
295
254
 
296
255
  async function requestPresenceSnapshot(source) {
@@ -341,6 +300,8 @@ module.exports = function(RED) {
341
300
  done();
342
301
  }
343
302
  } catch (error) {
303
+ setNodeStatus({ fill: "red", shape: "ring", text: "error" });
304
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
344
305
  if (typeof done === "function") {
345
306
  done(error);
346
307
  } else {
@@ -388,6 +349,7 @@ module.exports = function(RED) {
388
349
  processPresenceSnapshot(snapshot);
389
350
  }).catch((error) => {
390
351
  setNodeStatus({ fill: "red", shape: "ring", text: "error" });
352
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
391
353
  node.error(error);
392
354
  });
393
355
  }
@@ -18,10 +18,10 @@
18
18
  autoEmitInterval: { value: 60, validate: RED.validators.number() }
19
19
  },
20
20
  inputs: 1,
21
- outputs: 1,
21
+ outputs: 2,
22
22
  icon: "unifi-u-logo-light-protect.svg",
23
23
  paletteLabel: "PROTECT",
24
- outputLabels: ["result"],
24
+ outputLabels: ["result", "error"],
25
25
  label: function () {
26
26
  return this.name || this.deviceId || "Unifi Protect";
27
27
  },
@@ -1162,16 +1162,32 @@
1162
1162
  <li>Input message properties are ignored by this node.</li>
1163
1163
  </ul>
1164
1164
 
1165
- <h3>Output</h3>
1166
- <ul>
1167
- <li>A single output pin emits state and event messages for the selected device.</li>
1168
- <li><code>msg.topic</code>: node name from the editor.</li>
1169
- <li><code>msg.deviceName</code>: remembered/observed selected device name.</li>
1170
- <li><code>msg.eventName</code>: trigger/event that produced the message.</li>
1171
- <li><code>msg.details.unifiProtect</code>: standardized metadata for the device and selected capability.</li>
1172
- <li><code>msg.details.raw</code>: raw event/context payload when available.</li>
1173
- </ul>
1174
- <p>Example output:</p>
1165
+ <h3>Outputs</h3>
1166
+ <dl class="message-properties">
1167
+ <dt>Output 1 — result</dt>
1168
+ <dd>Emits state and live event messages for the selected device. When <code>Receive Events</code> is active, both state and event messages use this pin.</dd>
1169
+ <dt class="optional">msg.topic</dt>
1170
+ <dd>Node name from the editor.</dd>
1171
+ <dt class="optional">msg.deviceName</dt>
1172
+ <dd>Remembered/observed name of the selected device.</dd>
1173
+ <dt class="optional">msg.eventName</dt>
1174
+ <dd>Trigger or event that produced the message.</dd>
1175
+ <dt class="optional">msg.details.unifiProtect</dt>
1176
+ <dd>Standardized metadata for the device and selected capability.</dd>
1177
+ <dt class="optional">msg.details.raw</dt>
1178
+ <dd>Raw event or context payload when available.</dd>
1179
+ </dl>
1180
+ <dl class="message-properties">
1181
+ <dt>Output 2 — error</dt>
1182
+ <dd>Emitted when the action fails (API error, timeout, or configuration problem). The node status also turns red. Errors are additionally forwarded to any connected <code>catch</code> node.</dd>
1183
+ <dt class="optional">msg.payload</dt>
1184
+ <dd><code>null</code></dd>
1185
+ <dt class="optional">msg.topic</dt>
1186
+ <dd>Node name from the editor.</dd>
1187
+ <dt class="optional">msg.error.message</dt>
1188
+ <dd>Human-readable error description.</dd>
1189
+ </dl>
1190
+ <p>Example output (pin 1):</p>
1175
1191
  <pre><code>{
1176
1192
  "topic": "Front Door Camera",
1177
1193
  "deviceName": "Front Door Camera",
@@ -1193,5 +1209,11 @@
1193
1209
  "source": "events"
1194
1210
  }
1195
1211
  }
1212
+ }</code></pre>
1213
+ <p>Example output (pin 2 — error):</p>
1214
+ <pre><code>{
1215
+ "topic": "Front Door Camera",
1216
+ "payload": null,
1217
+ "error": { "message": "Request timed out" }
1196
1218
  }</code></pre>
1197
1219
  </script>
@@ -8,6 +8,18 @@ const {
8
8
  resolveObservableState,
9
9
  resolveObservableEventValue
10
10
  } = require("./utils/unifi-protect-device-registry");
11
+ const {
12
+ parseBoolean,
13
+ parseIntervalSeconds,
14
+ buildStatusTimestampText,
15
+ appendStatusTimestamp,
16
+ resolveNodeName,
17
+ resolveDeviceName,
18
+ extractDeviceNameFromPayload,
19
+ attachDeviceNameToPayload,
20
+ attachDetails,
21
+ buildErrorOutputMessage
22
+ } = require("./utils/common-utils");
11
23
  const DEFAULT_REQUEST_TIMEOUT_MS = 15000;
12
24
 
13
25
  function resolveDeviceType(configuredDeviceType) {
@@ -45,18 +57,6 @@ function resolveCapabilityConfig(configuredCapabilityConfig) {
45
57
  return parseCapabilityConfig(configuredCapabilityConfig);
46
58
  }
47
59
 
48
- function parseBoolean(value) {
49
- return value === true || value === "true" || value === 1 || value === "1";
50
- }
51
-
52
- function parseIntervalSeconds(value, fallback) {
53
- const numeric = Number(value);
54
- if (!Number.isFinite(numeric) || numeric < 5) {
55
- return fallback;
56
- }
57
- return Math.trunc(numeric);
58
- }
59
-
60
60
  function buildNodeStatus(deviceType, payload) {
61
61
  const label = payload && payload.name ? payload.name : deviceType;
62
62
  const state = payload && payload.state ? payload.state : "ready";
@@ -75,70 +75,6 @@ function requiresDeviceSpecificCapabilityValidation(deviceType, capabilityId) {
75
75
  ].includes(String(capabilityId || "").trim());
76
76
  }
77
77
 
78
- function resolveNodeName(value) {
79
- return String(value || "").trim();
80
- }
81
-
82
- function resolveDeviceName(value) {
83
- return String(value || "").trim();
84
- }
85
-
86
- function extractDeviceNameFromPayload(payload) {
87
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
88
- return "";
89
- }
90
-
91
- return resolveDeviceName(
92
- payload.name
93
- || payload.displayName
94
- || payload.alias
95
- || payload.full_name
96
- || payload.id
97
- );
98
- }
99
-
100
- function attachDeviceNameToPayload(payload, deviceName) {
101
- if (!deviceName) {
102
- return payload;
103
- }
104
-
105
- if (payload && typeof payload === "object" && !Array.isArray(payload)) {
106
- return {
107
- ...payload,
108
- deviceName
109
- };
110
- }
111
-
112
- return payload;
113
- }
114
-
115
- function attachDetails(outputMsg, details) {
116
- if (!details || typeof details !== "object" || Array.isArray(details)) {
117
- return;
118
- }
119
-
120
- const currentDetails = outputMsg.details && typeof outputMsg.details === "object" && !Array.isArray(outputMsg.details)
121
- ? outputMsg.details
122
- : {};
123
-
124
- outputMsg.details = {
125
- ...currentDetails,
126
- ...details
127
- };
128
- }
129
-
130
- function buildStatusTimestampText() {
131
- const now = new Date();
132
- const time = now.toTimeString().split(" ")[0];
133
- return `(day ${now.getDate()}, ${time})`;
134
- }
135
-
136
- function appendStatusTimestamp(text) {
137
- const normalized = String(text === undefined || text === null ? "" : text).trim();
138
- const suffix = buildStatusTimestampText();
139
- return normalized ? `${normalized} ${suffix}` : suffix;
140
- }
141
-
142
78
  function resolveConfiguredObservable(capabilityConfig) {
143
79
  const observable = String(
144
80
  capabilityConfig && capabilityConfig.observable !== undefined
@@ -446,6 +382,7 @@ module.exports = function(RED) {
446
382
  invokeCapability(node.send.bind(node), "interval")
447
383
  .catch((error) => {
448
384
  setNodeStatus({ fill: "red", shape: "ring", text: "auto error" });
385
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
449
386
  node.error(error);
450
387
  })
451
388
  .finally(() => {
@@ -475,6 +412,7 @@ module.exports = function(RED) {
475
412
  }
476
413
  } catch (error) {
477
414
  setNodeStatus({ fill: "red", shape: "ring", text: "error" });
415
+ node.send([null, buildErrorOutputMessage(error, node.name)]);
478
416
  if (typeof done === "function") {
479
417
  done(error);
480
418
  } else {