smart-nodes 0.3.13 → 0.3.22

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/README.md CHANGED
@@ -167,7 +167,7 @@ This control parses a text and performs actions to the selected and matching sma
167
167
 
168
168
  [ text ] is optional
169
169
 
170
- - Turn on [the light in] the living room and int the kitchen off
170
+ - Turn on [the light in] the living room and the kitchen off
171
171
  - Open [the shutter in] the kitchen and turn studio off
172
172
  - Close [the shutter in the] sleeping room
173
173
  - Living room to 10 %
@@ -69,6 +69,8 @@ module.exports = function (RED)
69
69
  // Send cloned message to all linked nodes
70
70
  config.links.forEach(link =>
71
71
  {
72
+ // console.log(node.id + " -> " + link);
73
+ // console.log(newMsg);
72
74
  RED.events.emit("node:" + link, newMsg);
73
75
  });
74
76
  });
package/delay/delay.js CHANGED
@@ -103,7 +103,7 @@ module.exports = function (RED)
103
103
 
104
104
  if (delay_only_on_change)
105
105
  {
106
- if (timeout)
106
+ if (timeout != null)
107
107
  {
108
108
  // current delay runs already for the same payload, so don't start a new one.
109
109
  if (next_payload == msg.payload)
@@ -137,7 +137,7 @@ module.exports = function (RED)
137
137
  // No delay if 0 or smaller
138
138
  if (delayMs <= 0)
139
139
  {
140
- node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + (msg.topic ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") });
140
+ node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + +msg.topic + "' msg.payload = '" + msg.payload + "'" });
141
141
  nodeSettings.lastMessage = msg
142
142
 
143
143
  if (config.save_state)
@@ -148,10 +148,11 @@ module.exports = function (RED)
148
148
  }
149
149
 
150
150
  // start new timeout
151
- node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "Forward msg.topic = '" + (msg.topic ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") + "' in " + helper.formatMsToStatus(delayMs, "at") });
151
+ node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "Forward msg.topic = '" + msg.topic + "' msg.payload = '" + msg.payload + "' in " + helper.formatMsToStatus(delayMs, "at") });
152
152
  timeout = setTimeout(() =>
153
153
  {
154
- node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + (msg.topic ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") });
154
+ timeout = null;
155
+ node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + msg.topic + "' msg.payload = '" + msg.payload + "'" });
155
156
  nodeSettings.lastMessage = msg
156
157
 
157
158
  if (config.save_state)
@@ -165,7 +166,7 @@ module.exports = function (RED)
165
166
  {
166
167
  setTimeout(() =>
167
168
  {
168
- node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + (nodeSettings.lastMessage.topic ?? "null") + "' msg.payload = '" + (nodeSettings.lastMessage.payload ?? "null") });
169
+ node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + nodeSettings.lastMessage.topic + "' msg.payload = '" + nodeSettings.lastMessage.payload + "'" });
169
170
  node.send(nodeSettings.lastMessage);
170
171
  }, 10000);
171
172
  }
@@ -88,6 +88,14 @@ module.exports = function (RED)
88
88
  node.status({ fill: "red", shape: "dot", text: (new Date()).toLocaleString() + ": Forwarding disabled" });
89
89
  }
90
90
 
91
+ if (config.save_state && config.resend_on_start && nodeSettings.lastMessage != null)
92
+ {
93
+ setTimeout(() =>
94
+ {
95
+ node.send(nodeSettings.lastMessage);
96
+ }, 10000);
97
+ }
98
+
91
99
  setStatus();
92
100
  }
93
101
 
@@ -12,6 +12,8 @@ module.exports = function (RED)
12
12
  var nodeSettings = {
13
13
  active: null,
14
14
  lastMessage: null,
15
+ setpoint: parseFloat(config.setpoint),
16
+ hysteresis: parseFloat(config.hysteresis)
15
17
  };
16
18
 
17
19
  if (config.save_state)
@@ -42,8 +44,6 @@ module.exports = function (RED)
42
44
  }
43
45
 
44
46
  // dynamic config
45
- let setpoint = parseFloat(config.setpoint);
46
- let hysteresis = parseFloat(config.hysteresis);
47
47
  let out_higher = helper.evaluateNodeProperty(RED, config.out_higher, config.out_higher_type);
