smart-nodes 0.4.23 → 0.4.25

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 CHANGED
@@ -181,3 +181,7 @@
181
181
  - Changed default of save_state and resend_on_start to false for all nodes.
182
182
  - Hysteresis node can now be defined by min/max values.
183
183
  - Added support for percentage output for the light node.
184
+
185
+ ## Version 0.4.24:
186
+
187
+ - Added set_inverted to light node.
package/README.md CHANGED
@@ -95,7 +95,7 @@ You can also choose 2-4 press detection.
95
95
 
96
96
  ## 7. Hysteresis
97
97
 
98
- This node is checking if the input value reachs a defined value until the upper message is send. When the lower level is reached, the lower masssage will be send
98
+ This node is checking if the input value reachs a defined value until the upper message is send. When the lower level is reached, the lower message will be send.
99
99
 
100
100
  ### **Features:**
101
101
 
@@ -104,7 +104,7 @@ This node is checking if the input value reachs a defined value until the upper
104
104
 
105
105
  ## 8. Logic
106
106
 
107
- This node can be used for AND, OR and XOR logics.
107
+ This node can be used for AND, OR and XOR logics. Inputs and outputs can be individually selected to be inverted.
108
108
 
109
109
  ### **Features:**
110
110
 
package/light/light.js CHANGED
@@ -110,6 +110,16 @@ module.exports = function (RED)
110
110
  let doRestartTimer = true;
111
111
  let real_topic = helper.getTopicName(msg.topic);
112
112
 
113
+ if (real_topic == "set_inverted")
114
+ {
115
+ real_topic = "set";
116
+
117
+ if (mode == "BOOL")
118
+ msg.payload = !msg.payload;
119
+ else if (mode == "PERCENTAGE")
120
+ msg.payload = 100 - boolToInt(msg.payload);
121
+ }
122
+
113
123
  switch (real_topic)
