homebridge-smartsystem 6.2.3 → 6.2.6

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.
@@ -2,5 +2,6 @@
2
2
  "files.exclude": {
3
3
  "**/*.js": true,
4
4
  "**/*.js.map": true
5
- }
5
+ },
6
+ "task.allowAutomaticTasks": true
6
7
  }
package/README.md CHANGED
@@ -272,6 +272,9 @@ Homebridge UI version
272
272
  - 1: always write config to file too (next to sending through the HB-UI API)
273
273
  - 2: added headers to http calls from switches, dimmers and up/down's (including OH stuff)
274
274
  - 3: fixed bug in Sanitizer of UnitConfig preventing from publishing units to homebridge
275
+ - 4: fixed empty name bug in unit-def / new accessory()
276
+ - 5: fixed bad displayNames in published units
277
+ - 6: power: 5% instead of 10% for power rules
275
278
 
276
279
 
277
280
  ## Hardware
@@ -9,9 +9,9 @@ const logger_1 = require("../duotecno/logger");
9
9
  class Accessory {
10
10
  constructor(api, unit) {
11
11
  this.homebridge = api.hap;
12
- this.unit = unit; // : Duotecno Unit
13
- this.name = unit.getDisplayName();
14
12
  this.uuid_base = unit.getSerialNr();
13
+ this.unit = unit; // : Duotecno Unit
14
+ this.name = unit.getDisplayName() || this.uuid_base;
15
15
  // get all services and add ours
16
16
  this.services = this.getAccessoryServices();
17
17
  this.services.push(this.getInformationService());
@@ -33,10 +33,10 @@ class Accessory {
33
33
  throw new Error('The getSystemServices method must be overridden.');
34
34
  }
35
35
  getModelName() {
36
- return this.name;
36
+ return this.name || this.unit.getSerialNr();
37
37
  }
38
38
  getName() {
39
- return this.name;
39
+ return this.name || this.unit.getSerialNr();
40
40
  }
41
41
  getSerialNumber() {
42
42
  if (this.unit)
@@ -18,9 +18,10 @@ export class Accessory {
18
18
 
19
19
  constructor(api: API, unit: Unit) {
20
20
  this.homebridge = api.hap;
21
- this.unit = unit; // : Duotecno Unit
22
- this.name = unit.getDisplayName();
21
+
23
22
  this.uuid_base = unit.getSerialNr();
23
+ this.unit = unit; // : Duotecno Unit
24
+ this.name = unit.getDisplayName() || this.uuid_base;
24
25
 
25
26
  // get all services and add ours
26
27
  this.services = this.getAccessoryServices();
@@ -47,10 +48,10 @@ export class Accessory {
47
48
  }
48
49
 
49
50
  getModelName(): string {
50
- return this.name;
51
+ return this.name || this.unit.getSerialNr();
51
52
  }
52
53
  getName(): string {
53
- return this.name;
54
+ return this.name || this.unit.getSerialNr();
54
55
  }
55
56
 
56
57
  getSerialNumber(): string {
package/config.dhcpcd ADDED
@@ -0,0 +1,5 @@
1
+ interface eth0
2
+ static ip_address=1.2.3.4
3
+ static routers=1.2.3.1
4
+
5
+ static domain_name_servers=8.8.8.8
package/config.json CHANGED
@@ -147,6 +147,9 @@
147
147
  "logicalAddress": 102,
148
148
  "masterAddress": "192.168.0.97",
149
149
  "masterPort": 5001,
150
+ "name": "unit 252:102",
151
+ "displayName": "unit 252:102",
152
+ "extendedType": 0,
150
153
  "channel": "0+1",
151
154
  "power": 1706
152
155
  },
@@ -155,6 +158,9 @@
155
158
  "logicalAddress": 100,
156
159
  "masterAddress": "192.168.0.97",
157
160
  "masterPort": 5001,
161
+ "name": "unit 252:100",
162
+ "displayName": "unit 252:100",
163
+ "extendedType": 0,
158
164
  "channel": "2+3",
159
165
  "power": 2494
160
166
  },
@@ -163,6 +169,9 @@
163
169
  "logicalAddress": 103,
164
170
  "masterAddress": "192.168.0.97",
165
171
  "masterPort": 5001,
172
+ "name": "unit 252:103",
173
+ "displayName": "unit 252:103",
174
+ "extendedType": 0,
166
175
  "channel": "4+5",
167
176
  "power": null
168
177
  },
@@ -171,6 +180,9 @@
171
180
  "logicalAddress": 101,
172
181
  "masterAddress": "192.168.0.97",
173
182
  "masterPort": 5001,
183
+ "name": "unit 252:101",
184
+ "displayName": "unit 252:101",
185
+ "extendedType": 0,
174
186
  "channel": "8",
175
187
  "power": null
176
188
  }
@@ -217,6 +229,9 @@
217
229
  "logicalAddress": 102,
218
230
  "masterAddress": "192.168.0.97",
219
231
  "masterPort": 5001,
232
+ "name": "unit 252:102",
233
+ "displayName": "unit 252:102",
234
+ "extendedType": 0,
220
235
  "channel": "0+1+2",
221
236
  "power": null
222
237
  },
@@ -225,6 +240,9 @@
225
240
  "logicalAddress": 100,
226
241
  "masterAddress": "192.168.0.97",
227
242
  "masterPort": 5001,
243
+ "name": "unit 252:100",
244
+ "displayName": "unit 252:100",
245
+ "extendedType": 0,
228
246
  "channel": "3+4+5",
229
247
  "power": null
230
248
  }
@@ -243,9 +261,11 @@
243
261
  "logicalAddress": 107,
244
262
  "masterAddress": "192.168.0.97",
245
263
  "masterPort": 5001,
264
+ "name": "Shelly Valies",
265
+ "displayName": "Shelly Valies",
266
+ "extendedType": 0,
246
267
  "nomacro": "Y",