48
48
  let out_lower = helper.evaluateNodeProperty(RED, config.out_lower, config.out_lower_type);
49
49
 
@@ -63,7 +63,7 @@ module.exports = function (RED)
63
63
  switch (realTopic)
64
64
  {
65
65
  case "setpoint":
66
- setpoint = value;
66
+ nodeSettings.setpoint = value;
67
67
  node.status({ fill: nodeSettings.active ? "green" : "red", shape: "ring", text: (new Date()).toLocaleString() + ": New setpoint: " + value + "" });
68
68
 
69
69
  if (config.save_state)
@@ -71,7 +71,7 @@ module.exports = function (RED)
71
71
  break;
72
72
 
73
73
  case "hysteresis":
74
- hysteresis = value;
74
+ nodeSettings.hysteresis = value;
75
75
  node.status({ fill: nodeSettings.active ? "green" : "red", shape: "ring", text: (new Date()).toLocaleString() + ": New hysteresis: " + value + "" });
76
76
 
77
77
  if (config.save_state)
@@ -96,22 +96,22 @@ module.exports = function (RED)
96
96
  break;
97
97
 
98
98
  default:
99
- if (value >= setpoint + hysteresis && nodeSettings.active !== true)
99
+ if (value >= nodeSettings.setpoint + nodeSettings.hysteresis && nodeSettings.active !== true)
100
100
  {
101
101
  node.status({ fill: "green", shape: "dot", text: (new Date()).toLocaleString() + ": Turned higher by value " + value + "" });
102
102
  nodeSettings.active = true;
103
- nodeSettings.lastMessage = out_higher ?? msg;
103
+ nodeSettings.lastMessage = createMessage(out_higher ?? msg, value);
104
104
 
105
105
  if (config.save_state)
106
106
  smartContext.set(node.id, nodeSettings);
107
107
 
108
108
  node.send([nodeSettings.lastMessage, null]);
109
109
  }
110
- else if (value <= setpoint - hysteresis && nodeSettings.active !== false)
110
+ else if (value <= nodeSettings.setpoint - nodeSettings.hysteresis && nodeSettings.active !== false)
111
111
  {
112
112
  node.status({ fill: "red", shape: "dot", text: (new Date()).toLocaleString() + ": Turned lower by value " + value + "" });
113
113
  nodeSettings.active = false;
114
- nodeSettings.lastMessage = out_lower ?? msg;
114
+ nodeSettings.lastMessage = createMessage(out_lower ?? msg, value);
115
115
 
116
116
  if (config.save_state)
117
117
  smartContext.set(node.id, nodeSettings);
@@ -130,6 +130,18 @@ module.exports = function (RED)
130
130
  {
131
131
  });
132
132
 
133
+ let createMessage = (msg, value) =>
134
+ {
135
+ return Object.assign({}, msg, {
136
+ smart_info: {
137
+ active: nodeSettings.active,
138
+ hysteresis: nodeSettings.hysteresis,
139
+ setpoint: nodeSettings.setpoint,
140
+ last_value: value
141
+ }
142
+ })
143
+ };
144
+
133
145
  if (config.save_state && config.resend_on_start && nodeSettings.active != null && nodeSettings.lastMessage != null)
134
146
  {
135
147
  setTimeout(() =>
@@ -27,7 +27,7 @@ module.exports = function (RED)
27
27
  let max_time_on_timeout = null;
28
28
  let isPermanent = false;
29
29
  let isMotion = false;
30
- let current_timeout_ms = 0;
30
+ let timeout_end_date = null;
31
31
  let alarm_active = false;
32
32
 
33
33
  // central handling
@@ -62,7 +62,9 @@ module.exports = function (RED)
62
62
  case "status":
63
63
  // Make sure it is bool
64
64
  msg.payload = !!msg.payload;
65
- doRestartTimer = nodeSettings.last_value != msg.payload;
65
+
66
+ if (nodeSettings.last_value == msg.payload && max_time_on_timeout != null)
67
+ doRestartTimer = false;
66
68
 
67
69
  nodeSettings.last_value = msg.payload;
68
70
  break;
@@ -178,7 +180,9 @@ module.exports = function (RED)
178
180
  timeMs = max_time_on;
179
181
  }
180
182
 
181
- current_timeout_ms = timeMs;
183
+ // calculate end date for status message
184
+ timeout_end_date = new Date();
185
+ timeout_end_date.setMilliseconds(timeout_end_date.getMilliseconds() + timeMs);
182
186
 
183
187
  // Stop if any timeout is set
184
188
  stopAutoOff();
@@ -216,10 +220,10 @@ module.exports = function (RED)
216
220
  }
217
221
  else if (nodeSettings.last_value)
218
222
  {
219
- if (isPermanent || isMotion || current_timeout_ms <= 0)
223
+ if (isPermanent || isMotion || timeout_end_date == null)
220
224
  node.status({ fill: "green", shape: "dot", text: (new Date()).toLocaleString() + ": On" });
221
225
  else if (max_time_on_timeout)
222
- node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": Wait " + helper.formatMsToStatus(current_timeout_ms, "until") + " for auto off" });
226
+ node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": Wait " + helper.formatDateToStatus(timeout_end_date, "until") + " for auto off" });
223
227
  }
