homebridge-cmd4 6.0.0 → 6.0.4
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 +30 -0
- package/Cmd4Accessory.js +115 -143
- package/Cmd4Platform.js +19 -0
- package/RUNNING_CHANGELOG.md +36 -0
- package/docs/Developers.md +1 -1
- package/package.json +2 -2
- package/homebridge-ui/public/index.html.1 +0 -248
- package/homebridge-ui/public/index.html.2 +0 -257
- package/homebridge-ui/public/index.html.3 +0 -265
- package/homebridge-ui/public/index.html.3.1 +0 -244
- package/homebridge-ui/public/index.html.wemo.1 +0 -194
- package/homebridge-ui/public/index.html.wemo.2 +0 -339
- package/homebridge-ui/public/js/main.js.1 +0 -583
- package/homebridge-ui/public/js/main.js.2 +0 -583
- package/homebridge-ui/public/js/main.js.3 +0 -583
- package/homebridge-ui/public/js/schema.js.save +0 -196
- package/homebridge-ui/public/js/wmain.js.1 +0 -152
- package/homebridge-ui/public/js/wmain.js.2 +0 -161
- package/homebridge-ui/server.js.1 +0 -281
- package/homebridge-ui/server.js.2 +0 -281
- package/homebridge-ui/server.js.3 +0 -281
- package/homebridge-ui/server.js.wemo.1 +0 -78
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
/*global $, window, location, homebridge, schema*/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const GLOBAL =
|
|
6
|
-
{
|
|
7
|
-
pluginConfig: false,
|
|
8
|
-
customSchema: false,
|
|
9
|
-
accessoryOptions: false
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
async function createCustomSchema( accessory )
|
|
14
|
-
{
|
|
15
|
-
console.log( "In CreateCustomSchema for:%s %s", accessory.name, accessory.displayName );
|
|
16
|
-
console.log( "In CreateCustomSchema accessory:%s", accessory );
|
|
17
|
-
//let settings = await homebridge.request( "/cmd4StaticVariable", "settings" );
|
|
18
|
-
|
|
19
|
-
GLOBAL.accessorySchema =
|
|
20
|
-
{
|
|
21
|
-
name: accessory.name,
|
|
22
|
-
displayName: accessory.displayName,
|
|
23
|
-
accessoryCharacteristics: accessory.characteristics,
|
|
24
|
-
polling: accessory.polling,
|
|
25
|
-
timeout: accessory.timeout,
|
|
26
|
-
queue: accessory.queue,
|
|
27
|
-
stateChangeResponseTime: accessory.stateChangeResponseTime,
|
|
28
|
-
stateCmdPrefix: accessory.stateCmdPrefix,
|
|
29
|
-
stateCmd: accessory.stateCmd,
|
|
30
|
-
stateCmdSuffix: accessory.stateCmdSuffix
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
GLOBAL.customSchema = homebridge.createForm( schema,
|
|
34
|
-
{
|
|
35
|
-
name: GLOBAL.pluginConfig[0].name,
|
|
36
|
-
debug: GLOBAL.pluginConfig[0].debug,
|
|
37
|
-
outputConstants: GLOBAL.pluginConfig[0].outputConstants,
|
|
38
|
-
statusMsg: GLOBAL.pluginConfig[0].statusMsg,
|
|
39
|
-
timeout: GLOBAL.pluginConfig[0].timeout,
|
|
40
|
-
stateChangeResponseTime: GLOBAL.pluginConfig[0].stateChangeResponseTime,
|
|
41
|
-
accessories: [],
|
|
42
|
-
accessories: accessory
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
GLOBAL.customSchema.onChange( async config =>
|
|
46
|
-
{
|
|
47
|
-
console.log( "In customSchema.onChange config:%s %s", config );
|
|
48
|
-
//let settings = await homebridge.request( "/cmd4StaticVariable", "settings" );
|
|
49
|
-
|
|
50
|
-
GLOBAL.pluginConfig[0].name = config.name;
|
|
51
|
-
GLOBAL.pluginConfig[0].debug = config.debug;
|
|
52
|
-
GLOBAL.pluginConfig[0].outputConstants = config.outputConstants;
|
|
53
|
-
GLOBAL.pluginConfig[0].statusMsg = config.statusMsg;
|
|
54
|
-
GLOBAL.pluginConfig[0].timeout = config.timeout;
|
|
55
|
-
GLOBAL.pluginConfig[0].stateChangeResponseTime = config.stateChangeResponseTime;
|
|
56
|
-
GLOBAL.pluginConfig[0].accessories = GLOBAL.pluginConfig[0].accessories.map( accessory =>
|
|
57
|
-
{
|
|
58
|
-
if ( accessory.name === config.accessories.name )
|
|
59
|
-
{
|
|
60
|
-
accessory = config.accessories;
|
|
61
|
-
}
|
|
62
|
-
return accessory;
|
|
63
|
-
} );
|
|
64
|
-
|
|
65
|
-
try
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
await homebridge.updatePluginConfig( GLOBAL.pluginConfig );
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
catch( err )
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
homebridge.toast.error( err.message, 'Error' );
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
} );
|
|
79
|
-
|
|
80
|
-
return;
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// This shows below the edit accessory. Not what I want
|
|
85
|
-
async function createCustomSchema( accessory )
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
GLOBAL.accessoryOptions = {
|
|
89
|
-
name: accessory.name,
|
|
90
|
-
displayName: accessory.displayName,
|
|
91
|
-
polling: accessory.polling,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
GLOBAL.customSchema = homebridge.createForm(schema, {
|
|
95
|
-
name: GLOBAL.pluginConfig[0].name,
|
|
96
|
-
debug: GLOBAL.pluginConfig[0].debug,
|
|
97
|
-
accessories: accessory
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
GLOBAL.customSchema.onChange(async config =>
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
GLOBAL.pluginConfig[0].name = config.name;
|
|
104
|
-
GLOBAL.pluginConfig[0].debug = config.debug;
|
|
105
|
-
GLOBAL.pluginConfig[0].accessories = GLOBAL.pluginConfig[0].accessories.map(accessory =>
|
|
106
|
-
{
|
|
107
|
-
if ( accessory.displayName === config.accessory.displayName &&
|
|
108
|
-
accessory.name === config.accessory.name )
|
|
109
|
-
{
|
|
110
|
-
accessory = config.accessory;
|
|
111
|
-
}
|
|
112
|
-
return accessory;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
|
|
117
|
-
await homebridge.updatePluginConfig(GLOBAL.pluginConfig);
|
|
118
|
-
|
|
119
|
-
} catch(err) {
|
|
120
|
-
|
|
121
|
-
homebridge.toast.error(err.message, 'Error');
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return;
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function resetUI( )
|
|
132
|
-
{
|
|
133
|
-
console.log( "In resetUI" );
|
|
134
|
-
|
|
135
|
-
resetForm( );
|
|
136
|
-
resetSchema( );
|
|
137
|
-
|
|
138
|
-
return;
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function resetForm( )
|
|
143
|
-
{
|
|
144
|
-
console.log( "In resetForm" );
|
|
145
|
-
|
|
146
|
-
$( '#accessoryName' ).val( '' );
|
|
147
|
-
$( '#accessoryCharacteristics' ).val( '' );
|
|
148
|
-
$( '#accessoryPolling' ).val( '' );
|
|
149
|
-
$( '#authCode' ).val( '' );
|
|
150
|
-
$( '#authToken' ).val( '' );
|
|
151
|
-
$( '#authRefreshToken' ).val( '' );
|
|
152
|
-
$( '#authTokenType' ).val( '' );
|
|
153
|
-
$( '#authExpiresIn' ).val( '' );
|
|
154
|
-
$( '#authExpiresAt' ).val( '' );
|
|
155
|
-
|
|
156
|
-
$( '#codeInput' ).hide( );
|
|
157
|
-
$( '#tokenInput' ).hide( );
|
|
158
|
-
|
|
159
|
-
GLOBAL.accessorySchema = false;
|
|
160
|
-
|
|
161
|
-
return;
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function resetSchema( )
|
|
166
|
-
{
|
|
167
|
-
console.log( "In resetSchema" );
|
|
168
|
-
|
|
169
|
-
if ( GLOBAL.customSchema )
|
|
170
|
-
{
|
|
171
|
-
GLOBAL.customSchema.end( );
|
|
172
|
-
GLOBAL.customSchema = false;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return;
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function addAccessoryToList( accessory )
|
|
180
|
-
{
|
|
181
|
-
console.log( "In addAccessoryToList accessory.displayName:%s", accessory.displayName );
|
|
182
|
-
|
|
183
|
-
let name = typeof accessory === 'string' ? accessory : accessory.name;
|
|
184
|
-
$( '#accessorySelect' ).append( '<option value="' + name + '">'+ name + '</option>' );
|
|
185
|
-
|
|
186
|
-
return;
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function removeAccessoryFromList( accessory )
|
|
191
|
-
{
|
|
192
|
-
console.log( "In removeAccessoryToList accessory.displayName:%s", accessory.displayName );
|
|
193
|
-
|
|
194
|
-
let name = typeof accessory === 'string' ? accessory : accessory.name;
|
|
195
|
-
$( '#accessorySelect option[value=\'' + name + '\']' ).remove( );
|
|
196
|
-
|
|
197
|
-
return;
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async function addNewDeviceToConfig( accessory )
|
|
202
|
-
{
|
|
203
|
-
console.log( "In addNewDeviceToConfig for:%s %s", accessory.name, accessory.displayName );
|
|
204
|
-
|
|
205
|
-
let found = false;
|
|
206
|
-
|
|
207
|
-
try
|
|
208
|
-
{
|
|
209
|
-
const config =
|
|
210
|
-
{
|
|
211
|
-
name: accessory.name,
|
|
212
|
-
accessoryCharacteristics: accessory.characteristics,
|
|
213
|
-
polling: accessory.polling,
|
|
214
|
-
electricVehicle: false,
|
|
215
|
-
tankBatteryType: 'HUMIDITY',
|
|
216
|
-
token:
|
|
217
|
-
{
|
|
218
|
-
access_token: accessory.token.access_token,
|
|
219
|
-
refresh_token: accessory.token.refresh_token,
|
|
220
|
-
token_type: accessory.token.token_type,
|
|
221
|
-
expires_in: accessory.token.expires_in,
|
|
222
|
-
expires_at: accessory.token.expires_at
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
for( const acc in GLOBAL.pluginConfig[0].accessories )
|
|
227
|
-
{
|
|
228
|
-
if ( GLOBAL.pluginConfig[ 0 ].accessories[ acc ].name === accessory.name )
|
|
229
|
-
{
|
|
230
|
-
found = true;
|
|
231
|
-
GLOBAL.pluginConfig[ 0 ].accessories[ acc ].token =
|
|
232
|
-
{
|
|
233
|
-
access_token: accessory.token.access_token,
|
|
234
|
-
refresh_token: accessory.token.refresh_token,
|
|
235
|
-
token_type: accessory.token.token_type,
|
|
236
|
-
expires_in: accessory.token.expires_in,
|
|
237
|
-
expires_at: accessory.token.expires_at
|
|
238
|
-
};
|
|
239
|
-
homebridge.toast.success( accessory.name + ' refreshed!', 'Success' );
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if ( !found )
|
|
244
|
-
{
|
|
245
|
-
|
|
246
|
-
GLOBAL.pluginConfig[0].accessories.push( config );
|
|
247
|
-
addAccessoryToList( config );
|
|
248
|
-
|
|
249
|
-
homebridge.toast.success( config.name + ' added to config!', 'Success' );
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
await homebridge.updatePluginConfig( GLOBAL.pluginConfig );
|
|
254
|
-
await homebridge.savePluginConfig( );
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
catch( err )
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
homebridge.toast.error( err.message, 'Error' );
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return;
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
async function removeDeviceFromConfig( )
|
|
269
|
-
{
|
|
270
|
-
|
|
271
|
-
let foundIndex;
|
|
272
|
-
let pluginConfigBkp = GLOBAL.pluginConfig;
|
|
273
|
-
let selectedAccessory = $( '#accessorySelect option:selected' ).text( );
|
|
274
|
-
|
|
275
|
-
GLOBAL.pluginConfig[0].accessories.forEach( ( accessory, index ) =>
|
|
276
|
-
{
|
|
277
|
-
if ( accessory.name === selectedAccessory )
|
|
278
|
-
{
|
|
279
|
-
foundIndex = index;
|
|
280
|
-
}
|
|
281
|
-
} );
|
|
282
|
-
|
|
283
|
-
if ( foundIndex !== undefined )
|
|
284
|
-
{
|
|
285
|
-
|
|
286
|
-
try
|
|
287
|
-
{
|
|
288
|
-
|
|
289
|
-
GLOBAL.pluginConfig[0].accessories.splice( foundIndex, 1 );
|
|
290
|
-
|
|
291
|
-
await homebridge.updatePluginConfig( GLOBAL.pluginConfig );
|
|
292
|
-
await homebridge.savePluginConfig( );
|
|
293
|
-
|
|
294
|
-
removeAccessoryFromList( selectedAccessory );
|
|
295
|
-
|
|
296
|
-
homebridge.toast.success( selectedAccessory + ' removed from config!', 'Success' );
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
catch( err )
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
GLOBAL.pluginConfig = pluginConfigBkp;
|
|
303
|
-
|
|
304
|
-
throw err;
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
else
|
|
310
|
-
{
|
|
311
|
-
|
|
312
|
-
throw new Error( 'No accessory found in config to remove!' );
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return;
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
async function startButtonPressed( )
|
|
322
|
-
{
|
|
323
|
-
let pluginConfig = await homebridge.getPluginConfig( );
|
|
324
|
-
GLOBAL.pluginConfig = pluginConfig;
|
|
325
|
-
console.log("got pluginConfig start sending start");
|
|
326
|
-
|
|
327
|
-
homebridge.request( "/startButtonPressed", pluginConfig );
|
|
328
|
-
}
|
|
329
|
-
async function backButtonPressed( )
|
|
330
|
-
{
|
|
331
|
-
console.log("main.js async function back sending back");
|
|
332
|
-
homebridge.request( "/backButtonPressed" );
|
|
333
|
-
}
|
|
334
|
-
async function showConfigureGlobalsPageButtonPressed( )
|
|
335
|
-
{
|
|
336
|
-
console.log("main.js async function globals sending globals");
|
|
337
|
-
homebridge.request( "/showConfigureGlobalsPage" );
|
|
338
|
-
}
|
|
339
|
-
async function showQueueGlobalsPageButtonPressed( )
|
|
340
|
-
{
|
|
341
|
-
console.log("main.js async function globals sending globals");
|
|
342
|
-
homebridge.request( "/showQueueGlobalsPage" );
|
|
343
|
-
}
|
|
344
|
-
async function deleteQueueButtonPressed( value )
|
|
345
|
-
{
|
|
346
|
-
console.log("main.js async function deleteQueueButtonPressed :%s", value);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// STARTUP CODE
|
|
350
|
-
( async ( ) =>
|
|
351
|
-
{
|
|
352
|
-
|
|
353
|
-
try
|
|
354
|
-
{
|
|
355
|
-
// PAGE SWITCH EVENT
|
|
356
|
-
homebridge.addEventListener('my-pageEvent', (event) =>
|
|
357
|
-
{
|
|
358
|
-
console.log("In Main.js server.js told me from:%s to:%s", event.data.from, event.data.to);
|
|
359
|
-
|
|
360
|
-
$( event.data.from ).hide( );
|
|
361
|
-
$( event.data.to ).show( );
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
// UPDATE accessoryTypeSelect
|
|
365
|
-
let select = document.getElementById( "accessoryTypeSelect" );
|
|
366
|
-
console.log("main.js select=%s", select);
|
|
367
|
-
|
|
368
|
-
console.log( "In Cmd4.js select" );
|
|
369
|
-
let CMD4_DEVICE_TYPE_ENUM = await homebridge.request( "/cmd4StaticVariable", "CMD4_DEVICE_TYPE_ENUM" );
|
|
370
|
-
Object.keys( CMD4_DEVICE_TYPE_ENUM.properties ).forEach( key => {
|
|
371
|
-
let defaultSelection = false;
|
|
372
|
-
if ( key == CMD4_DEVICE_TYPE_ENUM.Switch )
|
|
373
|
-
{
|
|
374
|
-
console.log( " Setting default selection to true at: %s", key );
|
|
375
|
-
defaultSelection = true;
|
|
376
|
-
}
|
|
377
|
-
//console.log( "In Cmd4.js select appending %s", CMD4_DEVICE_TYPE_ENUM.properties[key].deviceName );
|
|
378
|
-
select.appendChild( new Option( CMD4_DEVICE_TYPE_ENUM.properties[key].deviceName, CMD4_DEVICE_TYPE_ENUM.properties[key].deviceName, defaultSelection, defaultSelection ) );
|
|
379
|
-
} );
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
GLOBAL.pluginConfig = await homebridge.getPluginConfig( );
|
|
383
|
-
//GLOBAL.pluginConfig.forEach( ( elem, index ) =>
|
|
384
|
-
//{
|
|
385
|
-
//console.log( "GLOBAL.pluginConfig[ %s ] returned by homebridge: %s", index, elem );
|
|
386
|
-
//} );
|
|
387
|
-
|
|
388
|
-
if ( !GLOBAL.pluginConfig.length )
|
|
389
|
-
{
|
|
390
|
-
let settings = await homebridge.request( '/cmd4StaticVariable', "settings" );
|
|
391
|
-
|
|
392
|
-
GLOBAL.pluginConfig = [
|
|
393
|
-
{
|
|
394
|
-
platform: settings.PLATFORM_NAME,
|
|
395
|
-
name: settings.PLATFORM_NAME,
|
|
396
|
-
debug: false,
|
|
397
|
-
outputConstants: settings.DEFAULT_OUTPUTCONSTANTS,
|
|
398
|
-
statusMsg: settings.DEFAULT_STATUSMSG,
|
|
399
|
-
timeout: settings.DEFAULT_TIMEOUT,
|
|
400
|
-
stateChangeResponseTime: settings.DEFAULT_STATE_CHANGE_RESPONSE_TIME,
|
|
401
|
-
accessories: []
|
|
402
|
-
}];
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
else
|
|
406
|
-
{
|
|
407
|
-
|
|
408
|
-
if ( !GLOBAL.pluginConfig[0].accessories || ( GLOBAL.pluginConfig[0].accessories && !GLOBAL.pluginConfig[0].accessories.length ) )
|
|
409
|
-
{
|
|
410
|
-
GLOBAL.pluginConfig[0].accessories = [];
|
|
411
|
-
// return transPage( false, $( '#notConfigured' ) );
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
GLOBAL.pluginConfig[0].accessories.forEach( accessory =>
|
|
415
|
-
{
|
|
416
|
-
$( '#accessorySelect' ).append( '<option value="' + accessory.name + '">'+ accessory.name + '</option>' );
|
|
417
|
-
} );
|
|
418
|
-
console.log("GLOBAL.pluginConfig[0]=%s", GLOBAL.pluginConfig[0] );
|
|
419
|
-
console.log("GLOBAL.pluginConfig[0].queueTypes=%s", GLOBAL.pluginConfig[0].queueTypes );
|
|
420
|
-
|
|
421
|
-
if ( GLOBAL.pluginConfig[0].queueTypes )
|
|
422
|
-
{
|
|
423
|
-
$( "#globalQueueMessage" ).hide( );
|
|
424
|
-
$( "#globalQueueContainer" ).show( );
|
|
425
|
-
//document.getElementById("globalQueueMessage").style.visibility = "hidden";
|
|
426
|
-
|
|
427
|
-
GLOBAL.pluginConfig[0].queueTypes.forEach( entry =>
|
|
428
|
-
{
|
|
429
|
-
console.log("Adding queue: %s", entry.queue );
|
|
430
|
-
$( '#globalQueuesForm' ).append(
|
|
431
|
-
'<div class="row no-gutters">' +
|
|
432
|
-
'<div class="col">' +
|
|
433
|
-
'<div class="card card-body">' +
|
|
434
|
-
'<button type="submit" class="btn btn-primary p-0 mt-0 mb-0 deleteQueueButton" value="' + entry.queue +'">' +
|
|
435
|
-
'<i class="fa fa-trash" aria-hidden="true"></i>' +
|
|
436
|
-
'</button>' +
|
|
437
|
-
'</div>' +
|
|
438
|
-
'</div>' +
|
|
439
|
-
'<div class="col">' +
|
|
440
|
-
'<div class="card card-body">' + entry.queue + '</div>' +
|
|
441
|
-
'</div>' +
|
|
442
|
-
'<div class="col">' +
|
|
443
|
-
'<div class="card card-body">' + entry.queueType + '</div>' +
|
|
444
|
-
'</div>' +
|
|
445
|
-
'</div>'
|
|
446
|
-
);
|
|
447
|
-
});
|
|
448
|
-
} else {
|
|
449
|
-
$( "#globalQueueMessage" ).show( );
|
|
450
|
-
$( "#globalQueueContainer" ).hide( );
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
catch( err )
|
|
455
|
-
{
|
|
456
|
-
|
|
457
|
-
homebridge.toast.error( err.message, 'Error' );
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
} )( );
|
|
462
|
-
|
|
463
|
-
//jquery listener
|
|
464
|
-
|
|
465
|
-
$( '.backButton' ).on( 'click', ( ) =>
|
|
466
|
-
{
|
|
467
|
-
console.log(" main.js click .back");
|
|
468
|
-
backButtonPressed();
|
|
469
|
-
} );
|
|
470
|
-
|
|
471
|
-
$( '#startButton' ).on( 'click', ( ) =>
|
|
472
|
-
{
|
|
473
|
-
console.log("Click startButton");
|
|
474
|
-
startButtonPressed();
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
$( '.showConfigureGlobalsPageButton' ).on( 'click', ( ) =>
|
|
478
|
-
{
|
|
479
|
-
console.log("Click showConfigureGlobalsPageButton");
|
|
480
|
-
showConfigureGlobalsPageButtonPressed();
|
|
481
|
-
} );
|
|
482
|
-
|
|
483
|
-
$( '.showQueueGlobalsPageButton' ).on( 'click', ( ) =>
|
|
484
|
-
{
|
|
485
|
-
console.log("Click showQueueGlobalsPageButton");
|
|
486
|
-
showQueueGlobalsPageButtonPressed();
|
|
487
|
-
} );
|
|
488
|
-
|
|
489
|
-
$( '.configureNewQueuePageButton' ).on( 'click', ( ) =>
|
|
490
|
-
{
|
|
491
|
-
console.log("Click configureNewQueuePageButton");
|
|
492
|
-
configureNewQueuePageButtonPressed();
|
|
493
|
-
} );
|
|
494
|
-
|
|
495
|
-
$( '.deleteQueueButton' ).on( 'click', ( value ) =>
|
|
496
|
-
{
|
|
497
|
-
console.log("Click configureNewQueuePageButton value:%s", value );
|
|
498
|
-
deleteQueueButtonPressed( value);
|
|
499
|
-
} );
|
|
500
|
-
|
|
501
|
-
async function populateSelect( )
|
|
502
|
-
{
|
|
503
|
-
let select = document.getElementById( "accessoryType" );
|
|
504
|
-
|
|
505
|
-
console.log( "In Cmd4.js select" );
|
|
506
|
-
let CMD4_DEVICE_TYPE_ENUM = await homebridge.request( "/cmd4StaticVariable", "CMD4_DEVICE_TYPE_ENUM" );
|
|
507
|
-
Object.keys( CMD4_DEVICE_TYPE_ENUM.properties ).forEach( key => {
|
|
508
|
-
let defaultSelection = false;
|
|
509
|
-
if ( key == CMD4_DEVICE_TYPE_ENUM.Switch )
|
|
510
|
-
{
|
|
511
|
-
console.log( " Setting default selection to true at: %s", key );
|
|
512
|
-
defaultSelection = true;
|
|
513
|
-
}
|
|
514
|
-
select.appendChild( new Option( CMD4_DEVICE_TYPE_ENUM.properties[key].deviceName, CMD4_DEVICE_TYPE_ENUM.properties[key].deviceName, defaultSelection, defaultSelection ) );
|
|
515
|
-
} );
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
$( '#addAccessory, #Xstart' ).on( 'click', ( ) =>
|
|
519
|
-
{
|
|
520
|
-
|
|
521
|
-
resetUI( );
|
|
522
|
-
|
|
523
|
-
populateSelect( );
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
//let activeContent = $( '#notConfigured' ).css( 'display' ) !== 'none' ? $( '#notConfigured' ) : $( '#isConfigured' );
|
|
527
|
-
|
|
528
|
-
} );
|
|
529
|
-
|
|
530
|
-
$( '#editAccessory' ).on( 'click', ( ) =>
|
|
531
|
-
{
|
|
532
|
-
|
|
533
|
-
resetUI( );
|
|
534
|
-
|
|
535
|
-
let selectedAccessory = $( '#accessorySelect option:selected' ).text( );
|
|
536
|
-
let accessory = GLOBAL.pluginConfig[0].accessories.find( accessory => accessory.name === selectedAccessory );
|
|
537
|
-
|
|
538
|
-
if ( !accessory )
|
|
539
|
-
return homebridge.toast.error( 'Can not find the accessory!', 'Error' );
|
|
540
|
-
|
|
541
|
-
console.log("EDIT ACCESSORY INCOMPLETE");
|
|
542
|
-
createCustomSchema( accessory );
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
} );
|
|
546
|
-
|
|
547
|
-
$( '#refreshAccessory' ).on( 'click', async ( ) =>
|
|
548
|
-
{
|
|
549
|
-
|
|
550
|
-
if ( GLOBAL.customSchema && GLOBAL.accessorySchema )
|
|
551
|
-
{
|
|
552
|
-
|
|
553
|
-
resetSchema( );
|
|
554
|
-
|
|
555
|
-
let accessory = GLOBAL.pluginConfig[0].accessories.find( accessory => accessory.name === GLOBAL.accessorySchema.name );
|
|
556
|
-
|
|
557
|
-
if ( !accessory )
|
|
558
|
-
return homebridge.toast.error( 'Can not find accessory in config!', 'Error' );
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
} );
|
|
563
|
-
|
|
564
|
-
$( '#removeAccessory' ).on( 'click', async ( ) =>
|
|
565
|
-
{
|
|
566
|
-
|
|
567
|
-
try
|
|
568
|
-
{
|
|
569
|
-
|
|
570
|
-
await removeDeviceFromConfig( );
|
|
571
|
-
|
|
572
|
-
resetUI( );
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
catch ( err )
|
|
576
|
-
{
|
|
577
|
-
|
|
578
|
-
homebridge.toast.error( err.message, 'Error' );
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
} );
|
|
583
|
-
|