forked from eschava/node-red-contrib-toggle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoggle.html
121 lines (112 loc) · 4.86 KB
/
toggle.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
<script type="text/javascript">
RED.nodes.registerType('toggle',{
category: 'function',
color: '#E2D96E',
defaults: {
name: {value:""},
onOffTopic: {value:""},
onValue: {value:"", validate: RED.validators.typedInput("onType")},
onType: {value:"str"},
offValue: {value:"", validate: RED.validators.typedInput("offType")},
offType: {value:"str"},
offValue: {value:"", validate: RED.validators.typedInput("offType")},
offType: {value:"str"},
toggleTopic: {value:""},
toggleValue: {value:"", validate: RED.validators.typedInput("toggleType")},
toggleType: {value:"str"},
passOnOff: {value: ""},
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-toggle-on",
label: function() {
return this.name || "Toggle";
},
oneditprepare: function() {
$('#node-input-onValue').typedInput({
default: 'str',
typeField: $("#node-input-onType"),
types: ['str', 'num', 'bool']
});
$('#node-input-offValue').typedInput({
default: 'str',
typeField: $("#node-input-offType"),
types: ['str', 'num', 'bool']
});
$('#node-input-toggleValue').typedInput({
default: 'str',
typeField: $("#node-input-toggleType"),
types: [{value: "any", label: "Any except ON/OFF", hasValue: false}, 'str', 'num', 'bool']
});
}
});
</script>
<script type="text/html" data-template-name="toggle">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-onOffTopic"><i class="icon-tag"></i>On/Off topic</label>
<input type="text" id="node-input-onOffTopic" placeholder="<any>">
</div>
<div class="form-row">
<label for="node-input-onValue">ON value</label>
<input type="text" id="node-input-onValue" style="width:70%">
<input type="hidden" id="node-input-onType">
</div>
<div class="form-row">
<label for="node-input-offValue">OFF value</label>
<input type="text" id="node-input-offValue" style="width:70%">
<input type="hidden" id="node-input-offType">
</div>
<div class="form-row">
<label for="node-input-toggleTopic"><i class="icon-tag"></i>Toggle topic</label>
<input type="text" id="node-input-toggleTopic" placeholder="<any>">
</div>
<div class="form-row">
<label for="node-input-toggleValue">Toggle value</label>
<input type="text" id="node-input-toggleValue" style="width:70%">
<input type="hidden" id="node-input-toggleType">
</div>
<div class="form-row">
<label for="node-input-passOnOff">Pass through ON/OFF messages</label>
<select id="node-input-passOnOff">
<option value="">No</option>
<option value="ifChanged">If changed</option>
<option value="always">Always</option>
</select>
</div>
</script>
<script type="text/html" data-help-name="toggle">
<p>Toggle switch node for Node-red</p>
<p>This node could be a companion for any switch (physical or virtual), storing its state and providing "toggle" operation
without need of using function nodes or flow/global variables</p>
<h3>Input</h3>
<dl class="message-properties">
<dt class="message-properties">payload
<span class="property-type">string</span>
</dt>
<dd> initiates execution </dd>
<dt class="message-properties">topic
<span class="property-type">string</span>
</dt>
<dd> <code>msg.topic</code> can be used for control. </dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>The standard output of the node. <code>msg.payload</code> contains the input <code>msg.payload</code> value which was used.</dd>
</dl>
<p>Pass-through</p>
<p>Node has three pass-through modes:</p>
<ul>
<li>"No" - means that node sends a message only when state is toggled. ON/OFF input messages just update internal state of the node.</li>
<li>"If changed" - sends a message for ON/OFF input message only once it differs from the previous state. And obviously message is always sent for "toggle" message.</li>
<li>"Always" - output message is always sent as a reaction on an input message</li>
</ul>
<h3>References</h3>
<ul>
<li><a href="https://github.com/eschava/node-red-contrib-toggle">GitHub</a> - the node github repository</li>
</ul>
</script>