247
268
  "nostop": "Y",
248
- "name": "Shelly Valies",
249
269
  "unitName": "Red",
250
270
  "value": 0,
251
271
  "data": "",
@@ -259,9 +279,11 @@
259
279
  "logicalAddress": 105,
260
280
  "masterAddress": "192.168.0.97",
261
281
  "masterPort": 5001,
282
+ "name": "Screen Salon Top",
283
+ "displayName": "Screen Salon Top",
284
+ "extendedType": 0,
262
285
  "nomacro": "N",
263
286
  "nostop": "N",
264
- "name": "Screen Salon Top",
265
287
  "unitName": "Salon Top",
266
288
  "value": 0,
267
289
  "data": "",
@@ -275,9 +297,11 @@
275
297
  "logicalAddress": 104,
276
298
  "masterAddress": "192.168.0.97",
277
299
  "masterPort": 5001,
300
+ "name": "Screen Tim small",
301
+ "displayName": "Screen Tim small",
302
+ "extendedType": 0,
278
303
  "nomacro": "N",
279
304
  "nostop": "Y",
280
- "name": "Screen Tim small",
281
305
  "unitName": "Tim Small",
282
306
  "value": 0,
283
307
  "data": "",
@@ -291,9 +315,11 @@
291
315
  "logicalAddress": 35,
292
316
  "masterAddress": "gm.coppieters.be",
293
317
  "masterPort": 5005,
318
+ "name": "Test Plug",
319
+ "displayName": "Test Plug",
320
+ "extendedType": 0,
294
321
  "nomacro": "N",
295
322
  "nostop": "N",
296
- "name": "Test Plug",
297
323
  "unitName": "Plug",
298
324
  "value": 0,
299
325
  "data": "",
@@ -307,14 +333,16 @@
307
333
  "logicalAddress": 34,
308
334
  "masterAddress": "192.168.0.97",
309
335
  "masterPort": 5001,
336
+ "name": "Demo",
337
+ "displayName": "Demo",
338
+ "extendedType": 0,
310
339
  "nomacro": "N",
311
340
  "nostop": "N",
312
- "name": "Demo",
313
- "unitName": "",
341
+ "unitName": "unit 3:34",
314
342
  "value": 0,
315
343
  "data": "b=2",
316
344
  "header": "{\"a\":101, \"b\": \"hallo\"}",
317
- "method": "GET",
345
+ "method": "PUT",
318
346
  "type": "http",
319
347
  "plug": "http://localhost:3001/api/demo/haha?set=#B"
320
348
  }
@@ -350,6 +378,9 @@
350
378
  "logicalAddress": 102,
351
379
  "masterAddress": "192.168.0.97",
352
380
  "masterPort": 5001,
381
+ "name": "unit 252:102",
382
+ "displayName": "unit 252:102",
383
+ "extendedType": 0,
353
384
  "active": "N",
354
385
  "used": "N",
355
386
  "group": 0
@@ -359,6 +390,9 @@
359
390
  "logicalAddress": 103,
360
391
  "masterAddress": "192.168.0.97",
361
392
  "masterPort": 5001,
393
+ "name": "unit 252:103",
394
+ "displayName": "unit 252:103",
395
+ "extendedType": 0,
362
396
  "active": "N",
363
397
  "used": "N",
364
398
  "group": 0
@@ -368,6 +402,9 @@
368
402
  "logicalAddress": 100,
369
403
  "masterAddress": "192.168.0.97",
370
404
  "masterPort": 5001,
405
+ "name": "unit 252:100",
406
+ "displayName": "unit 252:100",
407
+ "extendedType": 0,
371
408
  "active": "N",
372
409
  "used": "N",
373
410
  "group": 0
@@ -377,6 +414,9 @@
377
414
  "logicalAddress": 101,
378
415
  "masterAddress": "192.168.0.97",
379
416
  "masterPort": 5001,
417
+ "name": "unit 252:101",
418
+ "displayName": "unit 252:101",
419
+ "extendedType": 0,
380
420
  "active": "N",
381
421
  "used": "N",
382
422
  "group": 0
@@ -386,6 +426,9 @@
386
426
  "logicalAddress": 105,
387
427
  "masterAddress": "192.168.0.97",
388
428
  "masterPort": 5001,
429
+ "name": "unit 252:105",
430
+ "displayName": "unit 252:105",
431
+ "extendedType": 0,
389
432
  "active": "N",
390
433
  "used": "N",
391
434
  "group": 0
@@ -395,6 +438,9 @@
395
438
  "logicalAddress": 104,
396
439
  "masterAddress": "192.168.0.97",
397
440
  "masterPort": 5001,
441
+ "name": "unit 252:104",
442
+ "displayName": "unit 252:104",
443
+ "extendedType": 0,
398
444
  "active": "N",
399
445
  "used": "N",
400
446
  "group": 0
@@ -404,6 +450,9 @@
404
450
  "logicalAddress": 106,
405
451
  "masterAddress": "192.168.0.97",
406
452
  "masterPort": 5001,
453
+ "name": "unit 252:106",
454
+ "displayName": "unit 252:106",
455
+ "extendedType": 0,
407
456
  "active": "N",
408
457
  "used": "N",
409
458
  "group": 0
@@ -413,6 +462,9 @@
413
462
  "logicalAddress": 1,
414
463
  "masterAddress": "192.168.0.97",
415
464
  "masterPort": 5001,
465
+ "name": "unit 3:1",
466
+ "displayName": "unit 3:1",
467
+ "extendedType": 0,
416
468
  "active": "N",
417
469
  "used": "N",
418
470
  "group": 0
@@ -422,6 +474,9 @@
422
474
  "logicalAddress": 0,
423
475
  "masterAddress": "192.168.0.97",
424
476
  "masterPort": 5001,