224
228
  else
225
229
  {
@@ -234,10 +238,16 @@ module.exports = function (RED)
234
238
 
235
239
  config.links.forEach(link =>
236
240
  {
241
+ // console.log(node.id + " -> " + link);
242
+ // console.log({ source: node.id, state: state });
237
243
  RED.events.emit("node:" + link, { source: node.id, state: state });
238
244
  });
239
245
  }
240
246
 
247
+ // After node red restart, start also the timeout
248
+ if (nodeSettings.last_value)
249
+ startAutoOffIfNeeded(helper.getTimeInMsFromString(max_time_on));
250
+
241
251
  setStatus();
242
252
  }
243
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-nodes",
3
- "version": "0.3.13",
3
+ "version": "0.3.22",
4
4
  "description": "Smart Nodes",
5
5
  "keywords": [
6
6
  "node-red",
@@ -263,9 +263,17 @@ module.exports = function (RED)
263
263
 
264
264
  config.links.forEach(link =>
265
265
  {
266
+ // console.log(node.id + " -> " + link);
267
+ // console.log({ source: node.id, state: state });
266
268
  RED.events.emit("node:" + link, { source: node.id, state: state });
267
269
  });
268
270
  }
271
+
272
+ // After node red restart, start also the timeout
273
+ if (getCurrentScene() != 0)
274
+ startAutoOffIfNeeded(helper.getTimeInMsFromString(max_time_on));
275
+
276
+ status();
269
277
  }
270
278
  RED.nodes.registerType("smart_scene-control", SceneControlNode);
271
279
  };
@@ -14,6 +14,16 @@
14
14
  <div class="form-row node-scheduler-schedules-row">
15
15
  <ol id="node-scheduler-schedules"></ol>
16
16
  </div>
17
+ <hr/>
18
+ <h4 style="margin: 0.5rem 0;">Systemstart</h4>
19
+ <div class="form-row">
20
+ <input type="checkbox" id="node-input-save_state" style="width: 20px;" />
21
+ <label for="node-input-save_state" style="width: calc(100% - 30px);">Zustand speichern</label>
22
+ </div>
23
+ <div class="form-row" id="resend_on_start_row">
24
+ <input type="checkbox" id="node-input-resend_on_start" style="width: 20px;" />
25
+ <label for="node-input-resend_on_start" style="width: calc(100% - 30px);">Letze Nachricht 10 Sekunden nach dem Start senden</label>
26
+ </div>
17
27
  </script>
18
28
 
19
29
  <script type="text/html" data-template-scheduler-row="">
@@ -117,6 +127,8 @@
117
127
  return true;
118
128
  },
119
129
  },
130
+ save_state: { value: true },
131
+ resend_on_start: { value: true }
120
132
  },
121
133
  inputs: 1,
122
134
  outputs: 1,
