homebridge-smartsystem 6.1.7 → 6.2.2
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 +14 -0
- package/accessories/accessory.js +4 -4
- package/accessories/accessory.ts +1 -2
- package/accessories/dimmer.js +6 -6
- package/accessories/dimmer.ts +1 -1
- package/accessories/door.js +2 -2
- package/accessories/door.ts +1 -1
- package/accessories/garagedoor.js +5 -4
- package/accessories/garagedoor.ts +2 -1
- package/accessories/lock.js +6 -5
- package/accessories/lock.ts +2 -1
- package/accessories/mood.js +2 -1
- package/accessories/mood.ts +2 -1
- package/accessories/temperature.js +2 -2
- package/accessories/temperature.ts +1 -1
- package/accessories/windowcovering.js +8 -7
- package/accessories/windowcovering.ts +2 -1
- package/config.json +169 -228
- package/config.smappee.json +178 -2
- package/config.smartapp.json +63 -0
- package/duotecno/Q.js +8 -8
- package/duotecno/Q.ts +1 -1
- package/duotecno/api.js +3 -3
- package/duotecno/api.ts +2 -2
- package/duotecno/config.js +24 -23
- package/duotecno/config.ts +23 -16
- package/duotecno/logger.js +51 -0
- package/duotecno/logger.ts +41 -0
- package/duotecno/master.js +4 -6
- package/duotecno/master.ts +2 -4
- package/duotecno/protocol.js +10 -9
- package/duotecno/protocol.ts +2 -1
- package/duotecno/system.js +17 -41
- package/duotecno/system.ts +7 -34
- package/duotecno/types.js +58 -131
- package/duotecno/types.ts +65 -125
- package/index.spec.js +22 -36
- package/index.spec.ts +20 -33
- package/package.json +2 -2
- package/server/base.js +10 -38
- package/server/base.ts +9 -42
- package/server/p1.js +9 -8
- package/server/p1.ts +6 -4
- package/server/platform.js +66 -36
- package/server/platform.ts +47 -12
- package/server/powerbase.js +15 -55
- package/server/powerbase.ts +4 -50
- package/server/shelly.js +4 -4
- package/server/shelly.ts +3 -2
- package/server/smappee.js +9 -8
- package/server/smappee.ts +4 -3
- package/server/smartapp.js +94 -39
- package/server/smartapp.ts +73 -20
- package/server/socapp.js +6 -6
- package/server/socapp.ts +2 -1
- package/server/somfy.js +12 -12
- package/server/somfy.ts +1 -1
- package/server/support.js +13 -13
- package/server/support.ts +4 -4
- package/server/views/style.ejs +1 -0
- package/server/views/switch-details.ejs +15 -5
- package/server/webapp.js +45 -47
- package/server/webapp.ts +29 -38
- package/config.groups.json +0 -8
- package/config.p1-dev.json +0 -59
- package/config.scenes.json +0 -15
package/duotecno/types.js
CHANGED
|
@@ -14,7 +14,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.makeInt = exports.now = exports.datetime = exports.time = exports.date = exports.watt = exports.hex = exports.two = exports.char = exports.ascii = exports.wait = exports.Sanitizers = exports.actionValueStr = exports.actionValue = exports.kEmptySwitch = exports.kEmptyRule = exports.kEmptyAction = exports.kEmptyBinding = exports.SwitchType = exports.RuleType = exports.Boundaries = exports.kEmptyCommRecord = exports.WriteError = exports.kEmptySettings = exports.kEmptyNetworkConfig = exports.kEmptyGroup = exports.kEmptyScene = exports.kEmptyUnitScene = exports.kEmptyUnit = exports.
|
|
17
|
+
exports.makeInt = exports.now = exports.datetime = exports.time = exports.date = exports.watt = exports.hex = exports.two = exports.char = exports.ascii = exports.wait = exports.Sanitizers = exports.actionValueStr = exports.actionValue = exports.kEmptySwitch = exports.kEmptyRule = exports.kEmptyAction = exports.kEmptyBinding = exports.SwitchType = exports.RuleType = exports.Boundaries = exports.kEmptyCommRecord = exports.WriteError = exports.kEmptySettings = exports.kEmptyNetworkConfig = exports.kEmptyGroup = exports.kEmptyScene = exports.kEmptyUnitScene = exports.kEmptyUnit = exports.UnitExtendedType = exports.UnitType = exports.UnitMotorCmd = exports.UnitState = exports.NodeType = void 0;
|
|
18
18
|
// Node types
|
|
19
19
|
var NodeType;
|
|
20
20
|
(function (NodeType) {
|
|
@@ -81,58 +81,6 @@ var UnitExtendedType;
|
|
|
81
81
|
UnitExtendedType[UnitExtendedType["kUnlocker"] = 204] = "kUnlocker";
|
|
82
82
|
})(UnitExtendedType = exports.UnitExtendedType /* extends UnitType */ || (exports.UnitExtendedType /* extends UnitType */ = {}));
|
|
83
83
|
;
|
|
84
|
-
// kLightbulb == kSwitch with no "*" or "$" in the name
|
|
85
|
-
// kDoor == kSwitchingMotor with "*" in the name
|
|
86
|
-
// kGarageDoor == kSwitchingMotor with "$" in the name
|
|
87
|
-
// kCondition == kMood with "*" in the name
|
|
88
|
-
// kLock == kMood with $ in the name
|
|
89
|
-
// kUnlocker = kMood with $ in the name
|
|
90
|
-
/////////////
|
|
91
|
-
// Logging //
|
|
92
|
-
/////////////
|
|
93
|
-
// add LogLevels per type at runtime
|
|
94
|
-
var LogLevel;
|
|
95
|
-
(function (LogLevel) {
|
|
96
|
-
LogLevel[LogLevel["noLog"] = 0] = "noLog";
|
|
97
|
-
LogLevel[LogLevel["log"] = 1] = "log";
|
|
98
|
-
LogLevel[LogLevel["debug"] = 2] = "debug";
|
|
99
|
-
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
100
|
-
;
|
|
101
|
-
exports.logSettings = {
|
|
102
|
-
"*": LogLevel.log,
|
|
103
|
-
"master": LogLevel.log,
|
|
104
|
-
"protocol": LogLevel.noLog,
|
|
105
|
-
"webapp": LogLevel.log,
|
|
106
|
-
"p1": LogLevel.log,
|
|
107
|
-
"power": LogLevel.log
|
|
108
|
-
};
|
|
109
|
-
// can be overriden with server log function
|
|
110
|
-
exports.logFunction = console.log;
|
|
111
|
-
function setLogFunction(F) {
|
|
112
|
-
console.log(">>>>>>>>> NOT changing logfunction to: " + F.name + " <<<<<<<<<<");
|
|
113
|
-
// logFunction = (m) => { F(m) };
|
|
114
|
-
}
|
|
115
|
-
exports.setLogFunction = setLogFunction;
|
|
116
|
-
function err(type, message) {
|
|
117
|
-
(0, exports.logFunction)(type + ": " + ((typeof message === "string") ? message : JSON.stringify(message)));
|
|
118
|
-
}
|
|
119
|
-
exports.err = err;
|
|
120
|
-
function log(type, message) {
|
|
121
|
-
var _a;
|
|
122
|
-
const level = (_a = exports.logSettings[type]) !== null && _a !== void 0 ? _a : exports.logSettings["*"];
|
|
123
|
-
if (level) {
|
|
124
|
-
(0, exports.logFunction)(type + ": " + ((typeof message === "string") ? message : JSON.stringify(message)));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.log = log;
|
|
128
|
-
function debug(type, message) {
|
|
129
|
-
var _a;
|
|
130
|
-
const level = (_a = exports.logSettings[type]) !== null && _a !== void 0 ? _a : exports.logSettings["*"];
|
|
131
|
-
if (level === LogLevel.debug) {
|
|
132
|
-
(0, exports.logFunction)(type + "> " + ((typeof message === "string") ? message : JSON.stringify(message)));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.debug = debug;
|
|
136
84
|
;
|
|
137
85
|
;
|
|
138
86
|
;
|
|
@@ -200,7 +148,7 @@ exports.kEmptyRule = {
|
|
|
200
148
|
actions: [Object.assign(Object.assign({}, exports.kEmptyUnit), { value: false }), Object.assign(Object.assign({}, exports.kEmptyUnit), { value: 50 }), Object.assign(Object.assign({}, exports.kEmptyUnit), { value: true })]
|
|
201
149
|
};
|
|
202
150
|
;
|
|
203
|
-
exports.kEmptySwitch = Object.assign(Object.assign({}, exports.kEmptyUnit), { plug: 0, type: SwitchType.kNoType, unitName: "", name: "", data: "", method: "GET", nomacro: "N", nostop: "N" });
|
|
151
|
+
exports.kEmptySwitch = Object.assign(Object.assign({}, exports.kEmptyUnit), { plug: 0, type: SwitchType.kNoType, unitName: "", name: "", data: "", method: "GET", header: "", nomacro: "N", nostop: "N" });
|
|
204
152
|
;
|
|
205
153
|
;
|
|
206
154
|
;
|
|
@@ -243,13 +191,11 @@ exports.Sanitizers = {
|
|
|
243
191
|
config = {};
|
|
244
192
|
config.manufacturer = config.manufacturer || "Duotecno-Coppieters";
|
|
245
193
|
config.platform = config.platform || "DuotecnoPlatform";
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
config.system = config.system || "./config.system.json";
|
|
252
|
-
}
|
|
194
|
+
config.smappee = config.smappee || false;
|
|
195
|
+
config.p1 = config.p1 || false;
|
|
196
|
+
config.shelly = config.shelly || false;
|
|
197
|
+
config.smartapp = config.smartapp || null;
|
|
198
|
+
config.system = exports.Sanitizers.system(config.system);
|
|
253
199
|
return config;
|
|
254
200
|
},
|
|
255
201
|
homebridge: function (config) {
|
|
@@ -260,19 +206,18 @@ exports.Sanitizers = {
|
|
|
260
206
|
config.bridge.username = config.bridge.username || "CC:22:3D:E3:A3:01";
|
|
261
207
|
config.bridge.port = config.bridge.port || 51827;
|
|
262
208
|
config.bridge.pin = config.bridge.pin || "577-03-001";
|
|
263
|
-
config.description = config.description || "Duotecno Platform";
|
|
264
|
-
config.password = config.password || ("!@#$%^&*()" + new Date().getTime());
|
|
265
209
|
config.platforms = config.platforms || [{}];
|
|
266
210
|
for (let p in config.platforms)
|
|
267
|
-
|
|
211
|
+
if (config.platforms[p].platform == "DuotecnoPlatform")
|
|
212
|
+
config.platforms[p] = exports.Sanitizers.platform(config.platforms[p]);
|
|
268
213
|
config.accessories = []; //config.accessories || [<AccessoryConfig>{}];
|
|
269
|
-
//for (let a in config.accessories)
|
|
214
|
+
//for (let a in config.accessories) Sanitizers.accessory(config.accessories[a]);
|
|
270
215
|
return config;
|
|
271
216
|
},
|
|
272
217
|
settings: function (config) {
|
|
273
218
|
if (!config)
|
|
274
219
|
config = {};
|
|
275
|
-
config.network =
|
|
220
|
+
config.network = exports.Sanitizers.networkConfig(config.network);
|
|
276
221
|
return config;
|
|
277
222
|
},
|
|
278
223
|
networkConfig: function (config) {
|
|
@@ -300,54 +245,60 @@ exports.Sanitizers = {
|
|
|
300
245
|
config = {};
|
|
301
246
|
config.port = config.port || 5002;
|
|
302
247
|
config.switches = config.switches || [];
|
|
303
|
-
config.switches.
|
|
248
|
+
config.switches = config.switches.map(sw => exports.Sanitizers.switchConfig(sw));
|
|
304
249
|
config.debug = config.debug || false;
|
|
250
|
+
config.apiHost = config.apiHost || "localhost";
|
|
251
|
+
config.apiPort = config.apiPort || 8581;
|
|
305
252
|
return config;
|
|
306
253
|
},
|
|
307
254
|
powerbase: function (config) {
|
|
308
255
|
if (!config)
|
|
309
256
|
config = {};
|
|
310
257
|
config.rules = config.rules || [];
|
|
311
|
-
config.rules = config.rules.map(sw =>
|
|
258
|
+
config.rules = config.rules.map(sw => exports.Sanitizers.ruleConfig(sw));
|
|
312
259
|
config.bindings = config.bindings || [];
|
|
313
|
-
config.bindings = config.bindings.map(b =>
|
|
260
|
+
config.bindings = config.bindings.map(b => exports.Sanitizers.bindingConfig(b));
|
|
314
261
|
config.address = config.address || "";
|
|
315
262
|
return config;
|
|
316
263
|
},
|
|
317
264
|
smappee: function (config) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
265
|
+
if (!config)
|
|
266
|
+
config = {};
|
|
267
|
+
const cfg = exports.Sanitizers.powerbase(config);
|
|
268
|
+
cfg.uid = config.uid || "--none--";
|
|
269
|
+
return cfg;
|
|
321
270
|
},
|
|
322
271
|
p1: function (config) {
|
|
323
|
-
config =
|
|
272
|
+
config = exports.Sanitizers.powerbase(config);
|
|
324
273
|
return config;
|
|
325
274
|
},
|
|
326
275
|
shelly: function (config) {
|
|
327
|
-
config =
|
|
276
|
+
config = exports.Sanitizers.powerbase(config);
|
|
328
277
|
return config;
|
|
329
278
|
},
|
|
330
279
|
switchConfig: function (aSwitch) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
280
|
+
const sw = exports.Sanitizers.unitDef(aSwitch);
|
|
281
|
+
sw.nomacro = aSwitch.nomacro || "N";
|
|
282
|
+
sw.nostop = aSwitch.nostop || "N";
|
|
283
|
+
sw.name = aSwitch.name || "--";
|
|
284
|
+
sw.unitName = aSwitch.unitName || "";
|
|
285
|
+
sw.value = aSwitch.value || 0;
|
|
286
|
+
sw.data = aSwitch.data || "";
|
|
287
|
+
sw.header = aSwitch.header || "";
|
|
288
|
+
sw.method = aSwitch.method || "GET";
|
|
289
|
+
sw.type = aSwitch.type || SwitchType.kNoType;
|
|
340
290
|
// don't destroy 0 plug
|
|
341
291
|
if (typeof aSwitch.plug === "string")
|
|
342
|
-
|
|
343
|
-
return
|
|
292
|
+
sw.plug = aSwitch.plug || "";
|
|
293
|
+
return sw;
|
|
344
294
|
},
|
|
345
295
|
makeSwitchConfig: function (aSwitch) {
|
|
346
|
-
return
|
|
296
|
+
return exports.Sanitizers.switchConfig({ name: aSwitch.name, unitName: aSwitch.unitName,
|
|
347
297
|
masterAddress: aSwitch.masterAddress, masterPort: aSwitch.masterPort,
|
|
348
298
|
nomacro: aSwitch.nomacro, nostop: aSwitch.nostop,
|
|
349
299
|
logicalAddress: aSwitch.logicalAddress, logicalNodeAddress: aSwitch.logicalNodeAddress,
|
|
350
|
-
type: aSwitch.type, plug: aSwitch.plug,
|
|
300
|
+
type: aSwitch.type, plug: aSwitch.plug,
|
|
301
|
+
data: aSwitch.data, method: aSwitch.method, header: aSwitch.header });
|
|
351
302
|
},
|
|
352
303
|
ruleConfig(rule) {
|
|
353
304
|
rule = Object.assign({}, rule);
|
|
@@ -368,10 +319,10 @@ exports.Sanitizers = {
|
|
|
368
319
|
return rule;
|
|
369
320
|
},
|
|
370
321
|
bindingConfig(binding) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return
|
|
322
|
+
const b = exports.Sanitizers.unitDef(Object.assign({}, binding));
|
|
323
|
+
b.channel = binding.channel || "0";
|
|
324
|
+
b.power = binding.power || NaN;
|
|
325
|
+
return b;
|
|
375
326
|
},
|
|
376
327
|
masterConfig: function (config) {
|
|
377
328
|
config = (config) ? Object.assign({}, config) : {};
|
|
@@ -392,36 +343,16 @@ exports.Sanitizers = {
|
|
|
392
343
|
if (!config)
|
|
393
344
|
config = {};
|
|
394
345
|
config.mood = config.mood || "sfeer";
|
|
395
|
-
config.language = config.language || "EN";
|
|
396
346
|
config.debug = config.debug || false;
|
|
397
|
-
config.stores = config.stores || false;
|
|
398
|
-
config.multiple = config.multiple || false;
|
|
399
347
|
config.socketserver = config.socketserver || 'ws.duotecno.eu';
|
|
400
348
|
// correct old settings
|
|
401
349
|
if (config.socketserver == 'akiworks.be')
|
|
402
350
|
config.socketserver = 'ws.duotecno.eu';
|
|
403
351
|
config.socketport = config.socketport || 9999;
|
|
404
352
|
config.cmasters = config.cmasters || [];
|
|
405
|
-
config.cmasters.
|
|
353
|
+
config.cmasters = config.cmasters.map(m => exports.Sanitizers.masterConfig(m));
|
|
406
354
|
config.cunits = config.cunits || [];
|
|
407
|
-
config.cunits.
|
|
408
|
-
return config;
|
|
409
|
-
},
|
|
410
|
-
////////////
|
|
411
|
-
// Groups //
|
|
412
|
-
group: function (config) {
|
|
413
|
-
if (!config)
|
|
414
|
-
return exports.kEmptyGroup;
|
|
415
|
-
config.name = config.name || exports.kEmptyGroup.name;
|
|
416
|
-
config.id = config.id || exports.kEmptyGroup.id;
|
|
417
|
-
config.order = config.order || exports.kEmptyGroup.order;
|
|
418
|
-
config.visible = (typeof config.visible === "boolean") ? config.visible : exports.kEmptyGroup.visible;
|
|
419
|
-
return config;
|
|
420
|
-
},
|
|
421
|
-
groups: function (config) {
|
|
422
|
-
if (!config)
|
|
423
|
-
return [Object.assign({}, exports.kEmptyGroup)];
|
|
424
|
-
config.forEach(g => exports.Sanitizers["group"](g));
|
|
355
|
+
config.cunits = config.cunits.map(u => exports.Sanitizers.unitConfig(u));
|
|
425
356
|
return config;
|
|
426
357
|
},
|
|
427
358
|
//////////
|
|
@@ -438,17 +369,18 @@ exports.Sanitizers = {
|
|
|
438
369
|
//////////
|
|
439
370
|
// Unit //
|
|
440
371
|
unitDef: function (info) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
372
|
+
return {
|
|
373
|
+
logicalNodeAddress: info.logicalNodeAddress || 0,
|
|
374
|
+
logicalAddress: info.logicalAddress || 0,
|
|
375
|
+
masterAddress: info.masterAddress || '',
|
|
376
|
+
masterPort: info.masterPort || 5001
|
|
377
|
+
};
|
|
446
378
|
},
|
|
447
379
|
unitConfig: function (config) {
|
|
448
380
|
if (!config) {
|
|
449
381
|
config = {};
|
|
450
382
|
}
|
|
451
|
-
|
|
383
|
+
config = exports.Sanitizers.unitDef(config);
|
|
452
384
|
config.active = config.active || 'N';
|
|
453
385
|
config.used = config.used || config.active;
|
|
454
386
|
if (typeof config.group === 'string') {
|
|
@@ -462,7 +394,7 @@ exports.Sanitizers = {
|
|
|
462
394
|
if (!config) {
|
|
463
395
|
config = {};
|
|
464
396
|
}
|
|
465
|
-
|
|
397
|
+
config = exports.Sanitizers.unitDef(config);
|
|
466
398
|
if (typeof config.value === "undefined")
|
|
467
399
|
config.value = 0;
|
|
468
400
|
if (typeof config.value === "string")
|
|
@@ -471,7 +403,8 @@ exports.Sanitizers = {
|
|
|
471
403
|
logicalAddress: config.logicalAddress,
|
|
472
404
|
masterAddress: config.masterAddress,
|
|
473
405
|
masterPort: config.masterPort,
|
|
474
|
-
value: config.value
|
|
406
|
+
value: config.value,
|
|
407
|
+
name: config.name };
|
|
475
408
|
},
|
|
476
409
|
////////////
|
|
477
410
|
// Scenes //
|
|
@@ -486,16 +419,16 @@ exports.Sanitizers = {
|
|
|
486
419
|
newConfig.order = parseInt(config.order);
|
|
487
420
|
}
|
|
488
421
|
newConfig.order = config.order || exports.kEmptyScene.order;
|
|
489
|
-
newConfig.trigger =
|
|
422
|
+
newConfig.trigger = exports.Sanitizers.unitScene(config.trigger);
|
|
490
423
|
config.units = config.units || exports.kEmptyScene.units;
|
|
491
|
-
newConfig.units = config.units.map(u =>
|
|
424
|
+
newConfig.units = config.units.map(u => exports.Sanitizers.unitScene(u));
|
|
492
425
|
return newConfig;
|
|
493
426
|
},
|
|
494
427
|
scenes: function (config) {
|
|
495
428
|
if (!config) {
|
|
496
|
-
return [
|
|
429
|
+
return [exports.Sanitizers.sceneConfig()];
|
|
497
430
|
}
|
|
498
|
-
config.
|
|
431
|
+
config = config.map(s => exports.Sanitizers.sceneConfig(s));
|
|
499
432
|
return config;
|
|
500
433
|
},
|
|
501
434
|
///////////////////////////////////
|
|
@@ -528,12 +461,6 @@ exports.Sanitizers = {
|
|
|
528
461
|
return info;
|
|
529
462
|
}
|
|
530
463
|
};
|
|
531
|
-
// add dev entries for dev configs
|
|
532
|
-
exports.Sanitizers["system-dev"] = exports.Sanitizers["system"];
|
|
533
|
-
exports.Sanitizers["smartapp-dev"] = exports.Sanitizers["smartapp"];
|
|
534
|
-
exports.Sanitizers["smappee-dev"] = exports.Sanitizers["smappee"];
|
|
535
|
-
exports.Sanitizers["p1-dev"] = exports.Sanitizers["p1"];
|
|
536
|
-
exports.Sanitizers["shelly-dev"] = exports.Sanitizers["shelly"];
|
|
537
464
|
//////////////////////
|
|
538
465
|
// Helper functions //
|
|
539
466
|
//////////////////////
|