477
+ "name": "unit 3:0",
478
+ "displayName": "unit 3:0",
479
+ "extendedType": 0,
425
480
  "active": "N",
426
481
  "used": "N",
427
482
  "group": 0
@@ -431,6 +486,9 @@
431
486
  "logicalAddress": 30,
432
487
  "masterAddress": "192.168.0.97",
433
488
  "masterPort": 5001,
489
+ "name": "unit 3:30",
490
+ "displayName": "unit 3:30",
491
+ "extendedType": 0,
434
492
  "active": "N",
435
493
  "used": "N",
436
494
  "group": 0
@@ -440,6 +498,9 @@
440
498
  "logicalAddress": 29,
441
499
  "masterAddress": "192.168.0.97",
442
500
  "masterPort": 5001,
501
+ "name": "unit 3:29",
502
+ "displayName": "unit 3:29",
503
+ "extendedType": 0,
443
504
  "active": "N",
444
505
  "used": "N",
445
506
  "group": 0
@@ -449,6 +510,9 @@
449
510
  "logicalAddress": 35,
450
511
  "masterAddress": "192.168.0.97",
451
512
  "masterPort": 5001,
513
+ "name": "unit 3:35",
514
+ "displayName": "unit 3:35",
515
+ "extendedType": 0,
452
516
  "active": "N",
453
517
  "used": "N",
454
518
  "group": 0
@@ -458,6 +522,9 @@
458
522
  "logicalAddress": 34,
459
523
  "masterAddress": "192.168.0.97",
460
524
  "masterPort": 5001,
525
+ "name": "unit 3:34",
526
+ "displayName": "unit 3:34",
527
+ "extendedType": 0,
461
528
  "active": "N",
462
529
  "used": "N",
463
530
  "group": 0
@@ -467,6 +534,9 @@
467
534
  "logicalAddress": 33,
468
535
  "masterAddress": "192.168.0.97",
469
536
  "masterPort": 5001,
537
+ "name": "unit 3:33",
538
+ "displayName": "unit 3:33",
539
+ "extendedType": 0,
470
540
  "active": "N",
471
541
  "used": "N",
472
542
  "group": 0
@@ -476,6 +546,9 @@
476
546
  "logicalAddress": 36,
477
547
  "masterAddress": "192.168.0.97",
478
548
  "masterPort": 5001,
549
+ "name": "unit 3:36",
550
+ "displayName": "unit 3:36",
551
+ "extendedType": 0,
479
552
  "active": "N",
480
553
  "used": "N",
481
554
  "group": 0
@@ -485,6 +558,9 @@
485
558
  "logicalAddress": 5,
486
559
  "masterAddress": "192.168.0.97",
487
560
  "masterPort": 5001,
561
+ "name": "unit 3:5",
562
+ "displayName": "unit 3:5",
563
+ "extendedType": 0,
488
564
  "active": "N",
489
565
  "used": "N",
490
566
  "group": 0
@@ -494,6 +570,9 @@
494
570
  "logicalAddress": 4,
495
571
  "masterAddress": "192.168.0.97",
496
572
  "masterPort": 5001,
573
+ "name": "unit 3:4",
574
+ "displayName": "unit 3:4",
575
+ "extendedType": 0,
497
576
  "active": "N",
498
577
  "used": "N",
499
578
  "group": 0
@@ -515,5 +594,14 @@
515
594
  "units": []
516
595
  }
517
596
  ],
518
- "debug": false
597
+ "debug": false,
598
+ "settings": {
599
+ "network": {
600
+ "ip1": "1.2.3.4",
601
+ "gateway1": "1.2.3.1",
602
+ "nameservers": "8.8.8.8",
603
+ "ip2": "",
604
+ "gateway2": ""
605
+ }
606
+ }
519
607
  }
package/duotecno/types.js CHANGED
@@ -373,7 +373,10 @@ exports.Sanitizers = {
373
373
  logicalNodeAddress: info.logicalNodeAddress || 0,
374
374
  logicalAddress: info.logicalAddress || 0,
375
375
  masterAddress: info.masterAddress || '',
376
- masterPort: info.masterPort || 5001
376
+ masterPort: info.masterPort || 5001,
377
+ name: info.name || ('unit ' + info.logicalNodeAddress + ":" + info.logicalAddress),
378
+ displayName: info.displayName || info.name || ('unit ' + info.logicalNodeAddress + ":" + info.logicalAddress),
379
+ extendedType: info.extendedType || UnitExtendedType.kNoType
377
380
  };
378
381
  },
379
382
  unitConfig: function (config) {
package/duotecno/types.ts CHANGED
@@ -563,7 +563,12 @@ export const Sanitizers = {
563
563
  logicalNodeAddress: info.logicalNodeAddress || 0,
564
564
  logicalAddress: info.logicalAddress || 0,
565
565
  masterAddress: info.masterAddress || '',
566
- masterPort: info.masterPort || 5001
566
+ masterPort: info.masterPort || 5001,
567
+
568
+ name: info.name || ('unit '+info.logicalNodeAddress+":"+info.logicalAddress),
569
+ displayName: info.displayName || info.name || ('unit '+info.logicalNodeAddress+":"+info.logicalAddress),
570
+
571
+ extendedType: info.extendedType || UnitExtendedType.kNoType
567
572
  };
568
573
  },
569
574
 
package/index.spec.js CHANGED
@@ -1,42 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const platform_1 = require("./server/platform");
4
- const protocol_1 = require("./duotecno/protocol");
5
- const types_1 = require("./duotecno/types");
6
4
  const logger_1 = require("./duotecno/logger");
7
- const master_1 = require("./duotecno/master");
8
5
  const fs = require("fs");
9
6
  const os = require("os");
10
7
  (0, logger_1.setLogFunction)(console.log);