@@ -129,6 +141,15 @@
129
141
  {
130
142
  let node = this;
131
143
 
144
+ $("#node-input-save_state").on("change", ev =>
145
+ {
146
+ if (ev.target.checked)
147
+ $("#resend_on_start_row").show();
148
+ else
149
+ $("#resend_on_start_row").hide();
150
+ });
151
+ $("#node-input-save_state").trigger("change");
152
+
132
153
  /**
133
154
  * prepare schedule
134
155
  */
@@ -8,13 +8,26 @@ module.exports = function (RED)
8
8
  const smartContext = require("../persistence.js")(RED);
9
9
  const helper = require("../smart_helper.js");
10
10
 
11
- var nodeSettings = Object.assign({}, {
11
+ var nodeSettings = {
12
12
  enabled: config.enabled,
13
- }, smartContext.get(node.id));
13
+ lastMessage: null,
14
+ };
14
15
 
15
- let timeouts = [];
16
- let nextEvents = [];
16
+ if (config.save_state)
17
+ {
18
+ // load old saved values
19
+ nodeSettings = Object.assign(nodeSettings, smartContext.get(node.id));
20
+ }
21
+ else
22
+ {
23
+ // delete old saved values
24
+ smartContext.del(node.id);
25
+ }
26
+
27
+ let timeout = null;
28
+ let nextEvent = null;
17
29
 
30
+ // prepare schedules
18
31
  setTimeout(() =>
19
32
  {
20
33
  for (let i = 0; i < config.schedules.length; i++)
@@ -26,7 +39,7 @@ module.exports = function (RED)
26
39
  }
27
40
 
28
41
  if (nodeSettings.enabled)
29
- initTimeouts();
42
+ initNextTimeout();
30
43
 
31
44
  setStatus();
32
45
  }, 1000);
@@ -41,6 +54,8 @@ module.exports = function (RED)
41
54
  return;
42
55
 
43
56
  nodeSettings.enabled = true;
57
+ if (config.save_state)
58
+ smartContext.set(node.id, nodeSettings);
44
59
  break;
45
60
 
46
61
  case "disable":
@@ -48,6 +63,8 @@ module.exports = function (RED)
48
63
  return;
49
64
 
50
65
  nodeSettings.enabled = false;
66
+ if (config.save_state)
67
+ smartContext.set(node.id, nodeSettings);
51
68
  break;
52
69
 
53
70
  case "set_state":
@@ -55,6 +72,8 @@ module.exports = function (RED)
55
72
  return;
56
73
 
57
74
  nodeSettings.enabled = !!msg.payload;
75
+ if (config.save_state)
76
+ smartContext.set(node.id, nodeSettings);
58
77
  break;
59
78
 
60
79
  default:
@@ -72,57 +91,42 @@ module.exports = function (RED)
72
91
 
73
92
  node.on("close", function ()
74
93
  {
75
- clearTimeouts();
94
+ if (timeout != null)
95
+ {
96
+ clearTimeout(timeout);
97
+ timeout = null;
98
+ }
76
99
  });
77
100
 
78
- let clearTimeouts = () =>
101
+ let initNextTimeout = () =>
79
102
  {
80
- for (let i = 0; i < timeouts.length; i++)
103
+ let minIndex = null;
104
+ for (let i = 0; i < config.schedules.length; i++)
81
105
  {
82
- if (timeouts[i] != 0)
106
+ config.schedules[i].nextEvent = calcNextEvent(i);
107
+ if (config.schedules[i].nextEvent != null)
83
108
  {
84
- clearTimeout(timeouts[i]);
85
- timeouts[i] = 0;
109
+ if (minIndex == null || config.schedules[i].nextEvent < config.schedules[minIndex].nextEvent)
110
+ minIndex = i;
86
111
  }
87
112
  }
88
- }
89
113
 
90
- let initTimeouts = () =>
91
- {
92
- for (let i = 0; i < config.schedules.length; i++)
114
+ // No events defined
115
+ if (minIndex == null)
93
116
  {
94
- initTimeout(i, config.schedules[i]);
95
- }
96
- }
97
-
98
- let initTimeout = (i, schedule) =>
99
- {
100
- if (!nodeSettings.enabled)
117
+ nextEvent = null;
101
118
  return;
102
-
103
- let waitTime = getWaitInMs(i, schedule);
104
- if (waitTime != null)
105
- {
106
- if (timeouts[i])
107
- clearTimeout(timeouts[i]);
108
-
109
- timeouts[i] = setTimeout(raiseEvent, waitTime, i, schedule);
110
119
  }
111
- }
112
120
 
