smart-nodes 0.3.37 → 0.4.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.
- package/CHANGELOG.md +62 -0
- package/README.md +35 -17
- package/central/central.html +26 -12
- package/central/central.js +84 -26
- package/central/locales/de-DE/central.json +1 -4
- package/central/locales/en-US/central.json +0 -3
- package/compare/compare.html +40 -24
- package/compare/compare.js +69 -29
- package/compare/locales/de-DE/compare.json +5 -7
- package/compare/locales/en-US/compare.json +18 -8
- package/counter/counter.html +64 -17
- package/counter/counter.js +43 -20
- package/counter/locales/de-DE/counter.json +6 -9
- package/counter/locales/en-US/counter.json +12 -16
- package/delay/delay.html +18 -88
- package/delay/delay.js +63 -20
- package/delay/locales/de-DE/delay.html +71 -0
- package/delay/locales/de-DE/delay.json +19 -0
- package/delay/locales/en-US/delay.html +76 -0
- package/delay/locales/en-US/delay.json +19 -0
- package/forwarder/forwarder.html +11 -42
- package/forwarder/forwarder.js +59 -18
- package/forwarder/locales/de-DE/forwarder.html +32 -0
- package/forwarder/locales/de-DE/forwarder.json +15 -0
- package/forwarder/locales/en-US/forwarder.html +32 -0
- package/forwarder/locales/en-US/forwarder.json +15 -0
- package/heating-curve/heating-curve.html +10 -51
- package/heating-curve/heating-curve.js +38 -13
- package/heating-curve/locales/de-DE/heating-curve.html +38 -0
- package/heating-curve/locales/de-DE/heating-curve.json +12 -0
- package/heating-curve/locales/en-US/heating-curve.html +38 -0
- package/heating-curve/locales/en-US/heating-curve.json +12 -0
- package/hysteresis/hysteresis.html +43 -65
- package/hysteresis/hysteresis.js +94 -68
- package/hysteresis/locales/de-DE/hysteresis.html +36 -0
- package/hysteresis/locales/de-DE/hysteresis.json +27 -0
- package/hysteresis/locales/en-US/hysteresis.html +36 -0
- package/hysteresis/locales/en-US/hysteresis.json +27 -0
- package/{light-control/light-control.html → light/light.html} +34 -144
- package/{light-control/light-control.js → light/light.js} +151 -32
- package/light/locales/de-DE/light.html +149 -0
- package/light/locales/de-DE/light.json +24 -0
- package/light/locales/en-US/light.html +148 -0
- package/light/locales/en-US/light.json +24 -0
- package/logic/locales/de-DE/logic.html +12 -0
- package/logic/locales/de-DE/logic.json +26 -0
- package/logic/locales/en-US/logic.html +12 -0
- package/logic/locales/en-US/logic.json +26 -0
- package/logic/logic.html +27 -40
- package/logic/logic.js +63 -29
- package/long-press/locales/de-DE/long-press.html +5 -0
- package/long-press/locales/de-DE/long-press.json +13 -0
- package/long-press/locales/en-US/long-press.html +5 -0
- package/long-press/locales/en-US/long-press.json +13 -0
- package/{long-press-control/long-press-control.html → long-press/long-press.html} +10 -14
- package/long-press/long-press.js +163 -0
- package/mixing-valve/locales/de-DE/mixing-valve.html +65 -0
- package/mixing-valve/locales/de-DE/mixing-valve.json +19 -0
- package/mixing-valve/locales/en-US/mixing-valve.html +66 -0
- package/mixing-valve/locales/en-US/mixing-valve.json +19 -0
- package/mixing-valve/mixing-valve.html +15 -79
- package/mixing-valve/mixing-valve.js +87 -61
- package/multi-press/locales/de-DE/multi-press.html +5 -0
- package/multi-press/locales/de-DE/multi-press.json +12 -0
- package/multi-press/locales/en-US/multi-press.html +5 -0
- package/multi-press/locales/en-US/multi-press.json +12 -0
- package/{multi-press-control/multi-press-control.html → multi-press/multi-press.html} +9 -13
- package/{multi-press-control/multi-press-control.js → multi-press/multi-press.js} +53 -5
- package/package.json +7 -7
- package/persistence.js +1 -0
- package/scene/locales/de-DE/scene.html +105 -0
- package/scene/locales/de-DE/scene.json +21 -0
- package/scene/locales/en-US/scene.html +107 -0
- package/scene/locales/en-US/scene.json +20 -0
- package/{scene-control/scene-control.html → scene/scene.html} +18 -121
- package/{scene-control/scene-control.js → scene/scene.js} +76 -26
- package/scheduler/locales/de-DE/scheduler.html +30 -0
- package/scheduler/locales/de-DE/scheduler.json +21 -0
- package/scheduler/locales/en-US/scheduler.html +30 -0
- package/scheduler/locales/en-US/scheduler.json +21 -0
- package/scheduler/scheduler.html +34 -64
- package/scheduler/scheduler.js +85 -53
- package/shutter/locales/de-DE/shutter.html +127 -0
- package/shutter/locales/de-DE/shutter.json +11 -0
- package/shutter/locales/en-US/shutter.html +133 -0
- package/shutter/locales/en-US/shutter.json +11 -0
- package/{shutter-control/shutter-control.html → shutter/shutter.html} +7 -133
- package/{shutter-control/shutter-control.js → shutter/shutter.js} +116 -56
- package/shutter-complex/locales/de-DE/shutter-complex.html +120 -0
- package/shutter-complex/locales/de-DE/shutter-complex.json +20 -0
- package/shutter-complex/locales/en-US/shutter-complex.html +120 -0
- package/shutter-complex/locales/en-US/shutter-complex.json +20 -0
- package/{shutter-complex-control/shutter-complex-control.html → shutter-complex/shutter-complex.html} +30 -133
- package/shutter-complex/shutter-complex.js +578 -0
- package/smart_helper.js +52 -9
- package/statistic/locales/de-DE/statistic.html +10 -0
- package/statistic/locales/de-DE/statistic.json +29 -0
- package/statistic/locales/en-US/statistic.html +10 -0
- package/statistic/locales/en-US/statistic.json +29 -0
- package/statistic/statistic.html +32 -36
- package/statistic/statistic.js +57 -28
- package/text-exec/locales/de-DE/text-exec.html +18 -0
- package/text-exec/locales/de-DE/text-exec.json +7 -0
- package/text-exec/locales/en-US/text-exec.html +18 -0
- package/text-exec/locales/en-US/text-exec.json +7 -0
- package/text-exec/text-exec.html +9 -25
- package/text-exec/text-exec.js +43 -2
- package/long-press-control/long-press-control.js +0 -76
- package/shutter-complex-control/shutter-complex-control.js +0 -442
package/CHANGELOG.md
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
- Separate values for shutter_complex node for up and down times.
|
|
7
7
|
(Open each node and save it, to use the new times. This should be done before the version 0.4.0 is released.)
|
|
8
8
|
- For the following nodes you can choose to have one or two outputs (Could be a **breaking change**, please check your nodes).
|
|
9
|
+
|
|
9
10
|
- Logic
|
|
10
11
|
- Compare
|
|
11
12
|
- Hysteresis
|
|
13
|
+
|
|
12
14
|
- You can now separately declare the messages that should be sent by the following nodes (Could be a **breaking change**, please check your nodes).
|
|
15
|
+
|
|
13
16
|
- Logic
|
|
14
17
|
- Compare
|
|
15
18
|
- Hysteresis
|
|
@@ -18,3 +21,62 @@
|
|
|
18
21
|
- Logic
|
|
19
22
|
- Compare
|
|
20
23
|
- Hysteresis
|
|
24
|
+
|
|
25
|
+
## Version 0.3.29:
|
|
26
|
+
|
|
27
|
+
- Fixed that hysteresis sends only on change, when separate outputs are enabled.
|
|
28
|
+
- Added a definable short up/down time for the shutter control.
|
|
29
|
+
- Fixed calculation of the time from string.
|
|
30
|
+
|
|
31
|
+
## Version 0.3.30:
|
|
32
|
+
|
|
33
|
+
- Added counter example.
|
|
34
|
+
|
|
35
|
+
## Version 0.3.31:
|
|
36
|
+
|
|
37
|
+
- Fixed logic node - invert output option.
|
|
38
|
+
|
|
39
|
+
## Version 0.3.32:
|
|
40
|
+
|
|
41
|
+
- Fixed hysteresis node - always change result.
|
|
42
|
+
|
|
43
|
+
## Version 0.3.33:
|
|
44
|
+
|
|
45
|
+
- Fixed hysteresis node - init send.
|
|
46
|
+
|
|
47
|
+
## Version 0.3.34:
|
|
48
|
+
|
|
49
|
+
- Fixed hysteresis node - init send.
|
|
50
|
+
- Fixed light node - status.
|
|
51
|
+
|
|
52
|
+
## Version 0.3.35:
|
|
53
|
+
|
|
54
|
+
- Fixed saving last message object as a clone of the original message, because it could be changed later.
|
|
55
|
+
|
|
56
|
+
## Version 0.3.36:
|
|
57
|
+
|
|
58
|
+
- Fixed mixing-valve - call of toFixed function.
|
|
59
|
+
|
|
60
|
+
## Version 0.3.37:
|
|
61
|
+
|
|
62
|
+
- Fixed using typedInput with node-red v4.
|
|
63
|
+
- Started to add English translations.
|
|
64
|
+
|
|
65
|
+
## Version 0.4.0:
|
|
66
|
+
|
|
67
|
+
- Fully added English and German translations.
|
|
68
|
+
- Light control: Added Alarm off action
|
|
69
|
+
- Shutter complex control: Added Alarm off action
|
|
70
|
+
- Restructured the complete code
|
|
71
|
+
- Improved status texts
|
|
72
|
+
- **breaking change** (soon): Changed some node internal values. Please open and save the following node types:
|
|
73
|
+
|
|
74
|
+
- Central node
|
|
75
|
+
- Compare node
|
|
76
|
+
- Counter node
|
|
77
|
+
- Hysteresis node
|
|
78
|
+
- Shutter complex node
|
|
79
|
+
- Statistic node
|
|
80
|
+
|
|
81
|
+
After saving the nodes, the values are automatically converted to the new one.
|
|
82
|
+
This conversion will be removed in version 0.5.0.
|
package/README.md
CHANGED
|
@@ -4,17 +4,29 @@ The smart nodes was created to control smart home devices like lights, power out
|
|
|
4
4
|
This nodes are designed to work with the [node-red-contrib-knx-ultimate](https://github.com/Supergiovane/node-red-contrib-knx-ultimate) but it could also work with other smart technologies.
|
|
5
5
|
|
|
6
6
|
The knx binary input and output/switching modules should be configured very stupid. Closing a binary input should output 1 and releasing 0.
|
|
7
|
-
Same for the output/switching modules, 1 should turn on and 0 turn
|
|
8
|
-
Some node has to filter out the binary inputs if they goes to 0 or in other words, if `msg.payload == false`. Please see the internal node documentation then this signals are ignored. As an example sending
|
|
7
|
+
Same for the output/switching modules, 1 should turn on and 0 turn off. That makes it easy to count the presses or check for short and long presses.
|
|
8
|
+
Some node has to filter out the binary inputs if they goes to 0 or in other words, if `msg.payload == false`. Please see the internal node documentation then this signals are ignored. As an example sending `msg.topic = "toggle"` for pressing and releasing an button would toggle the output twice.
|
|
9
9
|
|
|
10
10
|
Sometimes one source node should be connected to multiple smart nodes which requires different topics.
|
|
11
|
-
To avoid requiring many change nodes, the smart
|
|
12
|
-
Smart nodes that requires a name are using only the name part. the # and the number are optional. Smart nodes that requries a number will only use the number, the name and # is also optional.
|
|
11
|
+
To avoid requiring many change nodes, the smart nodes are using a special `msg.topic` notation. You can always send topics in the format `name#number`, e.g. `toggle#1`.
|
|
12
|
+
Smart nodes that requires a name are using only the name part. the # and the number are ignored and optional. Smart nodes that requries a number will only use the number, the name and # is also ignored and optional.
|
|
13
13
|
|
|
14
|
-
This is usefull when one node
|
|
14
|
+
This is usefull when one node provides information for example to a light control node and also to a logic node.
|
|
15
15
|
|
|
16
16
|
This file only describes the general function of the node. See the documentation shown in NodeRed to find out how to use them, or see the included example flows.
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
# Important info
|
|
19
|
+
|
|
20
|
+
This smart nodes are still in development and can have breaking changes. So please always take a look in the [Changelog](CHANGELOG.md) file.
|
|
21
|
+
|
|
22
|
+
# Support
|
|
23
|
+
|
|
24
|
+
I spent a lots of hours in this project. If you like it, you can support my work in different ways:
|
|
25
|
+
|
|
26
|
+
- Report bugs.
|
|
27
|
+
- Create pull requests.
|
|
28
|
+
- Name tipps and tricks if you see any improvement.
|
|
29
|
+
- Donate via [Paypal](https://paypal.me/BergenSoft).
|
|
18
30
|
|
|
19
31
|
# Nodes
|
|
20
32
|
|
|
@@ -27,8 +39,9 @@ This node is able to control a light or a power outlet.
|
|
|
27
39
|
- Auto turn off the light after a fixed time.
|
|
28
40
|
- Auto turn off the light with a custom time which is part of the message object.
|
|
29
41
|
- Toggle light between on and off.
|
|
30
|
-
- Can be
|
|
31
|
-
- Has an alarm function to go to a specific state (on or off) when the alarm is activated.
|
|
42
|
+
- Can be activated by motion sensors.
|
|
43
|
+
- Has an alarm on function to go to a specific state (on or off) when the alarm is activated.
|
|
44
|
+
- Has an alarm off function to go to a specific (on, off, the last or the last sended) when the alarm is deactivated.
|
|
32
45
|
|
|
33
46
|
## 2. Shutter control
|
|
34
47
|
|
|
@@ -38,10 +51,11 @@ There is no support for slats and it is also not planned as I don't need them, b
|
|
|
38
51
|
### **Features:**
|
|
39
52
|
|
|
40
53
|
- One button control which switch between `up`, `stop`, `down`, `stop`.
|
|
41
|
-
-
|
|
42
|
-
- Send direct position the shutter should
|
|
54
|
+
- Two button control for each direction `up and stop` and `down and stop`.
|
|
55
|
+
- Send direct position the shutter should go to.
|
|
43
56
|
- Stop shutter immediately.
|
|
44
|
-
- Has an alarm function to go to a specific state (Open or close) when the alarm is activated.
|
|
57
|
+
- Has an alarm on function to go to a specific state (Open or close) when the alarm is activated.
|
|
58
|
+
- Has an alarm off function to restore a specific state when the alarm gets deaktivated.
|
|
45
59
|
|
|
46
60
|
## 3. Scene control
|
|
47
61
|
|
|
@@ -165,13 +179,17 @@ This node parses a text and performs actions to the selected and matching smart
|
|
|
165
179
|
|
|
166
180
|
### Examples
|
|
167
181
|
|
|
168
|
-
[
|
|
182
|
+
Text in [ Braces ] is optional<br/>
|
|
183
|
+
Room names that has to be entered in the nodes are in `code` style.
|
|
184
|
+
|
|
185
|
+
- Turn on [the light in] the `living room` and the `kitchen` off.
|
|
186
|
+
- Open [the shutter in] the `kitchen` and turn `studio` off.
|
|
187
|
+
- Close [the shutter in the] `sleeping` room.
|
|
188
|
+
- `Living room` to 10 %.
|
|
189
|
+
- Turn on `living room` except the `couch` light.
|
|
190
|
+
|
|
191
|
+
### **Features:**
|
|
169
192
|
|
|
170
|
-
- Turn on [the light in] the living room and the kitchen off.
|
|
171
|
-
- Open [the shutter in] the kitchen and turn studio off.
|
|
172
|
-
- Close [the shutter in the] sleeping room.
|
|
173
|
-
- Living room to 10 %.
|
|
174
|
-
- Turn on living room except the couch light.
|
|
175
193
|
- Sends debug message to output.
|
|
176
194
|
|
|
177
195
|
## 15. Mixing valve
|
package/central/central.html
CHANGED
|
@@ -256,14 +256,14 @@
|
|
|
256
256
|
color: "#6EE2D9",
|
|
257
257
|
defaults: {
|
|
258
258
|
name: { value: "" },
|
|
259
|
-
mode: { value: "
|
|
259
|
+
mode: { value: "LIGHT" }, // LIGHT | SHUTTER
|
|
260
260
|
links: { value: [], type: "smart_shutter-complex-control[]" },
|
|
261
261
|
},
|
|
262
262
|
inputs: 1,
|
|
263
263
|
outputs: 0,
|
|
264
264
|
icon: function ()
|
|
265
265
|
{
|
|
266
|
-
if (this.mode === "
|
|
266
|
+
if (this.mode === "SHUTTER")
|
|
267
267
|
return "font-awesome/fa-align-justify";
|
|
268
268
|
|
|
269
269
|
return "font-awesome/fa-lightbulb-o";
|
|
@@ -279,19 +279,36 @@
|
|
|
279
279
|
onEditPrepare(this, ["smart_shutter-complex-control", "smart_shutter-control"]);
|
|
280
280
|
$("#node-input-mode").on("change", function ()
|
|
281
281
|
{
|
|
282
|
-
if (this.value == "
|
|
282
|
+
if (this.value == "SHUTTER")
|
|
283
283
|
initTreeList(node, ["smart_shutter-complex-control", "smart_shutter-control"]);
|
|
284
284
|
else
|
|
285
285
|
initTreeList(node, ["smart_light-control", "smart_scene-control"]);
|
|
286
286
|
});
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
$("#node-input-mode").typedInput({
|
|
289
|
+
types: [{
|
|
290
|
+
default: "LIGHT",
|
|
291
|
+
value: "mode",
|
|
292
|
+
options: [
|
|
293
|
+
{ value: "LIGHT", label: node._("central.ui.light_outlet") },
|
|
294
|
+
{ value: "SHUTTER", label: node._("central.ui.cover") }
|
|
295
|
+
],
|
|
296
|
+
}],
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Backward compatibility
|
|
300
|
+
this.mode = this.mode?.toUpperCase();
|
|
301
|
+
|
|
302
|
+
if (this.mode)
|
|
303
|
+
$("#node-input-mode").val(this.mode).trigger("change");
|
|
304
|
+
else
|
|
305
|
+
$("#node-input-mode").val("SHUTTER").trigger("change");
|
|
306
|
+
|
|
292
307
|
},
|
|
293
308
|
oneditsave: function ()
|
|
294
309
|
{
|
|
310
|
+
let node = this;
|
|
311
|
+
|
|
295
312
|
onEditSave(this);
|
|
296
313
|
},
|
|
297
314
|
onadd: onAdd,
|
|
@@ -306,11 +323,8 @@
|
|
|
306
323
|
<input type="text" id="node-input-name" />
|
|
307
324
|
</div>
|
|
308
325
|
<div class="form-row">
|
|
309
|
-
<label for="node-input-mode"><span data-i18n="central.ui.type"></span></label>
|
|
310
|
-
<
|
|
311
|
-
<option value="shutter" selected><span data-i18n="central.ui.cover"></span></option>
|
|
312
|
-
<option value="light"><span data-i18n="central.ui.light_outlet"></span></option>
|
|
313
|
-
</select>
|
|
326
|
+
<label for="node-input-mode"><i class="fa fa-arrow-right"></i> <span data-i18n="central.ui.type"></span></label>
|
|
327
|
+
<input id="node-input-mode"/>
|
|
314
328
|
</div>
|
|
315
329
|
<div class="node-input-link-rows" style="position:relative; height: 30px; text-align: right;"
|
|
316
330
|
><div style="display:inline-block"><input type="text" id="node-input-link-target-filter" /></div
|
package/central/central.js
CHANGED
|
@@ -7,48 +7,98 @@ module.exports = function (RED)
|
|
|
7
7
|
const node = this;
|
|
8
8
|
RED.nodes.createNode(node, config);
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// ###################
|
|
11
|
+
// # Class constants #
|
|
12
|
+
// ###################
|
|
13
|
+
const MODE_LIGHT = "LIGHT"
|
|
14
|
+
const MODE_SHUTTER = "SHUTTER";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// #######################
|
|
18
|
+
// # Global help objects #
|
|
19
|
+
// #######################
|
|
20
|
+
const smart_context = require("../persistence.js")(RED);
|
|
21
|
+
const helper = require("../smart_helper.js");
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// #####################
|
|
25
|
+
// # persistent values #
|
|
26
|
+
// #####################
|
|
27
|
+
// Not used from this node
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// ##################
|
|
31
|
+
// # Dynamic config #
|
|
32
|
+
// ##################
|
|
33
|
+
let mode = config.mode?.toUpperCase() ?? MODE_LIGHT;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// ##################
|
|
37
|
+
// # Runtime values #
|
|
38
|
+
// ##################
|
|
39
|
+
|
|
40
|
+
// This map saves the state of all connected nodes.
|
|
41
|
+
// The key is the node id of the connected node.
|
|
11
42
|
let states = new Map();
|
|
12
43
|
|
|
13
|
-
|
|
44
|
+
|
|
45
|
+
// #########################
|
|
46
|
+
// # Central node handling #
|
|
47
|
+
// #########################
|
|
14
48
|
let event = "node:" + config.id;
|
|
15
49
|
let handler = function (msg)
|
|
16
50
|
{
|
|
17
51
|
if (typeof msg.source == "undefined" || typeof msg.state == "undefined")
|
|
18
52
|
{
|
|
19
|
-
console.warn(
|
|
53
|
+
console.warn("Unknown message received in smart_node central.", msg);
|
|
20
54
|
return;
|
|
21
55
|
}
|
|
22
56
|
|
|
23
57
|
// Save feedback from linked node
|
|
24
58
|
states.set(msg.source, msg.state);
|
|
25
|
-
|
|
26
|
-
if (isAllOff())
|
|
27
|
-
node.status({ fill: "red", shape: "dot", text: "central.status.all_off" });
|
|
28
|
-
else
|
|
29
|
-
node.status({ fill: "green", shape: "dot", text: "central.status.Something_is_on" });
|
|
59
|
+
setStatus();
|
|
30
60
|
}
|
|
31
61
|
RED.events.on(event, handler);
|
|
32
62
|
|
|
33
|
-
node.status({});
|
|
34
63
|
|
|
35
64
|
node.on("input", function (msg)
|
|
65
|
+
{
|
|
66
|
+
handleTopic(msg);
|
|
67
|
+
|
|
68
|
+
setStatus();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
node.on("close", function ()
|
|
72
|
+
{
|
|
73
|
+
// Cleanup event listener
|
|
74
|
+
RED.events.removeListener(event, handler);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// #####################
|
|
79
|
+
// # Private functions #
|
|
80
|
+
// #####################
|
|
81
|
+
|
|
82
|
+
// This is the main function which handles all topics that was received.
|
|
83
|
+
let handleTopic = msg =>
|
|
36
84
|
{
|
|
37
85
|
// copy message, so original message stays unchanged
|
|
38
|
-
let new_msg =
|
|
86
|
+
let new_msg = helper.cloneObject(msg);
|
|
87
|
+
|
|
88
|
+
let real_topic = helper.getTopicName(msg.topic);
|
|
39
89
|
|
|
40
90
|
// make connected nodes behavior homogenous
|
|
41
|
-
switch (
|
|
91
|
+
switch (mode)
|
|
42
92
|
{
|
|
43
|
-
case
|
|
44
|
-
if (
|
|
93
|
+
case MODE_SHUTTER:
|
|
94
|
+
if (real_topic == "up_stop")
|
|
45
95
|
{
|
|
46
96
|
if (isAllOff())
|
|
47
97
|
new_msg.topic = "up";
|
|
48
98
|
else
|
|
49
99
|
new_msg.topic = "stop";
|
|
50
100
|
}
|
|
51
|
-
else if (
|
|
101
|
+
else if (real_topic == "down_stop")
|
|
52
102
|
{
|
|
53
103
|
if (isAllOff())
|
|
54
104
|
new_msg.topic = "down";
|
|
@@ -57,8 +107,8 @@ module.exports = function (RED)
|
|
|
57
107
|
}
|
|
58
108
|
break;
|
|
59
109
|
|
|
60
|
-
case
|
|
61
|
-
if (
|
|
110
|
+
case MODE_LIGHT:
|
|
111
|
+
if (real_topic == "toggle")
|
|
62
112
|
{
|
|
63
113
|
if (isAllOff())
|
|
64
114
|
new_msg.topic = "on";
|
|
@@ -71,19 +121,16 @@ module.exports = function (RED)
|
|
|
71
121
|
// Send cloned message to all linked nodes
|
|
72
122
|
config.links.forEach(link =>
|
|
73
123
|
{
|
|
74
|
-
|
|
75
|
-
|
|
124
|
+
helper.log(node.id + " -> " + link);
|
|
125
|
+
helper.log(new_msg);
|
|
76
126
|
RED.events.emit("node:" + link, new_msg);
|
|
77
127
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
node.on("close", function ()
|
|
81
|
-
{
|
|
82
|
-
// Cleanup event listener
|
|
83
|
-
RED.events.removeListener(event, handler);
|
|
84
|
-
});
|
|
128
|
+
}
|
|
85
129
|
|
|
86
|
-
|
|
130
|
+
/**
|
|
131
|
+
* This functions return true if all lights are off or all shutter are stopped
|
|
132
|
+
* @returns true if all is off
|
|
133
|
+
*/
|
|
87
134
|
let isAllOff = () =>
|
|
88
135
|
{
|
|
89
136
|
for (let [key, state] of states)
|
|
@@ -94,6 +141,17 @@ module.exports = function (RED)
|
|
|
94
141
|
|
|
95
142
|
return true;
|
|
96
143
|
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set the current node status
|
|
147
|
+
*/
|
|
148
|
+
let setStatus = () =>
|
|
149
|
+
{
|
|
150
|
+
if (isAllOff())
|
|
151
|
+
node.status({ fill: "red", shape: "dot", text: "central.status.all_off" });
|
|
152
|
+
else
|
|
153
|
+
node.status({ fill: "green", shape: "dot", text: "central.status.Something_is_on" });
|
|
154
|
+
}
|
|
97
155
|
}
|
|
98
156
|
RED.nodes.registerType("smart_central-control", CentralControlNode);
|
|
99
157
|
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"central": {
|
|
3
|
-
"errors": {
|
|
4
|
-
"unknown_message": "Unbekannte Nachricht in smart_node central empfangen."
|
|
5
|
-
},
|
|
6
3
|
"status": {
|
|
7
4
|
"all_off": "Alles aus",
|
|
8
|
-
"Something_is_on": "
|
|
5
|
+
"Something_is_on": "Etwas ist an"
|
|
9
6
|
},
|
|
10
7
|
"ui": {
|
|
11
8
|
"name": "Name",
|
package/compare/compare.html
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
category: "Smart Nodes",
|
|
4
4
|
paletteLabel: "Compare",
|
|
5
5
|
color: "#E2D96E",
|
|
6
|
-
color: "#E2D96E",
|
|
7
6
|
defaults: {
|
|
8
7
|
name: { value: "" },
|
|
9
8
|
comparator: { value: "EQUAL" }, // EQUAL, GREATER, GREATER_EQUAL, SMALLER, SMALLER_EQUAL, UNEQUAL
|
|
10
9
|
value1: { value: "" },
|
|
11
|
-
value1_type: { value: "
|
|
10
|
+
value1_type: { value: "NOTHING" },
|
|
12
11
|
value2: { value: "" },
|
|
13
|
-
value2_type: { value: "
|
|
12
|
+
value2_type: { value: "NOTHING" },
|
|
14
13
|
out_false: { value: '{"topic": ""}' },
|
|
15
14
|
out_false_type: { value: 'json' },
|
|
16
15
|
out_true: { value: '{"topic": ""}' },
|
|
@@ -33,17 +32,19 @@
|
|
|
33
32
|
},
|
|
34
33
|
oneditprepare: function ()
|
|
35
34
|
{
|
|
35
|
+
let node = this;
|
|
36
|
+
|
|
36
37
|
$("#node-input-comparator").typedInput({
|
|
37
38
|
types: [{
|
|
38
39
|
default: "EQUAL",
|
|
39
40
|
value: "comperator",
|
|
40
41
|
options: [
|
|
41
|
-
{ value: "SMALLER", label: "
|
|
42
|
-
{ value: "SMALLER_EQUAL", label: "
|
|
43
|
-
{ value: "EQUAL", label: "
|
|
44
|
-
{ value: "UNEQUAL", label: "
|
|
45
|
-
{ value: "GREATER_EQUAL", label: "
|
|
46
|
-
{ value: "GREATER", label: "
|
|
42
|
+
{ value: "SMALLER", label: node._("compare.ui.smaller") },
|
|
43
|
+
{ value: "SMALLER_EQUAL", label: node._("compare.ui.smaller_equal") },
|
|
44
|
+
{ value: "EQUAL", label: node._("compare.ui.equal") },
|
|
45
|
+
{ value: "UNEQUAL", label: node._("compare.ui.unequal") },
|
|
46
|
+
{ value: "GREATER_EQUAL", label: node._("compare.ui.greater_equal") },
|
|
47
|
+
{ value: "GREATER", label: node._("compare.ui.greater") },
|
|
47
48
|
],
|
|
48
49
|
}],
|
|
49
50
|
});
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
$("#node-input-value1").typedInput({
|
|
52
53
|
type: "num",
|
|
53
54
|
types: ["str", "num", "bool", {
|
|
54
|
-
value: "
|
|
55
|
-
label:
|
|
55
|
+
value: "NOTHING",
|
|
56
|
+
label: node._("compare.ui.no_value"),
|
|
56
57
|
icon: "fa fa-times",
|
|
57
58
|
hasValue: false,
|
|
58
59
|
}],
|
|
@@ -62,8 +63,8 @@
|
|
|
62
63
|
$("#node-input-value2").typedInput({
|
|
63
64
|
type: "num",
|
|
64
65
|
types: ["str", "num", "bool", {
|
|
65
|
-
value: "
|
|
66
|
-
label:
|
|
66
|
+
value: "NOTHING",
|
|
67
|
+
label: node._("compare.ui.no_value"),
|
|
67
68
|
icon: "fa fa-times",
|
|
68
69
|
hasValue: false,
|
|
69
70
|
}],
|
|
@@ -75,8 +76,8 @@
|
|
|
75
76
|
$("#node-input-out_true").typedInput({
|
|
76
77
|
type: "json",
|
|
77
78
|
types: ["json", {
|
|
78
|
-
value: "
|
|
79
|
-
label:
|
|
79
|
+
value: "NOTHING",
|
|
80
|
+
label: node._("compare.ui.send_nothing"),
|
|
80
81
|
icon: "fa fa-times",
|
|
81
82
|
hasValue: false,
|
|
82
83
|
}],
|
|
@@ -86,8 +87,8 @@
|
|
|
86
87
|
$("#node-input-out_false").typedInput({
|
|
87
88
|
type: "json",
|
|
88
89
|
types: ["json", {
|
|
89
|
-
value: "
|
|
90
|
-
label:
|
|
90
|
+
value: "NOTHING",
|
|
91
|
+
label: node._("compare.ui.send_nothing"),
|
|
91
92
|
icon: "fa fa-times",
|
|
92
93
|
hasValue: false,
|
|
93
94
|
}],
|
|
@@ -100,8 +101,8 @@
|
|
|
100
101
|
value: "1",
|
|
101
102
|
value: "send_only_change",
|
|
102
103
|
options: [
|
|
103
|
-
{ value: "true", label:
|
|
104
|
-
{ value: "false", label:
|
|
104
|
+
{ value: "true", label: node._("compare.ui.send_only_change") },
|
|
105
|
+
{ value: "false", label: node._("compare.ui.always") },
|
|
105
106
|
]
|
|
106
107
|
}]
|
|
107
108
|
});
|
|
@@ -112,8 +113,8 @@
|
|
|
112
113
|
value: "1",
|
|
113
114
|
value: "outputs",
|
|
114
115
|
options: [
|
|
115
|
-
{ value: "1", label:
|
|
116
|
-
{ value: "2", label:
|
|
116
|
+
{ value: "1", label: node._("compare.ui.common_output") },
|
|
117
|
+
{ value: "2", label: node._("compare.ui.separate_output") },
|
|
117
118
|
]
|
|
118
119
|
}]
|
|
119
120
|
});
|
|
@@ -128,6 +129,22 @@
|
|
|
128
129
|
$("#resend_on_start_row").hide();
|
|
129
130
|
});
|
|
130
131
|
$("#node-input-save_state").trigger("change");
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// Backward compatibility
|
|
136
|
+
if (this.value1_type == "null")
|
|
137
|
+
{
|
|
138
|
+
this.value1_type = "NOTHING";
|
|
139
|
+
$("#node-input-value1_type").val("NOTHING");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (this.value2_type == "null")
|
|
143
|
+
{
|
|
144
|
+
this.value2_type = "NOTHING";
|
|
145
|
+
$("#node-input-value2_type").val("NOTHING");
|
|
146
|
+
}
|
|
147
|
+
|
|
131
148
|
},
|
|
132
149
|
});
|
|
133
150
|
</script>
|
|
@@ -175,9 +192,8 @@
|
|
|
175
192
|
<input id="node-input-outputs" />
|
|
176
193
|
</div>
|
|
177
194
|
<div class="form-row" style="max-width: 28rem">
|
|
178
|
-
<div><strong
|
|
179
|
-
<div
|
|
180
|
-
<div><code>msg.comperator</code> <span data-i18n="compare.ui.note_comperator"></span></div>
|
|
195
|
+
<div><strong data-i18n="compare.ui.note"></strong></div>
|
|
196
|
+
<div data-i18n="[html]compare.ui.note_text"></div>
|
|
181
197
|
</div>
|
|
182
198
|
<hr/>
|
|
183
199
|
<h4 style="margin: 0.5rem 0;"><span data-i18n="compare.ui.system_start"></span></h4>
|