11
- logger_1.logSettings["spec"] = logger_1.LogLevel.debug;
12
- let platform;
13
- (0, logger_1.log)("spec", "running in directory: " + process.cwd());
14
- const isMac = (os.platform() === "darwin");
8
+ logger_1.logSettings["spec"] = logger_1.LogLevel.log;
9
+ const osType = os.platform();
10
+ (0, logger_1.log)("spec", "running in directory: " + process.cwd() + " on " + osType);
11
+ const isMac = (osType === "darwin");
15
12
  const kConfigFiles = (isMac) ? (__dirname) : (os.homedir() + "/duotecno");
16
13
  if (!fs.existsSync(kConfigFiles))
17
14
  fs.mkdirSync(kConfigFiles);
18
- const fn = kConfigFiles + "/config.json";
19
- (0, logger_1.log)("spec", "Config in " + fn);
20
15
  function adder(plugin, platform, list) {
21
16
  (0, logger_1.log)("spec", "************* plugin: " + plugin + ", platform: " + platform);
22
17
  (0, logger_1.log)("spec", "************* list: " + JSON.stringify(list));
23
18
  }
24
- function tester() {
25
- // testing
26
- let m = new master_1.Master(platform.system, types_1.Sanitizers.masterConfig({ name: "master1", address: "12", port: 21, password: "x", active: true, nodenames: {} }));
27
- let n = new protocol_1.Node(m, types_1.Sanitizers.nodeInfo({ name: "node1" }));
28
- let u = new protocol_1.Unit(n, types_1.Sanitizers.unitInfo({ name: "unit|123 $", type: 7 }));
29
- (0, logger_1.log)("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
30
- u = new protocol_1.Unit(n, types_1.Sanitizers.unitInfo({ name: "unit|20", type: 1 }));
31
- (0, logger_1.log)("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
32
- }
33
19
  try {
20
+ const fn = kConfigFiles + "/config.json";
21
+ (0, logger_1.log)("spec", "Reading config from " + fn);
34
22
  const configBuf = fs.readFileSync(fn);
35
23
  const configStr = configBuf.toString();
36
24
  const config = JSON.parse(configStr);
37
- platform = new platform_1.Platform(console, config, { registerPlatformAccessories: adder });
25
+ (0, logger_1.debug)("spec", config);
26
+ const platform = new platform_1.Platform(console, config, { registerPlatformAccessories: adder });
38
27
  }
39
28
  catch (err) {
40
29
  (0, logger_1.log)("spec", err);
41
30
  }
31
+ // function tester() {
32
+ // // testing
33
+ // let m = new Master(platform.system, Sanitizers.masterConfig({name: "master1", address: "12", port: 21, password:"x", active: true, nodenames: {}}));
34
+ // let n = new Node(m, Sanitizers.nodeInfo({name: "node1"}));
35
+ // let u = new Unit(n, Sanitizers.unitInfo({name: "unit|123 $", type: 7}));
36
+ // log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
37
+ // u = new Unit(n, Sanitizers.unitInfo({name: "unit|20", type: 1}));
38
+ // log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
39
+ // }
42
40
  //# sourceMappingURL=index.spec.js.map
package/index.spec.ts CHANGED
@@ -1,50 +1,53 @@
1
1
  import { Platform } from "./server/platform";
2
2
  import { Unit, Node } from "./duotecno/protocol";
3
3
  import { Sanitizers } from "./duotecno/types";
4
- import { log, LogLevel, logSettings, setLogFunction } from "./duotecno/logger";
4
+ import { debug, log, LogLevel, logSettings, setLogFunction } from "./duotecno/logger";
5
5
  import { Master } from "./duotecno/master";
6
6
  import { API } from "homebridge";
7
7
  import * as fs from "fs";
8
8
  import * as os from "os";
9
9
 
10
10
  setLogFunction(console.log);
11
- logSettings["spec"] = LogLevel.debug;
11
+ logSettings["spec"] = LogLevel.log;
12
12
 
13
- let platform;
14
- log("spec", "running in directory: " + process.cwd());
15
13
 
16
- const isMac = (os.platform() === "darwin");
14
+ const osType = os.platform();
15
+ log("spec", "running in directory: " + process.cwd() + " on " + osType);
16
+
17
+ const isMac = (osType === "darwin");
17
18
  const kConfigFiles = (isMac) ? (__dirname) : (os.homedir() + "/duotecno");
18
19
  if (! fs.existsSync(kConfigFiles)) fs.mkdirSync(kConfigFiles);
19
20
 
20
- const fn = kConfigFiles + "/config.json";
21
- log("spec", "Config in " + fn);
22
21
 
23
22
  function adder(plugin: string, platform: string, list: any[]) {
24
23
  log("spec", "************* plugin: " + plugin + ", platform: " + platform);
25
24
  log("spec", "************* list: " + JSON.stringify(list));
26
25
  }
27
26
 
28
- function tester() {
29
- // testing
30
- let m = new Master(platform.system, Sanitizers.masterConfig({name: "master1", address: "12", port: 21, password:"x", active: true, nodenames: {}}));
31
- let n = new Node(m, Sanitizers.nodeInfo({name: "node1"}));
32
- let u = new Unit(n, Sanitizers.unitInfo({name: "unit|123 $", type: 7}));
33
- log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
34
- u = new Unit(n, Sanitizers.unitInfo({name: "unit|20", type: 1}));
35
- log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
36
- }
37
-
38
-
39
27
 
40
28
  try {
29
+ const fn = kConfigFiles + "/config.json";
30
+ log("spec", "Reading config from " + fn);
31
+
41
32
  const configBuf = fs.readFileSync(fn);
42
33
  const configStr = configBuf.toString();
43
34
  const config = JSON.parse(configStr);
35
+ debug("spec", config);
44
36
 
45
- platform = new Platform(console, config, <API>{registerPlatformAccessories: adder});
37
+ const platform = new Platform(console, config, <API>{registerPlatformAccessories: adder});
46
38
 
47
39
  } catch(err) {
48
40
  log("spec", err);
49
41
  }
50
42
 
43
+
44
+ // function tester() {
45
+ // // testing
46
+ // let m = new Master(platform.system, Sanitizers.masterConfig({name: "master1", address: "12", port: 21, password:"x", active: true, nodenames: {}}));
47
+ // let n = new Node(m, Sanitizers.nodeInfo({name: "node1"}));
48
+ // let u = new Unit(n, Sanitizers.unitInfo({name: "unit|123 $", type: 7}));
49
+ // log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
50
+ // u = new Unit(n, Sanitizers.unitInfo({name: "unit|20", type: 1}));
51
+ // log("spec", "Testing names -> getName = " + u.getName() + ", getDisplayname = " + u.getDisplayName() + ", type " + u.type + ", extType = " + u.extendedType + ", getTypeName = " + u.typeName());
52
+ // }
53
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.2.3",
4
+ "version": "6.2.6",
5
5
  "description": "SmartServer (Proxy Websockets to TCP sockets, Smappee MQTT, Duotecno IP Nodes, Homekit interface)",
6
6
  "main": "index.js",
7
7
  "author": "Johan Coppieters",
@@ -17,6 +17,7 @@ const base_1 = require("./base");
17
17
  // used by Smappee, Shelly PM, P1 Meter, ...
18
18
  // Johan Coppieters, Jul 2022.
19
19
  //
20
+ const kPercentChange = 0.05;
20
21
  class PowerBase extends base_1.Base {
21
22
  constructor(type, system) {
22
23
  super(type);
@@ -97,8 +98,8 @@ class PowerBase extends base_1.Base {
97
98
  // for all bindings
98
99
  this.bindings.forEach(b => {
99
100
  const power = this.evalPower(b.channel);
100
- if ((!isNaN(power)) && (isNaN(b.power) || (Math.abs(b.power - power) > Math.abs(b.power * 0.1)))) {
101
- (0, logger_1.debug)("power", "APPLY to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * 0.1));
101
+ if ((!isNaN(power)) && (isNaN(b.power) || (Math.abs(b.power - power) > Math.abs(b.power * kPercentChange)))) {
102
+ (0, logger_1.debug)("power", "APPLY to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * kPercentChange));
102
103
  this.applyBinding(b, power)
103
104
  .then(value => {
104
105
  b.power = value;
@@ -107,7 +108,7 @@ class PowerBase extends base_1.Base {
107
108
  .catch((e) => (0, logger_1.err)(this.type, e));
108
109
  }
109
110
  else {
110
- (0, logger_1.debug)("power", "DONT to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * 0.1));
111
+ (0, logger_1.debug)("power", "DONT to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * kPercentChange));
111
112
  }
112
113
  });
113
114
  }
@@ -9,6 +9,8 @@ import { Context } from "./webapp";
9
9
  // Johan Coppieters, Jul 2022.
10
10
  //
11
11
 
12
+ const kPercentChange = 0.05;
13
+
12
14
 
13
15
  export class PowerBase extends Base {
14
16
  system: System;
@@ -112,8 +114,8 @@ export class PowerBase extends Base {
112
114
  // for all bindings
113
115
  this.bindings.forEach( b => {
114
116
  const power = this.evalPower(b.channel);
115
- if ((!isNaN(power)) && (isNaN(b.power) || (Math.abs(b.power - power) > Math.abs(b.power * 0.1)))) {
116
- debug("power", "APPLY to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * 0.1))
117
+ if ((!isNaN(power)) && (isNaN(b.power) || (Math.abs(b.power - power) > Math.abs(b.power * kPercentChange)))) {
118
+ debug("power", "APPLY to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * kPercentChange))
117
119
  this.applyBinding(b, power)
118
120
  .then(value => {
119
121
  b.power = value;
@@ -122,7 +124,7 @@ export class PowerBase extends Base {
122
124
  .catch((e) => err(this.type, e));
123
125
 
124
126
  } else {
125
- debug("power", "DONT to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * 0.1))
127
+ debug("power", "DONT to " + b.channel + " = " + b.power + " -> " + power + " for " + b.name + " (" + b.logicalNodeAddress + ";" + b.logicalAddress + "): difference: " + Math.abs(b.power - power) + " > threshold: " + Math.abs(b.power * kPercentChange))
126
128
  }
127
129
  });
128
130
  }
@@ -22,7 +22,7 @@ import { existsSync, truncateSync, writeFileSync } from 'fs';
22
22
  import { Shelly } from './shelly';
23
23
  import { P1 } from './p1';
24
24
  import { post } from "../duotecno/api";
25
- import { getConfig, setAPIConfig, setToken } from "../duotecno/config";
25
+ import { setToken } from "../duotecno/config";
26
26
 
27
27
  const kMaster = {name: "master", type: "string", default: "0.0.0.0:5001"} as const;
28
28
  const kAddress = {name: "address", type: "string", default: "0.0.0.0"} as const;
@@ -20,7 +20,6 @@
20
20
  Settings<button class="right btn waves-effect waves-light" type="submit" name="action" value="reset">Reset to DHCP</button>
21
21
  <button class="right btn waves-effect waves-light" type="submit" name="action" value="install">Install IP Settings</button>
22
22
  <button class="right btn waves-effect waves-light" type="submit" name="action" value="reboot">Reboot PI</button>
23
- <button class="right btn waves-effect waves-light" type="submit" name="action" value="restart">Restart Homebridge</button>
24
23
  </h1>
25
24
 
26
25
  <div class="row">
@@ -41,7 +40,7 @@
41
40
  </div>
42
41
  </div>
43
42
 
44
- <div class="row">
43
+ <!-- div class="row">
45
44
  <div class="input-field col s6">
46
45
  <input placeholder="" id="ip2" name="ip2" type="text" value="<%= config.network.ip2 %>">
47
46
  <label for="ip2">Secondary Fixed IP Address / netmask</label>
@@ -50,7 +49,7 @@
50
49
  <input placeholder="" id="gateway2" name="gateway2" type="text" value="<%= config.network.gateway2 %>">
51
50
  <label for="gateway2">Secondary Gateway</label>
52
51
  </div>
53
- </div>
52
+ </div -->
54
53
 
55
54
  </form>
56
55
 
package/config.p1.json DELETED
@@ -1,59 +0,0 @@
1
- {
2
- "rules": [
3
- {
4
- "type": "power",
5
- "channel": "3+4+5",
6
- "low": 30,
7
- "high": 1500,
8
- "actions": [
9
- {
10
- "name": "--",
11
- "value": false,
12
- "masterAddress": "192.168.0.97",
13
- "masterPort": 5001,
14
- "logicalAddress": 0,
15
- "logicalNodeAddress": 0
16
- },
17
- {
18
- "name": "--",
19
- "value": 50,
20
- "masterAddress": "192.168.0.97",
21
- "masterPort": 5001,
22
- "logicalAddress": 0,
23
- "logicalNodeAddress": 0
24
- },
25
- {
26
- "name": "Alles aan",
27
- "value": true,
28
- "masterAddress": "192.168.0.97",
29
- "masterPort": 5001,
30
- "logicalAddress": 5,
31
- "logicalNodeAddress": 3
32
- }
33
- ]
34
- }
35
- ],
36
- "bindings": [
37
- {
38
- "name": "<Solar Panels",
39
- "value": 0,
40
- "masterAddress": "192.168.0.97",
41
- "masterPort": 5001,
42
- "logicalAddress": 102,
43
- "logicalNodeAddress": 252,
44
- "channel": "0+1+2",
45
- "power": null
46
- },
47
- {
48
- "name": ">Grid",
49
- "value": 0,
50
- "masterAddress": "192.168.0.97",
51
- "masterPort": 5001,
52
- "logicalAddress": 100,
53
- "logicalNodeAddress": 252,
54
- "channel": "3+4+5",
55
- "power": null
56
- }
57
- ],
58
- "address": "192.168.0.214"
59
- }
@@ -1,4 +0,0 @@
1
- {
2
- "debug": false,
3
- "port": 9999
4
- }
@@ -1,9 +0,0 @@
1
- {
2
- "network": {
3
- "ip1": "192.168.0.97",
4
- "gateway1": "192.168.0.1",
5
- "nameservers": "8.8.8.8 8.8.8.4",
6
- "ip2": "",
7
- "gateway2": ""
8
- }
9
- }
@@ -1,183 +0,0 @@
1
- {
2
- "rules": [
3
- {
4
- "type": "sun",
5
- "channel": "0",
6
- "low": 30,
7
- "high": 900,
8
- "actions": [
9
- {
10
- "name": "Mood A",
11
- "value": false,
12
- "masterAddress": "192.168.0.97",
13
- "masterPort": 5001,
14
- "logicalAddress": 10,
15
- "logicalNodeAddress": 252
16
- },
17
- {
18
- "name": "Mood A",
19
- "value": 50,
20
- "masterAddress": "192.168.0.97",
21
- "masterPort": 5001,
22
- "logicalAddress": 10,
23
- "logicalNodeAddress": 252
24
- },
25
- {
26
- "name": "Mood A",
27
- "value": true,
28
- "masterAddress": "192.168.0.97",
29
- "masterPort": 5001,
30
- "logicalAddress": 10,
31
- "logicalNodeAddress": 252
32
- }
33
- ],
34
- "power": -3382,
35
- "current": 0
36
- },
37
- {
38
- "type": "power",
39
- "channel": "4",
40
- "low": 10,
41
- "high": 20,
42
- "actions": [
43
- {
44
- "name": "Mood B",
45
- "value": false,
46
- "masterAddress": "192.168.0.97",
47
- "masterPort": 5001,
48
- "logicalAddress": 11,
49
- "logicalNodeAddress": 252
50
- },
51
- {
52
- "name": "Mood B",
53
- "value": 50,
54
- "masterAddress": "192.168.0.97",
55
- "masterPort": 5001,
56
- "logicalAddress": 11,
57
- "logicalNodeAddress": 252
58
- },
59
- {
60
- "name": "Mood B",
61
- "value": true,
62
- "masterAddress": "192.168.0.97",
63
- "masterPort": 5001,
64
- "logicalAddress": 11,
65
- "logicalNodeAddress": 252
66
- }
67
- ],
68
- "power": 0,
69
- "current": 0
70
- },
71
- {
72
- "type": "power",
73
- "channel": "7+8+9",
74
- "low": 30,
75
- "high": 900,
76
- "actions": [
77
- {
78
- "name": "Mood C",
79
- "value": false,
80
- "masterAddress": "192.168.0.97",
81
- "masterPort": 5001,
82
- "logicalAddress": 12,
83
- "logicalNodeAddress": 252
84
- },
85
- {
86
- "name": "Mood C",
87
- "value": 50,
88
- "masterAddress": "192.168.0.97",
89
- "masterPort": 5001,
90
- "logicalAddress": 12,
91
- "logicalNodeAddress": 252
92
- },
93
- {
94
- "name": "Mood C",
95
- "value": true,
96
- "masterAddress": "192.168.0.97",
97
- "masterPort": 5001,
98
- "logicalAddress": 12,
99
- "logicalNodeAddress": 252
100
- }
101
- ],
102
- "power": 2207,
103
- "current": 2
104
- },
105
- {
106
- "type": "sun",
107
- "channel": "7",
108
- "low": 0,
109
- "high": 0,
110
- "actions": [
111
- {
112
- "name": "Mood C",
113
- "value": false,
114
- "masterAddress": "192.168.0.97",
115
- "masterPort": 5001,
116
- "logicalAddress": 12,
117
- "logicalNodeAddress": 252
118
- },
119
- {
120
- "name": "Mood C",
121
- "value": 50,
122
- "masterAddress": "192.168.0.97",
123
- "masterPort": 5001,
124
- "logicalAddress": 12,
125
- "logicalNodeAddress": 252
126
- },
127
- {
128
- "name": "Mood C",
129
- "value": true,
130
- "masterAddress": "192.168.0.97",
131
- "masterPort": 5001,
132
- "logicalAddress": 12,
133
- "logicalNodeAddress": 252
134
- }
135
- ]
136
- }
137
- ],
138
- "address": "192.168.0.186",
139
- "uid": "57e3e0d8-bb05-4b04-8662-1a9871998f3f",
140
- "debug": false,
141
- "bindings": [
142
- {
143
- "name": "<Solar",
144
- "value": 0,
145
- "masterAddress": "192.168.0.97",
146
- "masterPort": 5001,
147
- "logicalAddress": 102,
148
- "logicalNodeAddress": 252,
149
- "channel": "0+1",
150
- "power": 1706
151
- },
152
- {
153
- "name": ">Grid",
154
- "value": 0,
155
- "masterAddress": "192.168.0.97",
156
- "masterPort": 5001,
157
- "logicalAddress": 100,
158
- "logicalNodeAddress": 252,
159
- "channel": "2+3",
160
- "power": 2494
161
- },
162
- {
163
- "name": ">Cars",
164
- "value": 0,
165
- "masterAddress": "192.168.0.97",
166
- "masterPort": 5001,
167
- "logicalAddress": 103,
168
- "logicalNodeAddress": 252,
169
- "channel": "4+5",
170
- "power": null
171
- },
172
- {
173
- "name": ">Swimmingpool",
174
- "value": 0,
175
- "masterAddress": "192.168.0.97",
176
- "masterPort": 5001,
177
- "logicalAddress": 101,
178
- "logicalNodeAddress": 252,
179
- "channel": "8",
180
- "power": null
181
- }
182
- ]
183
- }
@@ -1,69 +0,0 @@
1
- {
2
- "apiPort": 8581,
3
- "apiHost": "192.168.0.99",
4
- "socapp": false,
5
- "port": 5002,
6
- "switches": [
7
- {
8
- "name": "Shelly Valies",
9
- "unitName": "Red",
10
- "masterAddress": "192.168.0.97",
11
- "masterPort": 5001,
12
- "nomacro": "Y",
13
- "nostop": "Y",
14
- "logicalAddress": 107,
15
- "logicalNodeAddress": 252,
16
- "type": "httpdim",
17
- "plug": "http://192.168.0.96/light/0?brightness=$&turn=#",
18
- "data": "",
19
- "method": "GET",
20
- "value": 0
21
- },
22
- {
23
- "name": "Screen Salon Top",
24
- "unitName": "Salon Top",
25
- "masterAddress": "192.168.0.97",
26
- "masterPort": 5001,
27
- "nomacro": "N",
28
- "nostop": "N",
29
- "logicalAddress": 105,
30
- "logicalNodeAddress": 252,
31
- "type": "somfy",
32
- "plug": "1",
33
- "data": "",
34
- "method": "GET",
35
- "value": 0
36
- },
37
- {
38
- "name": "Screen Tim small",
39
- "unitName": "Tim Small",
40
- "masterAddress": "192.168.0.97",
41
- "masterPort": 5001,
42
- "nomacro": "N",
43
- "nostop": "Y",
44
- "logicalAddress": 104,
45
- "logicalNodeAddress": 252,
46
- "type": "httpupdown",
47
- "plug": "2",
48
- "data": "",
49
- "method": "GET",
50
- "value": 0
51
- },
52
- {
53
- "name": "Test Plug",
54
- "unitName": "Plug",
55
- "masterAddress": "gm.coppieters.be",
56
- "masterPort": 5005,
57
- "nomacro": "N",
58
- "nostop": "N",
59
- "logicalAddress": 35,
60
- "logicalNodeAddress": 16,
61
- "type": "smappee",
62
- "plug": "1",
63
- "data": "",
64
- "method": "GET",
65
- "value": 0
66
- }
67
- ],
68
- "debug": false
69
- }
@@ -1,247 +0,0 @@
1
- {
2
- "language": "EN",
3
- "stores": false,
4
- "multiple": false,
5
- "socketserver": "ws.duotecno.eu",
6
- "socketport": 9999,
7
- "mood": "sfeer",
8
- "debug": false,
9
- "cmasters": [
10
- {
11
- "address": "192.168.0.97",
12
- "port": 5001,
13
- "password": "GMTecno",
14
- "name": "Valies",
15
- "active": true,
16
- "nodenames": {
17
- "3": "SB 1",
18
- "4": "oled",
19
- "252": " 20211003"
20
- },
21
- "debug": false
22
- }
23
- ],
24
- "cunits": [
25
- {
26
- "active": "Y",
27
- "used": "Y",
28
- "group": 0,
29
- "name": "<Solar Panels",
30
- "displayName": "<Solar Panels",
31
- "type": 4,
32
- "extendedType": null,
33
- "masterAddress": "192.168.0.97",
34
- "masterPort": 5001,
35
- "logicalNodeAddress": 252,
36
- "logicalAddress": 102
37
- },
38
- {
39
- "active": "Y",
40
- "used": "Y",
41
- "group": 0,
42
- "name": ">Cars",
43
- "displayName": ">Cars",
44
- "type": 4,
45
- "extendedType": null,
46
- "masterAddress": "192.168.0.97",
47
- "masterPort": 5001,
48
- "logicalNodeAddress": 252,
49
- "logicalAddress": 103
50
- },
51
- {
52
- "active": "Y",
53
- "used": "Y",
54
- "group": 0,
55
- "name": ">Grid",
56
- "displayName": ">Grid",
57
- "type": 4,
58
- "extendedType": null,
59
- "masterAddress": "192.168.0.97",
60
- "masterPort": 5001,
61
- "logicalNodeAddress": 252,
62
- "logicalAddress": 100
63
- },
64
- {
65
- "active": "Y",
66
- "used": "Y",
67
- "group": 0,
68
- "name": ">Swimmingpool",
69
- "displayName": ">Swimmingpool",
70
- "type": 4,
71
- "extendedType": null,
72
- "masterAddress": "192.168.0.97",
73
- "masterPort": 5001,
74
- "logicalNodeAddress": 252,
75
- "logicalAddress": 101
76
- },
77
- {
78
- "active": "Y",
79
- "used": "Y",
80
- "group": 0,
81
- "name": "Salon Top",
82
- "displayName": "Salon Top",
83
- "type": 8,
84
- "extendedType": 8,
85
- "masterAddress": "192.168.0.97",
86
- "masterPort": 5001,
87
- "logicalNodeAddress": 252,
88
- "logicalAddress": 105
89
- },
90
- {
91
- "active": "Y",
92
- "used": "Y",
93
- "group": 0,
94
- "name": "Tim Small",
95
- "displayName": "Tim Small",
96
- "type": 8,
97
- "extendedType": 8,
98
- "masterAddress": "192.168.0.97",
99
- "masterPort": 5001,
100
- "logicalNodeAddress": 252,
101
- "logicalAddress": 104
102
- },
103
- {
104
- "active": "Y",
105
- "used": "Y",
106
- "group": 0,
107
- "name": "Plug 1",
108
- "displayName": "Plug 1",
109
- "type": 2,
110
- "extendedType": 2,
111
- "masterAddress": "192.168.0.97",
112
- "masterPort": 5001,
113
- "logicalNodeAddress": 252,
114
- "logicalAddress": 106
115
- },
116
- {
117
- "active": "Y",
118
- "used": "Y",
119
- "group": 0,
120
- "name": "Smartbox",
121
- "displayName": "Smartbox",
122
- "type": 4,
123
- "extendedType": null,
124
- "masterAddress": "192.168.0.97",
125
- "masterPort": 5001,
126
- "logicalNodeAddress": 3,
127
- "logicalAddress": 1
128
- },
129
- {
130
- "active": "Y",
131
- "used": "Y",
132
- "group": 0,
133
- "name": "Valies",
134
- "displayName": "Valies",
135
- "type": 4,
136
- "extendedType": null,
137
- "masterAddress": "192.168.0.97",
138
- "masterPort": 5001,
139
- "logicalNodeAddress": 3,
140
- "logicalAddress": 0
141
- },
142
- {
143
- "active": "Y",
144
- "used": "Y",
145
- "group": 0,
146
- "name": "Blue LED",
147
- "displayName": "Blue LED",
148
- "type": 1,
149
- "extendedType": null,
150
- "masterAddress": "192.168.0.97",
151
- "masterPort": 5001,
152
- "logicalNodeAddress": 3,
153
- "logicalAddress": 30
154
- },
155
- {
156
- "active": "Y",
157
- "used": "Y",
158
- "group": 0,
159
- "name": "Red LED",
160
- "displayName": "Red LED",
161
- "type": 1,
162
- "extendedType": null,
163
- "masterAddress": "192.168.0.97",
164
- "masterPort": 5001,
165
- "logicalNodeAddress": 3,
166
- "logicalAddress": 29
167
- },
168
- {
169
- "active": "Y",
170
- "used": "Y",
171
- "group": 0,
172
- "name": "Bulb",
173
- "displayName": "Bulb",
174
- "type": 2,
175
- "extendedType": 2,
176
- "masterAddress": "192.168.0.97",
177
- "masterPort": 5001,
178
- "logicalNodeAddress": 3,
179
- "logicalAddress": 35
180
- },
181
- {
182
- "active": "Y",
183
- "used": "Y",
184
- "group": 0,
185
- "name": "Lamp-Bottom",
186
- "displayName": "Lamp-Bottom",
187
- "type": 2,
188
- "extendedType": 2,
189
- "masterAddress": "192.168.0.97",
190
- "masterPort": 5001,
191
- "logicalNodeAddress": 3,
192
- "logicalAddress": 34
193
- },
194
- {
195
- "active": "Y",
196
- "used": "Y",
197
- "group": 0,
198
- "name": "Lamp-Top",
199
- "displayName": "Lamp-Top",
200
- "type": 2,
201
- "extendedType": 2,
202
- "masterAddress": "192.168.0.97",
203
- "masterPort": 5001,
204
- "logicalNodeAddress": 3,
205
- "logicalAddress": 33
206
- },
207
- {
208
- "active": "Y",
209
- "used": "Y",
210
- "group": 0,
211
- "name": "Stopcontact stk",
212
- "displayName": "Stopcontact stk",
213
- "type": 2,
214
- "extendedType": 2,
215
- "masterAddress": "192.168.0.97",
216
- "masterPort": 5001,
217
- "logicalNodeAddress": 3,
218
- "logicalAddress": 36
219
- },
220
- {
221
- "active": "Y",
222
- "used": "Y",
223
- "group": 0,
224
- "name": "Alles aan",
225
- "displayName": "Alles aan",
226
- "type": 7,
227
- "extendedType": 7,
228
- "masterAddress": "192.168.0.97",
229
- "masterPort": 5001,
230
- "logicalNodeAddress": 3,
231
- "logicalAddress": 5
232
- },
233
- {
234
- "active": "Y",
235
- "used": "Y",
236
- "group": 0,
237
- "name": "Alles uit",
238
- "displayName": "Alles uit",
239
- "type": 7,
240
- "extendedType": 7,
241
- "masterAddress": "192.168.0.97",
242
- "masterPort": 5001,
243
- "logicalNodeAddress": 3,
244
- "logicalAddress": 4
245
- }
246
- ]
247
- }