113
- let raiseEvent = (i, schedule) =>
114
- {
115
- if (!nodeSettings.enabled)
116
- return;
117
-
118
- timeouts[i] = 0;
119
- node.send(schedule.message);
120
- initTimeout(i, schedule);
121
- setStatus();
121
+ nextEvent = config.schedules[minIndex].nextEvent;
122
+ let waitTime = nextEvent.getTime() - (new Date()).getTime();
123
+ timeout = setTimeout(raiseEvent, waitTime, minIndex);
122
124
  }
123
125
 
124
- let getWaitInMs = (i, schedule) =>
126
+ let calcNextEvent = i =>
125
127
  {
128
+ const schedule = config.schedules[i];
129
+
126
130
  // If no day is checked then we cannot it is never raised
127
131
  if (!schedule.days || schedule.days.length == 0)
128
132
  return null;
@@ -148,26 +152,51 @@ module.exports = function (RED)
148
152
  }
149
153
 
150
154
  // find next day when the event should be raised
151
- let possibleDays = schedule.days.filter(d => findNextDay ? d > now.getDay() : d >= now.getDay());
152
- if (possibleDays.length == 0)
153
- possibleDays = Math.min(...schedule.days);
155
+ let possibleDay = schedule.days.filter(d => findNextDay ? d > now.getDay() : d >= now.getDay());
156
+ if (possibleDay.length == 0)
157
+ possibleDay = Math.min(...schedule.days);
154
158
  else
155
- possibleDays = Math.min(...possibleDays);
159
+ possibleDay = Math.min(...possibleDay);
156
160
 
157
161
  let nextEvent = new Date(
158
162
  now.getFullYear(),
159
163
  now.getMonth(),
160
164
  now.getDate() + (
161
- possibleDays < now.getDay() ? 7 - now.getDay() + possibleDays : possibleDays - now.getDay()
165
+ findNextDay ?
166
+ possibleDay <= now.getDay() ? 7 - now.getDay() + possibleDay : possibleDay - now.getDay()
167
+ :
168
+ possibleDay < now.getDay() ? 7 - now.getDay() + possibleDay : possibleDay - now.getDay()
162
169
  ),
163
170
  schedule.hour,
164
171
  schedule.minute,
165
172
  schedule.second
166
173
  );
167
174
 
168
- nextEvents[i] = nextEvent;
175
+ // console.log({
176
+ // i,
177
+ // findNextDay,
178
+ // nextEvent
179
+ // });
169
180
 
170
- return nextEvent.getTime() - now.getTime();
181
+ return nextEvent;
182
+ }
183
+
184
+ let raiseEvent = i =>
185
+ {
186
+ const schedule = config.schedules[i];
187
+
188
+ if (!nodeSettings.enabled)
189
+ return;
190
+
191
+ timeout = null;
192
+ node.send(schedule.message);
193
+ nodeSettings.lastMessage = schedule.message;
194
+
195
+ if (config.save_state)
196
+ smartContext.set(node.id, nodeSettings);
197
+
198
+ initNextTimeout();
199
+ setStatus();
171
200
  }
172
201
 
173
202
  let setStatus = () =>
@@ -180,7 +209,7 @@ module.exports = function (RED)
180
209
  text: (new Date()).toLocaleString() + ": Scheduler disabled"
181
210
  });
182
211
  }
183
- else if (nextEvents.filter(d => d).lenght == 0)
212
+ else if (nextEvent == null)
184
213
  {
185
214
  node.status({
186
215
  fill: "red",
@@ -191,7 +220,6 @@ module.exports = function (RED)
191
220
  else
192
221
  {
193
222
  // filter out empty values
194
- let nextEvent = new Date(Math.min(...nextEvents.filter(d => d)));
195
223
  let time = nextEvent.getTime() - (new Date()).getTime();
196
224
  time = Math.ceil(time / 1000) * 1000;
197
225
 
@@ -203,6 +231,13 @@ module.exports = function (RED)
203
231
  }
204
232
  }
205
233
 
234
+ if (config.save_state && config.resend_on_start && nodeSettings.lastMessage != null)
235
+ {
236
+ setTimeout(() =>
237
+ {
238
+ node.send(nodeSettings.lastMessage);
239
+ }, 10000);
240
+ }
206
241
  }
207
242
 
208
243
  RED.nodes.registerType("smart_scheduler", SchedulerNode);
@@ -388,6 +388,8 @@ module.exports = function (RED)
388
388
 
389
389
  config.links.forEach(link =>
390
390
  {
391
+ // console.log(node.id + " -> " + link);
392
+ // console.log({ source: node.id, state: state });
391
393
  RED.events.emit("node:" + link, { source: node.id, state: state });
392
394
  });
393
395
  };
