forked from thetonto/node-red-contrib-sensibo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensibo.html
273 lines (241 loc) · 11.8 KB
/
sensibo.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<script type="text/javascript">
(function() {
RED.nodes.registerType('sensibo-config',{
category: 'config',
defaults: {
senAPI: {value:""}
},
label: function() { return this.senAPI; }
});
})();
</script>
<script type="text/x-red" data-template-name="sensibo-config">
<div id="node-config-sensibo-api">
<div class="form-row">
<p style="margin-top: 10px;"><b>1.</b> <span data-i18n="sensibo.label.register"></span> <a href="https://home.sensibo.com" target="_blank" style="text-decoration:underline;">Sensibo</a>.</p>
</div>
<div class="form-row">
<p style="margin-top: 10px;"><b>2.</b> <span data-i18n="sensibo.label.copy"></span>:</p>
</div>
<div class="form-row">
<label style="margin-left: 10px; margin-right: -10px;" for="node-config-input-senAPI"><i class="fa fa-key"></i> <span data-i18n="sensibo.label.key"></span></label>
<input type="text" id="node-config-input-senAPI">
</div>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sensibo in',{
category: 'home automation',
color: '#C0DEED',
defaults: {
sensiboAPI: {type:"sensibo-config", required:true},
name: {value:""},
pod: {value:""},
getconfig: {value: ""},
getACState: {value: ''},
polltime: {value:"0", validate:function checkvalid(v){
//check value is either 0, or greater than 60s. Sure there is compressed way of doing this but it works and is clear to read
if (v == 0){return true;}
else if (v >=60){return true}
else {return false}}}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-snowflake-o",
label: function() {
return this.name||"sensibo"
},
oneditprepare: function() {
//Add Pods from the lookup
$("#node-lookup-pod").click(function() {
$("#node-lookup-pod").addClass('disabled');
$.getJSON('sensibo?lkup=node',function(data) {
$("#node-lookup-pod").removeClass('disabled');
$("#node-input-pod").autocomplete({
source:data,
minLength:0,
close: function( event, ui ) {
$("#node-input-pod").autocomplete( "destroy" );
}
}).autocomplete("search","");
});
});
//Hide the polling option if get config is selected.
$('#node-input-getconfig').change(function(){
if(this.checked){
$('.setstate').hide()
$('#node-input-getACState').prop('checked', false)
$('#node-input-polltime').val('0')
}
else
{$('.setstate').show()}
});
$('#node-input-getACState').change(function(){
if (this.checked) {
//alert("that worked")
$('.setpoll').hide()
} else { $('.setpoll').show() }
})
},
oneditsave: function(){
//set the pod to just the ID number off the friendly name
//this.pod = $("#node-input-podSelector").find('option:selected').val();
}
});
</script>
<script type="text/x-red" data-template-name="sensibo in">
<div class="form-row">
<label for="node-input-sensiboAPI"><span data-i18n="sensibo.label.key"></span></label>
<input type="text" id="node-input-sensiboAPI">
</div>
<div class="form-row">
<label for="node-input-pod"><i class="fa fa-superpowers"></i> <span data-i18n="sensibo.label.podname"></span></label>
<input type="text" id="node-input-pod" style="width:60%;">
<a id="node-lookup-pod" class="btn"><i id="node-lookup-pod-icon" class="fa fa-search"></i></a>
</div>
<div class="form-row"> <label for="node-input-getconfig"><i class="fa fa-briefcase"></i> Get Config</label>
<input id="node-input-getconfig" name="Get Config" type="checkbox"></div>
<div class="form-row setstate"> <label for="node-input-getACState"><i class="fa fa-cogs"></i> Get AC State</label>
<input id="node-input-getACState" name="Get AC State" type="checkbox"></div>
<div class="form-row setstate setpoll"> <label for="node-input-polltime"> Polling time</label>
<input id="node-input-polltime" placeholder="seconds" type="text"></div>
<div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i>
Name</label> <input id="node-input-name" placeholder="Name" type="text">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sensibo send',{
category: 'home automation',
color: '#C0DEED',
defaults: {
sensiboAPI: {type:"sensibo-config", required:true},
name: {value:""},
pod: {value:""},
podSelector: {value:""},
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-snowflake-o",
label: function() {
return this.name||"sensibo out"
},
oneditprepare: function() {
//Add Pods from the lookup
$("#node-lookup-pod").click(function() {
$("#node-lookup-pod").addClass('disabled');
$.getJSON('sensibo?lkup=node',function(data) {
$("#node-lookup-pod").removeClass('disabled');
$("#node-input-pod").autocomplete({
source:data,
minLength:0,
close: function( event, ui ) {
$("#node-input-pod").autocomplete( "destroy" );
//alert("finished - should now get the configuration")
}
}).autocomplete("search","");
});
});
},
oneditsave: function(){
//set the pod to just the ID number off the friendly name
//this.pod = $("#node-input-podSelector").find('option:selected').val();
}
});
</script>
<script type="text/x-red" data-template-name="sensibo send">
<div class="form-row">
<label for="node-input-sensiboAPI">API Configuration</label>
<input type="text" id="node-input-sensiboAPI">
</div>
<div class="form-row">
<label for="node-input-pod"><i class="fa fa-superpowers"></i> <span data-i18n="sensibo.label.podname"></span></label>
<input type="text" id="node-input-pod" style="width:60%;">
<a id="node-lookup-pod" class="btn"><i id="node-lookup-pod-icon" class="fa fa-search"></i></a>
</div>
<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>
</script>
<script type="text/x-red" data-help-name="sensibo in">
<p>Connects to Sensibo cloud for temp/humidity/time measurements for the selected pod</p>
<h3>Configuration</h3>
<p>An API needs to be obtained from Sensibo</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>pod <span class="property-type">string</span></dt>
<dd>The pod to get the measurements from. Click on magnifying glass to get list of available pods from sensibo. This may take a moment to resolve from the server</dd>
<dt>Get config only<span class="property-type">boolean</span></dt>
<dd>If selected the node will get the properties of the node. Polling or get AC State will be not be available. Useful to find out the various modes that your unit supports</dd>
<dt>Get AC State<span class="property-type">boolean</span></dt>
<dd>If selected the node will get the AC State only. The get config option will return the AC State as well, however it contains a lot of other data so this option is more efficient if you just want the current AC State</dd>
<dt>polling time <span class="property-type">string</span></dt>
<dd>How often in seconds to poll the cloud. 0 = no polling and if set a minimum of 60 seconds</dd>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string | buffer</span>
</dt>
<dd> Currently any payload will trigger a lookup of the measurements for the requested pod </dd>
<dt class="optional">topic <span class="property-type">string</span></dt>
<dd> Currently topic has no impact on the node.</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>Status of lookup request to Sensibo</dd>
<dt>payload.x <span class="property-type">string</span></dt>
<dd>Measurement values as returned from Sensibo. Tip: turn on full object in the debug node to see all the values returned</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>Will return the error received from the Sensibo server</dd>
</dl>
</li>
</ol>
</script>
<script type="text/x-red" data-help-name="sensibo send">
<p>Connects to Sensibo cloud and sends updates for the selected pod</p>
<h3>Configuration</h3>
<p>An API needs to be obtained from Sensibo</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>pod <span class="property-type">selector</span></dt>
<dd>The pod to get the measurements from. Click on magnifying glass to get list of available pods from sensibo. This may take a moment to resolve from the server</dd>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string | buffer</span>
</dt>
<dd> Payload is not currently assigned to a function</dd>
<dt class="optional">msg.on<span class="property-type">string/binary</span></dt>
<dd> Turn the air conditioning unit on and off. true/false. Bug fixed so both types will accepted</dd>
<dt class="optional">msg.swing<span class="property-type">string</span></dt>
<dd> Sets the swing mode.</dd>
<dt class="optional">msg.mode<span class="property-type">string</span></dt>
<dd> Set the operating mode: cool/heat/fan/dry/auto'</dd>
<dt class="optional">msg.fanlevel<span class="property-type">string</span></dt>
<dd> Set the fan level: quiet/low/medium low/medium/medium high/high/auto. Note: medium high/low may not be supported on all units</dd>
<dt class="optional">msg.targetTemperature<span class="property-type">number</span></dt>
<dd> Sets the target temperature to reach.'</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>Status of the request to Sensibo</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>Will return the error received from the Sensibo server</dd>
</dl>
</li>
</ol>
</script>