114
124
  {
115
125
  case "status":
@@ -223,7 +233,7 @@ module.exports = function (RED)
223
233
 
224
234
  case "alarm":
225
235
  isBlinking = false;
226
-
236
+
227
237
  // Make sure it is bool
228
238
  msg.payload = !!msg.payload;
229
239
 
@@ -39,7 +39,15 @@
39
39
  <tr>
40
40
  <td><code>set</code></td>
41
41
  <td>
42
- Schaltet den Ausgang bei <code>msg.payload = true</code> ein und bei <code>msg.payload = false</code> aus, bzw. setzt den Ausgang auf den gesendeten Prozent Wert <code>msg.payload = 50</code>.<br/>
42
+ Schaltet den Ausgang bei <code>msg.payload = true</code> ein und bei <code>msg.payload = false</code> aus, bzw. setzt den Ausgang auf den gesendeten Prozent Wert <code>msg.payload = 30</code>.<br/>
43
+ Bei einem Wechsel des Ausgangswerts wird die Zeitmessung für die hinterlegte, bzw. mitgesendete Zeit gestartet, sofern vorhanden.
44
+ </td>
45
+ <td>Nein</td>
46
+ </tr>
47
+ <tr>
48
+ <td><code>set_inverted</code></td>
49
+ <td>
50
+ Schaltet den Ausgang bei <code>msg.payload = false</code> ein und bei <code>msg.payload = true</code> aus, bzw. setzt den Ausgang auf 100 - den gesendeten Prozent Wert <code>msg.payload = 30</code> => sendet 70%.<br/>
43
51
  Bei einem Wechsel des Ausgangswerts wird die Zeitmessung für die hinterlegte, bzw. mitgesendete Zeit gestartet, sofern vorhanden.
44
52
  </td>
45
53
  <td>Nein</td>
@@ -38,7 +38,15 @@
38
38
  <tr>
39
39
  <td><code>set</code></td>
40
40
  <td>
41
- Switches the output on when <code>msg.payload = true</code> and off when <code>msg.payload = false, or sets the output to the sent percent value <code>msg.payload = 50</code>.</code>.<br />
41
+ Switches the output on when <code>msg.payload = true</code> and off when <code>msg.payload = false, or sets the output to the sent percent value <code>msg.payload = 30</code>.</code>.<br />
42
+ When changing the output value, the time measurement is started for the stored or sent time, if available.
43
+ </td>
44
+ <td>No</td>
45
+ </tr>
46
+ <tr>
47
+ <td><code>set_inverted</code></td>
48
+ <td>
49
+ Switches the output on when <code>msg.payload = false</code> and off when <code>msg.payload = true, or sets the output to 100 - the sent percent value <code>msg.payload = 30</code> => sent 70%.</code>.<br />
42
50
  When changing the output value, the time measurement is started for the stored or sent time, if available.
43
51
  </td>
44
52
  <td>No</td>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "smart-nodes",
3
- "version": "0.4.23",
4
- "description": "Smart Nodes",
3
+ "version": "0.4.25",
4
+ "description": "Controls light, shutters and more. Includes common used logic and statistic nodes to control your home.",
5
5
  "keywords": [
6
6
  "node-red",
7
7
  "smart nodes",
@@ -1,389 +0,0 @@
1
- <script type="text/javascript">
2
- (function ()
3
- {
4
- let treeList;
5
- let candidateNodesCount = 0;
6
- let flows = [];
7
- let flowMap = {};
8
-
9
- function onEditPrepare(node, targetTypes)
10
- {
11
- if (!node.links)
12
- node.links = [];
13
-
14
- const activeSubflow = RED.nodes.subflow(node.z);
15
-
16
- treeList = $("<div>")
17
- .css({ width: "100%", height: "100%" })
18
- .appendTo(".node-input-link-row")
19
- .treeList({ autoSelect: false })
20
- .on("treelistitemmouseover", function (e, item)
21
- {
22
- if (item.node)
23
- {
24
- item.node.highlighted = true;
25
- item.node.dirty = true;
26
- RED.view.redraw();
27
- }
28
- })
29
- .on("treelistitemmouseout", function (e, item)
30
- {
31
- if (item.node)
32
- {
33
- item.node.highlighted = false;
34
- item.node.dirty = true;
35
- RED.view.redraw();
36
- }
37
- });
38
-
39
- flows = [];
40
- flowMap = {};
41
-
42
- if (activeSubflow)
43
- {
44
- flowMap[activeSubflow.id] = {
45
- id: activeSubflow.id,
46
- class: "red-ui-palette-header",
47
- label: "Subflow : " + (activeSubflow.name || activeSubflow.id),
48
- expanded: true,
49
- children: []
50
- };
51
- flows.push(flowMap[activeSubflow.id]);
52
- }
53
- else
54
- {
55
- RED.nodes.eachWorkspace(function (ws)
56
- {
57
- if (!ws.disabled)
58
- {
59
- flowMap[ws.id] = {
60
- id: ws.id,
61
- class: "red-ui-palette-header",
62
- label: (ws.label || ws.id) + (node.z === ws.id ? " *" : ""),
63
- expanded: true,
64
- children: []
65
- };
66
- flows.push(flowMap[ws.id]);
67
- }
68
- });
69
- }
70
-
71
- setTimeout(function ()
72
- {
73
- treeList.treeList("show", node.z);
74
- }, 100);
75
- }
76
-
77
- function initTreeList(node, targetTypes)
78
- {
79
- candidateNodesCount = 0;
80
- for (const key in flowMap)
81
- {
82
- flowMap[key].children = [];
83
- }
84
-
85
- let candidateNodes = [];
86
-
87
- targetTypes.forEach(function (targetType)
88
- {
89
- candidateNodes = candidateNodes.concat(RED.nodes.filterNodes({ type: targetType }));
90
- });
91
-
92
- candidateNodes.forEach(function (n)
93
- {
94
- if (flowMap[n.z])
95
- {
96
- const isChecked = (node.links.indexOf(n.id) !== -1) || (n.links || []).indexOf(node.id) !== -1;
97
- if (isChecked)
98
- {
99
- flowMap[n.z].children.push({
100
- id: n.id,
101
- node: n,
102
- label: n.name || n.id,
103
- selected: false,
104
- checkbox: false,
105
- radio: false
106
- });
107
- candidateNodesCount++;
108
- }
109
- }
110
- });
111
-
112
- for (const key in flowMap)
113
- {
114
- flowMap[key].children.sort((a, b) => a.label.localeCompare(b.label));
115
- }
116
-
117
- const flowsFiltered = flows.filter(function (f) { return f.children.length > 0 });
118
- treeList.treeList("empty");
119
- treeList.treeList("data", flowsFiltered);
120
- }
121
-
122
- function resizeNodeList()
123
- {
124
- var rows = $("#dialog-form>div:not(.node-input-link-row)");
125
- var height = $("#dialog-form").height();
126
- for (var i = 0; i < rows.length; i++)
127
- {
128
- if ($(rows[i]).is(":visible"))
129
- height -= $(rows[i]).outerHeight(true);
130
- }
131
- var editorRow = $("#dialog-form>div.node-input-link-row");
132
- height -= (parseInt(editorRow.css("marginTop")) + parseInt(editorRow.css("marginBottom")));
133
- $(".node-input-link-row").css("height", height + "px");
134
- }
135
-
136
- RED.nodes.registerType("smart_dimmer-control", {
137
- category: "Smart Nodes",
138
- paletteLabel: "Dimmer control",
139
- color: "#C882FF",
140
- defaults: {
141
- name: { value: "" },
142
- exec_text_names: { value: "" },
143
- max_time_on: { value: "0" },
144
- max_time_on_unit: { value: "s" },
145
- long_press_ms: { value: "1000" },
146
- dim_time_total: { value: "0" },
147
- dim_time_total_unit: { value: "s" },
148
- alarm_on_action: { value: 'NOTHING' }, // NOTHING | ON | OFF | PERCENTAGE
149
- alarm_on_percentage: { value: 0 },
150
- alarm_off_action: { value: 'NOTHING' }, // NOTHING | ON | OFF | PERCENTAGE | LAST | LAST_SENDED
151
- alarm_off_percentage: { value: 0 },
152
- links: { value: [], type: "smart_central-control[]" }
153
- },
154
- inputs: 1,
155
- outputs: 1,
156
- icon: "font-awesome/fa-circle-o-notch",
157
- label: function ()
158
- {
159
- return this.name || "Dimmer control";
160
- },
161
- oneditprepare: function ()
162
- {
163
- let node = this;
164
-
165
- onEditPrepare(this, ["smart_central-control"]);
166
- initTreeList(node, ["smart_central-control"]);
167
-
168
- $("#node-input-max_time_on")
169
- .css("max-width", "4rem")
170
- .spinner({
171
- min: 0,
172
- change: function (event, ui)
173
- {
174
- var value = parseInt(this.value);
175
- value = isNaN(value) ? 0 : value;
176
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
177
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
178
- if (value !== this.value) $(this).spinner("value", value);
179
- },
180
- });
181
-
182
- $("#node-input-max_time_on_unit")
183
- .css("max-width", "10rem")
184
- .typedInput({
185
- types: [{
186
- value: "max_time_on_unit",
187
- default: "s",
188
- options: [
189
- { value: "ms", label: node._("dimmer.ui.milliseconds") },
190
- { value: "s", label: node._("dimmer.ui.seconds") },
191
- { value: "min", label: node._("dimmer.ui.minutes") },
192
- { value: "h", label: node._("dimmer.ui.hours") },
193
- ],
194
- }],
195
- });
196
-
197
- $("#node-input-dim_time_total")
198
- .css("max-width", "4rem")
199
- .spinner({
200
- min: 0,
201
- change: function (event, ui)
202
- {
203
- var value = parseInt(this.value);
204
- value = isNaN(value) ? 0 : value;
205
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
206
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
207
- if (value !== this.value) $(this).spinner("value", value);
208
- },
209
- });
210
-
211
- $("#node-input-dim_time_total_unit")
212
- .css("max-width", "10rem")
213
- .typedInput({
214
- types: [{
215
- value: "dim_time_total_unit",
216
- default: "s",
217
- options: [
218
- { value: "ms", label: node._("dimmer.ui.milliseconds") },
219
- { value: "s", label: node._("dimmer.ui.seconds") },
220
- { value: "min", label: node._("dimmer.ui.minutes") },
221
- { value: "h", label: node._("dimmer.ui.hours") },
222
- ],
223
- }],
224
- });
225
-
226
- $("#node-input-long_press_ms")
227
- .css("max-width", "4rem")
228
- .spinner({
229
- min: 1,
230
- change: function (event, ui)
231
- {
232
- var value = parseInt(this.value);
233
- value = isNaN(value) ? 0 : value;
234
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
235
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
236
- if (value !== this.value)
237
- $(this).spinner("value", value);
238
- }
239
- });
240
-
241
- $("#node-input-update_interval")
242
- .css("max-width", "4rem")
243
- .spinner({
244
- min: 1,
245
- change: function (event, ui)
246
- {
247
- var value = parseInt(this.value);
248
- value = isNaN(value) ? 0 : value;
249
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
250
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
251
- if (value !== this.value)
252
- $(this).spinner("value", value);
253
- }
254
- });
255
-
256
- $("#node-input-alarm_on_action")
257
- .css("max-width", "13rem")
258
- .typedInput({
259
- types: [{
260
- value: "alarm_on_action",
261
- default: "NOTHING",
262
- options: [
263
- { value: "NOTHING", label: node._("dimmer.ui.no_action") },
264
- { value: "ON", label: node._("dimmer.ui.turn_on") },
265
- { value: "OFF", label: node._("dimmer.ui.turn_off") },
266
- { value: "PERCENTAGE", label: node._("dimmer.ui.turn_percentage") }
267
- ],
268
- }],
269
- });
270
-
271
- $("#node-input-alarm_on_percentage")
272
- .css("max-width", "4rem")
273
- .spinner({
274
- min: 0,
275
- max: 100,
276
- change: function (event, ui)
277
- {
278
- var value = parseInt(this.value);
279
- value = isNaN(value) ? 0 : value;
280
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
281
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
282
- if (value !== this.value) $(this).spinner("value", value);
283
- },
284
- });
285
-
286
- $("#node-input-alarm_off_action")
287
- .css("max-width", "13rem")
288
- .typedInput({
289
- types: [{
290
- value: "alarm_off_action",
291
- default: "NOTHING",
292
- options: [
293
- { value: "NOTHING", label: node._("dimmer.ui.no_action") },
294
- { value: "ON", label: node._("dimmer.ui.turn_on") },
295
- { value: "OFF", label: node._("dimmer.ui.turn_off") },
296
- { value: "PERCENTAGE", label: node._("dimmer.ui.turn_percentage") },
297
- { value: "LAST", label: node._("dimmer.ui.last_state") },
298
- { value: "LAST_SENDED", label: node._("dimmer.ui.last_sended_state") }
299
- ],
300
- }],
301
- });
302
-
303
- $("#node-input-alarm_off_percentage")
304
- .css("max-width", "4rem")
305
- .spinner({
306
- min: 0,
307
- max: 100,
308
- change: function (event, ui)
309
- {
310
- var value = parseInt(this.value);
311
- value = isNaN(value) ? 0 : value;
312
- value = Math.max(value, parseInt($(this).attr("aria-valuemin")));
313
- // value = Math.min(value, parseInt($(this).attr("aria-valuemax")));
314
- if (value !== this.value) $(this).spinner("value", value);
315
- },
316
- });
317
-
318
- $("#node-input-alarm_on_action").on("change", function ()
319
- {
320
- if (this.value == "PERCENTAGE")
321
- $("#alarm_on_percentage_block").show();
322
- else
323
- $("#alarm_on_percentage_block").hide();
324
- });
325
-
326
- $("#node-input-alarm_off_action").on("change", function ()
327
- {
328
- if (this.value == "PERCENTAGE")
329
- $("#alarm_off_percentage_block").show();
330
- else
331
- $("#alarm_off_percentage_block").hide();
332
- });
333
- },
334
- onadd: function ()
335
- {
336
- this.links = [];
337
- },
338
- oneditresize: resizeNodeList
339
- });
340
- })();
341
- </script>
342
-
343
- <script type="text/html" data-template-name="smart_dimmer-control">
344
- <div class="form-row">
345
- <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="dimmer.ui.name"></span></label>
346
- <input type="text" id="node-input-name" data-i18n="[placeholder]dimmer.ui.name" />
347
- </div>
348
- <div class="form-row">
349
- <label for="node-input-exec_text_names"><i class="fa fa-comments-o"></i> <span data-i18n="dimmer.ui.text"></span></label>
350
- <input id="node-input-exec_text_names" type="text" />
351
- <div style="max-width: 450px;" data-i18n="dimmer.ui.controlled_by_words"></div>
352
- </div>
353
- <div class="form-row">
354
- <label for="node-input-max_time_on"><i class="fa fa-clock-o"></i> <span data-i18n="dimmer.ui.max_time_on"></span></label>
355
- <input id="node-input-max_time_on" value="0" />
356
- <input id="node-input-max_time_on_unit" />
357
- </div>
358
- <div class="form-row">
359
- <label for="node-input-dim_time_total"><i class="fa fa-clock-o"></i> <span data-i18n="dimmer.ui.dim_time_on"></span></label>
360
- <input id="node-input-dim_time_total" value="0" />
361
- <input id="node-input-dim_time_total_unit" />
362
- </div>
363
- <div class="form-row">
364
- <label for="node-input-long_press_ms"><i class="fa fa-clock-o"></i> <span data-i18n="dimmer.ui.time_for_long"></span></label>
365
- <input id="node-input-long_press_ms" value="1000" />
366
- <span data-i18n="dimmer.ui.milliseconds"></span>
367
- </div>
368
- <div class="form-row">
369
- <label for="node-input-update_interval"><i class="fa fa-clock-o"></i> <span data-i18n="dimmer.ui.update_interval"></span></label>
370
- <input id="node-input-update_interval" value="500" />
371
- <span data-i18n="dimmer.ui.milliseconds"></span>
372
- </div>
373
- <div class="form-row">
374
- <label for="node-input-alarm_on_action"><i class="fa fa-exclamation-triangle"></i> <span data-i18n="dimmer.ui.alarm_on"></span></label>
375
- <input id="node-input-alarm_on_action"/>
376
- <span id="alarm_on_percentage_block" style="display: none;">
377
- <input id="node-input-alarm_on_percentage" value="0" /> %
378
- </span>
379
- </div>
380
- <div class="form-row">
381
- <label for="node-input-alarm_off_action"><i class="fa fa-exclamation-triangle"></i> <span data-i18n="dimmer.ui.alarm_off"></span></label>
382
- <input id="node-input-alarm_off_action"/>
383
- <span id="alarm_off_percentage_block" style="display: none;">
384
- <input id="node-input-alarm_off_percentage" value="0" /> %
385
- </span>
386
- </div>
387
- <span><i class="fa fa-link"></i> <span data-i18n="dimmer.ui.controlled_by_central"></span></span>
388
- <div class="form-row node-input-link-row node-input-link-rows"></div>
389
- </script>