@@ -206,6 +206,8 @@ module.exports = function (RED)
206
206
 
207
207
  config.links.forEach(link =>
208
208
  {
209
+ // console.log(node.id + " -> " + link);
210
+ // console.log({ source: node.id, state: state });
209
211
  RED.events.emit("node:" + link, { source: node.id, state: state });
210
212
  });
211
213
  };
package/smart_helper.js CHANGED
@@ -151,6 +151,42 @@ module.exports = {
151
151
  if (value > 0)
152
152
  result = value + "." + result;
153
153
 
154
+ return result;
155
+ },
156
+ formatDateToStatus(date, timeConcatWord = null)
157
+ {
158
+ let result = "";
159
+
160
+ if (timeConcatWord)
161
+ result = " " + timeConcatWord + " " + date.getHours() + ":" + ("" + date.getMinutes()).padStart(2, "0") + ":" + ("" + date.getSeconds()).padStart(2, "0");
162
+
163
+ let value = date - new Date();
164
+ if (value <= 0)
165
+ return "0:00" + result;
166
+
167
+ // value in sec
168
+ value = parseInt(value / 1000, 10);
169
+ result = (value % 60) + result;
170
+ if (value % 60 < 10)
171
+ result = "0" + result;
172
+
173
+ // value in min
174
+ value = parseInt(value / 60, 10);
175
+ result = (value % 60) + ":" + result;
176
+ if (value % 60 < 10)
177
+ result = "0" + result;
178
+
179
+ // value in hour
180
+ value = parseInt(value / 60, 10);
181
+ result = (value % 24) + ":" + result;
182
+ if (value % 24 < 10)
183
+ result = "0" + result;
184
+
185
+ // value in days
186
+ value = parseInt(value / 24, 10);
187
+ if (value > 0)
188
+ result = value + "." + result;
189
+
154
190
  return result;
155
191
  }
156
192
  };
@@ -286,12 +286,12 @@ module.exports = function (RED)
286
286
  {
287
287
  if (action != null && affectedNodes.length > 0)
288
288
  {
289
- for (const node of affectedNodes)
289
+ for (const targetNode of affectedNodes)
290
290
  {
291
- if (mode == "light" && !["smart_light-control", "smart_scene-control"].includes(node.type))
291
+ if (mode == "light" && !["smart_light-control", "smart_scene-control"].includes(targetNode.type))
292
292
  continue;
293
293
 
294
- if (mode == "shutter" && !["smart_shutter-control", "smart_shutter-complex-control"].includes(node.type))
294
+ if (mode == "shutter" && !["smart_shutter-control", "smart_shutter-complex-control"].includes(targetNode.type))
295
295
  continue;
296
296
 
297
297
  // node.log("Notify node " + node.id);
@@ -299,11 +299,17 @@ module.exports = function (RED)
299
299
  {
300
300
  // console.log({ "topic": action, "payload": number });
301
301
  if (number != null)
302
- RED.events.emit("node:" + node.id, { "topic": action, "payload": number });
302
+ {
303
+ // console.log(node.id + " -> " + targetNode.id);
304
+ // console.log({ "topic": action, "payload": number });
305
+ RED.events.emit("node:" + targetNode.id, { "topic": action, "payload": number });
306
+ }
303
307
  }
304
308
  else
305
309
  {
306
- RED.events.emit("node:" + node.id, { "topic": action });
310
+ // console.log(node.id + " -> " + targetNode.id);
311
+ // console.log({ "topic": action });
312
+ RED.events.emit("node:" + targetNode.id, { "topic": action });
307
313
  }
308
314
  }
309
315