smart-nodes 0.3.7 → 0.3.13
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 +82 -47
- package/compare/compare.js +1 -1
- package/delay/delay.js +11 -11
- package/examples/central.json +804 -0
- package/examples/central.png +0 -0
- package/examples/compare.json +916 -0
- package/examples/compare.png +0 -0
- package/examples/delay.json +198 -0
- package/examples/delay.png +0 -0
- package/examples/forwarder.json +152 -0
- package/examples/forwarder.png +0 -0
- package/examples/hysteresis.json +358 -0
- package/examples/hysteresis.png +0 -0
- package/examples/light-control.json +499 -0
- package/examples/light-control.png +0 -0
- package/examples/logic.json +562 -0
- package/examples/logic.png +0 -0
- package/examples/long-press-control.json +113 -0
- package/examples/long-press-control.png +0 -0
- package/examples/multi-press-control.json +136 -0
- package/examples/multi-press-control.png +0 -0
- package/examples/scene-control.json +535 -0
- package/examples/scene-control.png +0 -0
- package/examples/scheduler.json +164 -0
- package/examples/scheduler.png +0 -0
- package/examples/shutter-complex-control.json +489 -0
- package/examples/shutter-complex-control.png +0 -0
- package/examples/shutter-control.json +457 -0
- package/examples/shutter-control.png +0 -0
- package/examples/statistic.json +1112 -0
- package/examples/statistic.png +0 -0
- package/examples/text-exec.json +147 -0
- package/examples/text-exec.png +0 -0
- package/forwarder/forwarder.js +2 -2
- package/hysteresis/hysteresis.js +12 -12
- package/light-control/light-control.js +4 -4
- package/logic/logic.js +1 -1
- package/long-press-control/long-press-control.js +4 -5
- package/multi-press-control/multi-press-control.js +1 -1
- package/package.json +1 -1
- package/scene-control/scene-control.js +3 -3
- package/scheduler/scheduler.js +4 -4
- package/shutter-complex-control/shutter-complex-control.js +10 -10
- package/shutter-control/shutter-control.js +12 -12
- package/statistic/statistic.js +2 -2
- package/text-exec/text-exec.js +39 -3
package/README.md
CHANGED
|
@@ -17,124 +17,159 @@ This file only describes the general function of the node. See the documentation
|
|
|
17
17
|
As I'm german, the internal documentation is only available in german. If you need another language, feel free to add localizations and adding more languages via a pull request.
|
|
18
18
|
|
|
19
19
|
# Nodes
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
## 1. Light control
|
|
22
|
+
|
|
21
23
|
This node is able to control a light or a power outlet.
|
|
22
24
|
|
|
23
25
|
### **Features:**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
- Auto turn off the light after a fixed time.
|
|
28
|
+
- Auto turn off the light with a custom time which is part of the message object.
|
|
29
|
+
- Toggle light between on and off.
|
|
30
|
+
- Can be triggered by motion sensors.
|
|
31
|
+
- Has an alarm function to go to a specific state (on or off) when the alarm is activated.
|
|
29
32
|
|
|
30
33
|
## 2. Shutter control
|
|
34
|
+
|
|
31
35
|
This node is able to control a shutter.
|
|
32
36
|
There is no support for slats and it is also not planned as I don't need them, but feel free to send a pull request.
|
|
33
37
|
|
|
34
38
|
### **Features:**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
- One button control which switch between `up`, `stop`, `down`, `stop`.
|
|
41
|
+
- One button control for each direction `up and stop` or `down and stop`.
|
|
42
|
+
- Send direct position the shutter should be.
|
|
43
|
+
- Stop shutter immediately.
|
|
44
|
+
- Has an alarm function to go to a specific state (Open or close) when the alarm is activated.
|
|
40
45
|
|
|
41
46
|
## 3. Scene control
|
|
47
|
+
|
|
42
48
|
This node is tracking the state of multiple outputs and controls them by switching to multiple defined scenes.
|
|
43
49
|
|
|
44
50
|
### **Features:**
|
|
45
|
-
|
|
51
|
+
|
|
52
|
+
- An input message could name multiple scenes that should be iterated one by one by receiving the same message multiple times
|
|
46
53
|
|
|
47
54
|
## 4. Central control
|
|
55
|
+
|
|
48
56
|
This node can control multiple light/scene controls or shutter controls at the same time
|
|
49
57
|
|
|
50
58
|
### **Features:**
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
|
|
60
|
+
- Take care that multiple light/scene controls are turned of if any of them is one before executing a toggle command. This is helpful to avoid turning one light on and the other off.
|
|
61
|
+
- The same is used for shutters with the up_stop or down_stop commands. A toggle is not supported, it will only be forwarded.
|
|
53
62
|
|
|
54
63
|
## 5. Long press control
|
|
64
|
+
|
|
55
65
|
This control is used to detect a short or a long press.
|
|
56
66
|
The time can be configured in this control.
|
|
57
67
|
|
|
58
68
|
### **Features:**
|
|
59
|
-
|
|
69
|
+
|
|
70
|
+
- Imediately send a message to the long press output when the time is reached. It is not waiting until the button is released.
|
|
60
71
|
|
|
61
72
|
## 6. Multi press control
|
|
73
|
+
|
|
62
74
|
This control is used to detect multiple presses on a button.
|
|
63
75
|
The max wait time between presses can be configured in this control.
|
|
64
76
|
You can also choose 2-4 press detection.
|
|
65
77
|
|
|
66
78
|
### **Features:**
|
|
67
|
-
|
|
79
|
+
|
|
80
|
+
- Imediately send a message to the last output when the max presses are reached. It is not waiting until the button is released.
|
|
68
81
|
|
|
69
82
|
## 7. Hysteresis
|
|
83
|
+
|
|
70
84
|
This control 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
|
|
71
85
|
|
|
72
86
|
### **Features:**
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
|
|
88
|
+
- The state can be saved between NodeRed restarts.
|
|
89
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
75
90
|
|
|
76
91
|
## 8. Logic
|
|
92
|
+
|
|
77
93
|
This control can be used for AND, OR and XOR logics.
|
|
78
94
|
|
|
79
95
|
### **Features:**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
|
|
97
|
+
- All input values could be individual converted as well as the output messsage.
|
|
98
|
+
- A NOT logic is possible when selecting 1 input and convert the output.
|
|
99
|
+
- The setpoint and hysteresis value can be changed in runtime.
|
|
100
|
+
- The state can be saved between NodeRed restarts.
|
|
101
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
85
102
|
|
|
86
103
|
## 9. Statistic
|
|
104
|
+
|
|
87
105
|
This control can be used for getting the following types of values: Minimum, Maximum, Sum, Difference, Absolute Value, Absolute Difference, Average and Running average.
|
|
88
106
|
|
|
89
107
|
### **Features:**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
|
|
109
|
+
- All input values could be individual converted as well as the output messsage.
|
|
110
|
+
- A NOT logic is possible when selecting 1 input and convert the output.
|
|
111
|
+
- The state can be saved between NodeRed restarts.
|
|
112
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
94
113
|
|
|
95
114
|
## 10. Compare
|
|
115
|
+
|
|
96
116
|
This control can compare 2 values with the following operators: < <= == >= > !=
|
|
97
117
|
|
|
98
118
|
### **Features:**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
|
|
120
|
+
- Can compare also texts like js would do.
|
|
121
|
+
- The state can be saved between NodeRed restarts.
|
|
122
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
102
123
|
|
|
103
124
|
## 11. Delay
|
|
125
|
+
|
|
104
126
|
This control can delay incomming messages.
|
|
105
127
|
|
|
106
128
|
### **Features:**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
|
|
130
|
+
- Different times for `msg.payload = true` and `msg.payload = false`.
|
|
131
|
+
- Delays can be changed in runtime.
|
|
132
|
+
- The state can be saved between NodeRed restarts.
|
|
133
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
111
134
|
|
|
112
135
|
## 12. Forwarder
|
|
136
|
+
|
|
113
137
|
This control can control if an incomming message should be forwarded or not.
|
|
114
138
|
|
|
115
139
|
### **Features:**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
140
|
+
|
|
141
|
+
- The forwarding can be enabled or disabled in runtime.
|
|
142
|
+
- The state can be saved between NodeRed restarts.
|
|
143
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
119
144
|
|
|
120
145
|
## 13. Scheduler
|
|
146
|
+
|
|
121
147
|
This control can send a defined message on defined times.
|
|
122
148
|
|
|
123
149
|
### **Features:**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
150
|
+
|
|
151
|
+
- The weekdays and the time can be selected as a trigger.
|
|
152
|
+
- Multiple trigger and messages can be defined in one node.
|
|
153
|
+
- The scheduler can be activated or deactivated in runtime.
|
|
154
|
+
- The state can be saved between NodeRed restarts.
|
|
155
|
+
- The last message can automatically be sent 10 seconds after a deployment.
|
|
129
156
|
|
|
130
157
|
## 14. Text execution
|
|
158
|
+
|
|
131
159
|
This control parses a text and performs actions to the selected and matching smart nodes
|
|
132
160
|
|
|
133
161
|
### **Features:**
|
|
134
|
-
|
|
135
|
-
|
|
162
|
+
|
|
163
|
+
- Control light and scenes (only on or off) in german and english
|
|
164
|
+
- Control shutter in german and english
|
|
136
165
|
|
|
137
166
|
### Examples
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
167
|
+
|
|
168
|
+
[ text ] is optional
|
|
169
|
+
|
|
170
|
+
- Turn on [the light in] the living room and int 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
|
+
- Sends debug message to output
|
package/compare/compare.js
CHANGED
|
@@ -129,7 +129,7 @@ module.exports = function (RED)
|
|
|
129
129
|
if (result == null)
|
|
130
130
|
node.status({});
|
|
131
131
|
else
|
|
132
|
-
node.status({ fill: "yellow", shape: "ring", text: nodeSettings.values.join(" " + getComparatorSign() + " ") + " => " + result });
|
|
132
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + nodeSettings.values.join(" " + getComparatorSign() + " ") + " => " + result });
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
node.on("close", function ()
|
package/delay/delay.js
CHANGED
|
@@ -22,15 +22,15 @@ module.exports = function (RED)
|
|
|
22
22
|
switch (nodeSettings.lastMessage?.payload)
|
|
23
23
|
{
|
|
24
24
|
case true:
|
|
25
|
-
node.status({ fill: "yellow", shape: "ring", text: "Load last state: On" });
|
|
25
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "Load last state: On" });
|
|
26
26
|
break;
|
|
27
27
|
|
|
28
28
|
case false:
|
|
29
|
-
node.status({ fill: "yellow", shape: "ring", text: "Load last state: Off" });
|
|
29
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "Load last state: Off" });
|
|
30
30
|
break;
|
|
31
31
|
|
|
32
32
|
default:
|
|
33
|
-
node.status({ fill: "yellow", shape: "ring", text: "No last state available" });
|
|
33
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "No last state available" });
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -54,7 +54,7 @@ module.exports = function (RED)
|
|
|
54
54
|
{
|
|
55
55
|
case "set_delay_on":
|
|
56
56
|
nodeSettings.on_delay_ms = helper.getTimeInMsFromString(msg.payload);
|
|
57
|
-
node.status({ fill: "yellow", shape: "ring", text: "New on delay: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
57
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "New on delay: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
58
58
|
|
|
59
59
|
if (config.save_state)
|
|
60
60
|
smartContext.set(node.id, nodeSettings);
|
|
@@ -62,7 +62,7 @@ module.exports = function (RED)
|
|
|
62
62
|
|
|
63
63
|
case "set_delay_off":
|
|
64
64
|
nodeSettings.off_delay_ms = helper.getTimeInMsFromString(msg.payload);
|
|
65
|
-
node.status({ fill: "yellow", shape: "ring", text: "New off delay: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
65
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "New off delay: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
66
66
|
|
|
67
67
|
if (config.save_state)
|
|
68
68
|
smartContext.set(node.id, nodeSettings);
|
|
@@ -71,7 +71,7 @@ module.exports = function (RED)
|
|
|
71
71
|
case "set_delays":
|
|
72
72
|
nodeSettings.on_delay_ms = helper.getTimeInMsFromString(msg.payload);
|
|
73
73
|
nodeSettings.off_delay_ms = nodeSettings.on_delay_ms;
|
|
74
|
-
node.status({ fill: "yellow", shape: "ring", text: "New delays: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
74
|
+
node.status({ fill: "yellow", shape: "ring", text: (new Date()).toLocaleString() + ": " + "New delays: " + helper.formatMsToStatus(nodeSettings.on_delay_ms) });
|
|
75
75
|
|
|
76
76
|
if (config.save_state)
|
|
77
77
|
smartContext.set(node.id, nodeSettings);
|
|
@@ -112,7 +112,7 @@ module.exports = function (RED)
|
|
|
112
112
|
// payload changed back to last value => stop current delay
|
|
113
113
|
if (nodeSettings.lastMessage?.payload == msg.payload)
|
|
114
114
|
{
|
|
115
|
-
node.status({});
|
|
115
|
+
node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Stopped delayed message" });
|
|
116
116
|
clearTimeout(timeout);
|
|
117
117
|
timeout = null;
|
|
118
118
|
|
|
@@ -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({});
|
|
140
|
+
node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + (msg.topic ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") });
|
|
141
141
|
nodeSettings.lastMessage = msg
|
|
142
142
|
|
|
143
143
|
if (config.save_state)
|
|
@@ -148,10 +148,10 @@ module.exports = function (RED)
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// start new timeout
|
|
151
|
-
node.status({ fill: "yellow", shape: "ring", text: "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 ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") + "' in " + helper.formatMsToStatus(delayMs, "at") });
|
|
152
152
|
timeout = setTimeout(() =>
|
|
153
153
|
{
|
|
154
|
-
node.status({});
|
|
154
|
+
node.status({ fill: "yellow", shape: "dot", text: (new Date()).toLocaleString() + ": " + "Sended msg.topic = '" + (msg.topic ?? "null") + "' msg.payload = '" + (msg.payload ?? "null") });
|
|
155
155
|
nodeSettings.lastMessage = msg
|
|
156
156
|
|
|
157
157
|
if (config.save_state)
|
|
@@ -165,7 +165,7 @@ module.exports = function (RED)
|
|
|
165
165
|
{
|
|
166
166
|
setTimeout(() =>
|
|
167
167
|
{
|
|
168
|
-
node.status({});
|
|
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
169
|
node.send(nodeSettings.lastMessage);
|
|
170
170
|
}, 10000);
|
|
171
171
|
}
|