-
Notifications
You must be signed in to change notification settings - Fork 10
/
mytimeout.html
186 lines (156 loc) · 7.01 KB
/
mytimeout.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!--
This software puts out one of several messages on change of state
which could be sent to the MQTT node and can be triggered by
the INJECT module, an mqtt topic or a button on the UI.
Based on Peter Scargill's work on BigTimer
Copyright 2018 Neil Cherry ([email protected] - https://linuxha.com)
Peter Scargill's (https://tech.scargill.net)
-->
<script type="text/x-red" data-template-name="mytimeout">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-outtopic"><i class="fa fa-tag"></i> Output Topic</label>
<input style="width:70%" type="text" id="node-input-outtopic" placeholder="topic">
</div>
<div class="form-row">
<label for="node-input-outsafe"><i class="fa fa-tag"></i> Timer On payload</label>
<input style="width:70%" type="text" id="node-input-outsafe" placeholder="safe">
</div>
<div class="form-row">
<label for="node-input-outwarning"><i class="fa fa-tag"></i> Warning state payload</label>
<input style="width:70%" type="text" id="node-input-outwarning" placeholder="">
</div>
<div class="form-row">
<label for="node-input-outunsafe"><i class="fa fa-tag"></i> Timer Off payload</label>
<input style="width:70%" type="text" id="node-input-outunsafe" placeholder="unsafe">
</div>
<div class="form-row">
<label for="node-input-timer"><i class="fa fa-clock-o"></i> Countdown (secs)</label>
<input style="width:15%" type="text" id="node-input-timer" placeholder="30">
</div>
<div class="form-row">
<label for="node-input-warning"><i class="fa fa-clock-o"></i> Warning (secs)</label>
<input style="width:15%" type="text" id="node-input-warning" placeholder="10">
</div>
<div class="form-row">
<span style="width: 350px; float: left; margin-left: 5px;"><input type="checkbox" id="node-input-ndebug" placeholder="debug" > Debug logging</span>
<br/><br/>
<span style="width: 350px; float: left; margin-left: 5px;"><input type="checkbox" id="node-input-ignoreCase" placeholder="ignoreCase" > Ignore input case</span>
</div>
<!--
<div class="form-row">
<label for="node-input-debug"><i class="fa fa-clock-o"></i>Debug logging</label>
<input style="width:15%" type="text" id="node-input-debug" placeholder="0">
</div>
<!--
<div>
<span style="width: 350px; float: left; margin-left: 5px;"><input type="checkbox" id="node-input-repeat" placeholder="repeat" > Repeat message every second</span>
<br/><br/>
</div>
<div>
<span style="width: 350px; float: left; margin-left: 5px;"><input type="checkbox" id="node-input-again" placeholder="again" > Auto-restart when timed out</span>
<br/><br/>
</div>
<div>
<span style="width: 350px; float: left; margin-left: 5px;"><input type="checkbox" id="node-input-atStart" placeholder="atStart" > Run at start</span>
<br/><br/>
</div>
-->
</script>
<script type="text/x-red" data-help-name="mytimeout">
<h3>myTimeout</h3>
<p> A simple timeout node, "on" starts the timer and sends out the
"Timer on payload" (on) message. Every additional "on" will
send an additional "Timer on payload" message on output 1. If
the counter counts down to the warning level it outputs the
WARNING message. If the timer is allowed to count down to 0 -
the UNSAFE (off) message is sent out.</p>
<p> An empty WARNING message in the node's properties will allow
you to skip sending the warning message. As will setting the
warning seconds to 0.</p>
<h3>Acceptable input</h3>
<p> The normal input msg.payload can contain an "on" or "1" for
the Timer On payload, For the Timer Off payload an "off" or
"0", a payload of "stop" will stop the time and output a
"stop" message, a payload of "cancel" will cancel the timer
with no additional messages on output 1. </p>
<ul>
<li>on or 1 (case insensitive)</li>
<li>off or 0</li>
<li>stop</li>
<li>cancel</li>
<li>Any junk will be considered an on condition (a kicker if you will)</li>
<li>JSON in the msg.payload (see below)</li>
</ul>
<p> <b>Please note:</b> The countdown and warning values must be
whole, integer numbers. Using floating point numbers can cause
the timer to not send the appropriate off state payload.</p>
<h3>JSON input</h3>
<p> You can override the user's default settings by send a JSON
packet with a payload, timeout and warning (in seconds).</p>
<pre><code>{
"payload": "on",
"timeout": 600,
"warning": 30
}
or
{
"payload": "off"
}
or
{
"payload": "stop"
}
or
{
"payload": "cancel"
}</code></pre>
<p> <b>Please note:</b> The timeout and warning values must be
whole, integer numbers. Using floating point numbers can cause
the timer to not send the appropriate off state payload.</p>
<ul>
<li>on - turns on the timer and runs for timeout and warns at warning (all 3 fields are required) and sends an on as the msg.payload</li>
<li>1 - turns on the timer and runs for timeout and warns at warning (all 3 fields are required) and sends an on as the msg.payload</li>
<li>off - immediately turns off the timer and sends an off as the msg.payload</li>
<li>0 - immediately turns off the timer and sends an off as the msg.payload</li>
<li>stop - immediately turns off the timer and sends an stop as the msg.payload (which is not an off)</li>
<li>cancel - immediately turns off the timer and sends nothing</li>
<li>JSON payload - (see above)</li>
<li>anything else - is treated as an on command allowing us to tickle or kick the timer (keep it on)</li>
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('mytimeout',{
category: 'cherry',
color:"#ff66cc",
inputLabels: "Any old input resets the timer",
outputLabels: "Output message depends on state",
defaults: {
name: { value: "" },
outtopic: { value: "" },
outsafe: { value: "on" }, /* Default new 20200114 */
outwarning: { value: "Warning" }, /* */
outunsafe: { value: "off", required: true }, /* Default */
warning: { value: "5" }, /* */
timer: { value: "30" }, /* */
debug: { value: false },
ndebug: { value: false },
ignoreCase: { value: false },
repeat: { value: false },
again: { value: false }
},
inputs: 1,
outputs: 2,
icon: "stopwatch.png",
label: function() {
return this.name||"mytimeout";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {}
});
</script>