homebridge-smartsystem 6.2.5 → 6.3.1

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
@@ -274,6 +274,10 @@ Homebridge UI version
274
274
  - 3: fixed bug in Sanitizer of UnitConfig preventing from publishing units to homebridge
275
275
  - 4: fixed empty name bug in unit-def / new accessory()
276
276
  - 5: fixed bad displayNames in published units
277
+ - 6: power: 5% instead of 10% for power rules
278
+
279
+ ### v6.3.x - 23-09-2022 - Shelly PM release
280
+ - 1: first test 1 PM
277
281
 
278
282
 
279
283
  ## Hardware
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,13 +240,21 @@
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
  }
231
249
  ],
232
- "address": "192.168.0.214"
250
+ "address": "192.168.0.207"
251
+ },
252
+ "shelly": {
253
+ "address": "192.168.0.95",
254
+ "addresses": "192.168.0.95,192.168.0.95",
255
+ "rules": [],
256
+ "bindings": []
233
257
  },
234
- "shelly": false,
235
258
  "smartapp": {
236
259
  "apiPort": 8581,
237
260
  "apiHost": "192.168.0.99",
@@ -243,9 +266,11 @@
243
266
  "logicalAddress": 107,
244
267
  "masterAddress": "192.168.0.97",
245
268
  "masterPort": 5001,
269
+ "name": "Shelly Valies",
270
+ "displayName": "Shelly Valies",
271
+ "extendedType": 0,
246
272
  "nomacro": "Y",
247
273
  "nostop": "Y",
248
- "name": "Shelly Valies",
249
274
  "unitName": "Red",
250
275
  "value": 0,
251
276
  "data": "",
@@ -259,9 +284,11 @@
259
284
  "logicalAddress": 105,
260
285
  "masterAddress": "192.168.0.97",
261
286
  "masterPort": 5001,
287
+ "name": "Screen Salon Top",
288
+ "displayName": "Screen Salon Top",
289
+ "extendedType": 0,
262
290
  "nomacro": "N",
263
291
  "nostop": "N",
264
- "name": "Screen Salon Top",
265
292
  "unitName": "Salon Top",
266
293
  "value": 0,
267
294
  "data": "",
@@ -275,9 +302,11 @@
275
302
  "logicalAddress": 104,
276
303
  "masterAddress": "192.168.0.97",
277
304
  "masterPort": 5001,
305
+ "name": "Screen Tim small",
306
+ "displayName": "Screen Tim small",
307
+ "extendedType": 0,
278
308
  "nomacro": "N",
279
309
  "nostop": "Y",
280
- "name": "Screen Tim small",
281
310
  "unitName": "Tim Small",
282
311
  "value": 0,
283
312
  "data": "",
@@ -291,9 +320,11 @@
291
320
  "logicalAddress": 35,
292
321
  "masterAddress": "gm.coppieters.be",
293
322
  "masterPort": 5005,
323
+ "name": "Test Plug",
324
+ "displayName": "Test Plug",
325
+ "extendedType": 0,
294
326
  "nomacro": "N",
295
327
  "nostop": "N",
296
- "name": "Test Plug",
297
328
  "unitName": "Plug",
298
329
  "value": 0,
299
330
  "data": "",
@@ -307,14 +338,16 @@
307
338
  "logicalAddress": 34,
308
339
  "masterAddress": "192.168.0.97",
309
340
  "masterPort": 5001,
341
+ "name": "Demo",
342
+ "displayName": "Demo",
343
+ "extendedType": 0,
310
344
  "nomacro": "N",
311
345
  "nostop": "N",
312
- "name": "Demo",
313
- "unitName": "",
346
+ "unitName": "unit 3:34",
314
347
  "value": 0,
315
348
  "data": "b=2",
316
349
  "header": "{\"a\":101, \"b\": \"hallo\"}",
317
- "method": "GET",
350
+ "method": "PUT",
318
351
  "type": "http",
319
352
  "plug": "http://localhost:3001/api/demo/haha?set=#B"
320
353
  }
@@ -345,139 +378,16 @@
345
378
  }
346
379
  ],
347
380
  "cunits": [
348
- {
349
- "logicalNodeAddress": 252,
350
- "logicalAddress": 102,
351
- "masterAddress": "192.168.0.97",
352
- "masterPort": 5001,
353
- "active": "N",
354
- "used": "N",
355
- "group": 0
356
- },
357
- {
358
- "logicalNodeAddress": 252,
359
- "logicalAddress": 103,
360
- "masterAddress": "192.168.0.97",
361
- "masterPort": 5001,
362
- "active": "N",
363
- "used": "N",
364
- "group": 0
365
- },
366
- {
367
- "logicalNodeAddress": 252,
368
- "logicalAddress": 100,
369
- "masterAddress": "192.168.0.97",
370
- "masterPort": 5001,
371
- "active": "N",
372
- "used": "N",
373
- "group": 0
374
- },
375
- {
376
- "logicalNodeAddress": 252,
377
- "logicalAddress": 101,
378
- "masterAddress": "192.168.0.97",
379
- "masterPort": 5001,
380
- "active": "N",
381
- "used": "N",
382
- "group": 0
383
- },
384
- {
385
- "logicalNodeAddress": 252,
386
- "logicalAddress": 105,
387
- "masterAddress": "192.168.0.97",
388
- "masterPort": 5001,
389
- "active": "N",
390
- "used": "N",
391
- "group": 0
392
- },
393
- {
394
- "logicalNodeAddress": 252,
395
- "logicalAddress": 104,
396
- "masterAddress": "192.168.0.97",
397
- "masterPort": 5001,
398
- "active": "N",
399
- "used": "N",
400
- "group": 0
401
- },
402
- {
403
- "logicalNodeAddress": 252,
404
- "logicalAddress": 106,
405
- "masterAddress": "192.168.0.97",
406
- "masterPort": 5001,
407
- "active": "N",
408
- "used": "N",
409
- "group": 0
410
- },
411
381
  {
412
382
  "logicalNodeAddress": 3,
413
- "logicalAddress": 1,
414
- "masterAddress": "192.168.0.97",
415
- "masterPort": 5001,
416
- "active": "N",
417
- "used": "N",
418
- "group": 0
419
- },
420
- {
421
- "logicalNodeAddress": 3,
422
- "logicalAddress": 0,
423
- "masterAddress": "192.168.0.97",
424
- "masterPort": 5001,
425
- "active": "N",
426
- "used": "N",
427
- "group": 0
428
- },
429
- {
430
- "logicalNodeAddress": 3,
431
- "logicalAddress": 30,
432
- "masterAddress": "192.168.0.97",
433
- "masterPort": 5001,
434
- "active": "N",
435
- "used": "N",
436
- "group": 0
437
- },
438
- {
439
- "logicalNodeAddress": 3,
440
- "logicalAddress": 29,
441
- "masterAddress": "192.168.0.97",
442
- "masterPort": 5001,
443
- "active": "N",
444
- "used": "N",
445
- "group": 0
446
- },
447
- {
448
- "logicalNodeAddress": 3,
449
- "logicalAddress": 35,
450
- "masterAddress": "192.168.0.97",
451
- "masterPort": 5001,
452
- "active": "N",
453
- "used": "N",
454
- "group": 0
455
- },
456
- {
457
- "logicalNodeAddress": 3,
458
- "logicalAddress": 34,
459
- "masterAddress": "192.168.0.97",
460
- "masterPort": 5001,
461
- "active": "N",
462
- "used": "N",
463
- "group": 0
464
- },
465
- {
466
- "logicalNodeAddress": 3,
467
- "logicalAddress": 33,
468
- "masterAddress": "192.168.0.97",
469
- "masterPort": 5001,
470
- "active": "N",
471
- "used": "N",
472
- "group": 0
473
- },
474
- {
475
- "logicalNodeAddress": 3,
476
- "logicalAddress": 36,
383
+ "logicalAddress": 4,
477
384
  "masterAddress": "192.168.0.97",
478
385
  "masterPort": 5001,
479
- "active": "N",
480
- "used": "N",
386
+ "name": "All off",
387
+ "displayName": "Alles uitje",
388
+ "extendedType": 7,
389
+ "active": "Y",
390
+ "used": "Y",
481
391
  "group": 0
482
392
  },
483
393
  {
@@ -485,17 +395,11 @@
485
395
  "logicalAddress": 5,
486
396
  "masterAddress": "192.168.0.97",
487
397
  "masterPort": 5001,
488
- "active": "N",
489
- "used": "N",
490
- "group": 0
491
- },
492
- {
493
- "logicalNodeAddress": 3,
494
- "logicalAddress": 4,
495
- "masterAddress": "192.168.0.97",
496
- "masterPort": 5001,
497
- "active": "N",
498
- "used": "N",
398
+ "name": "All on",
399
+ "displayName": "Alles aantje",
400
+ "extendedType": 7,
401
+ "active": "Y",
402
+ "used": "Y",
499
403
  "group": 0
500
404
  }
501
405
  ]
@@ -515,5 +419,14 @@
515
419
  "units": []
516
420
  }
517
421
  ],
518
- "debug": false
422
+ "debug": false,
423
+ "settings": {
424
+ "network": {
425
+ "ip1": "1.2.3.4",
426
+ "gateway1": "1.2.3.1",
427
+ "nameservers": "8.8.8.8",
428
+ "ip2": "",
429
+ "gateway2": ""
430
+ }
431
+ }
519
432
  }
@@ -18,6 +18,7 @@ exports.logSettings = {
18
18
  "protocol": LogLevel.noLog,
19
19
  "webapp": LogLevel.log,
20
20
  "p1": LogLevel.log,
21
+ "shelly": LogLevel.debug,
21
22
  "power": LogLevel.log,
22
23
  "smartapp": LogLevel.log
23
24
  };
@@ -13,6 +13,7 @@ export const logSettings = {
13
13
  "protocol": LogLevel.noLog,
14
14
  "webapp": LogLevel.log,
15
15
  "p1": LogLevel.log,
16
+ "shelly": LogLevel.debug,
16
17
  "power": LogLevel.log,
17
18
  "smartapp": LogLevel.log
18
19
  };
@@ -466,6 +466,7 @@ class Master extends base_1.Base {
466
466
  receiveUnitInfo(message) {
467
467
  const unitInfo = protocol_1.Protocol.makeUnitInfo(message);
468
468
  let unit = this.findUnit(unitInfo.logicalNodeAddress, unitInfo.logicalAddress);
469
+ this.info("> received unit info: " + unitInfo.name + " (" + unitInfo.logicalNodeAddress + "," + unitInfo.logicalAddress + ") for unit: " + (unit === null || unit === void 0 ? void 0 : unit.name));
469
470
  if (!unit) {
470
471
  // find if in config
471
472
  const cunit = this.system.config.cunits.find(u => ((u.logicalNodeAddress == unitInfo.logicalNodeAddress) && (u.logicalAddress == unitInfo.logicalAddress)));
@@ -473,7 +474,6 @@ class Master extends base_1.Base {
473
474
  unitInfo.extendedType = cunit.extendedType;
474
475
  const node = this.findNode(unitInfo.logicalNodeAddress);
475
476
  if (node) {
476
- this.info("> received unit info: " + unitInfo.name + " (" + unitInfo.logicalNodeAddress + "," + unitInfo.logicalAddress + ")");
477
477
  unit = new protocol_1.Unit(node, unitInfo, this.system.config.mood);
478
478
  node.units.push(unit);
479
479
  }
@@ -520,6 +520,8 @@ export class Master extends Base {
520
520
 
521
521
  let unit = this.findUnit(unitInfo.logicalNodeAddress, unitInfo.logicalAddress);
522
522
 
523
+ this.info("> received unit info: " + unitInfo.name + " ("+unitInfo.logicalNodeAddress+","+unitInfo.logicalAddress+") for unit: " + unit?.name);
524
+
523
525
  if (!unit) {
524
526
  // find if in config
525
527
  const cunit = this.system.config.cunits.find(u => ((u.logicalNodeAddress == unitInfo.logicalNodeAddress) && (u.logicalAddress == unitInfo.logicalAddress)));
@@ -527,7 +529,6 @@ export class Master extends Base {
527
529
 
528
530
  const node = this.findNode(unitInfo.logicalNodeAddress);
529
531
  if (node) {
530
- this.info("> received unit info: " + unitInfo.name + " ("+unitInfo.logicalNodeAddress+","+unitInfo.logicalAddress+")");
531
532
  unit = new Unit(node, unitInfo, this.system.config.mood);
532
533
  node.units.push(unit);
533
534
  } else {
@@ -159,28 +159,33 @@ class System extends base_1.Base {
159
159
  this.writeConfig();
160
160
  }
161
161
  setActiveState(item) {
162
+ // for nodes
162
163
  if (item instanceof protocol_1.Node) {
163
164
  const masterAddress = item.master.getAddress();
164
165
  const masterPort = item.master.getPort();
166
+ // check if at least 1 unit is used
165
167
  const unitConfig = this.config.cunits.find((cu) => (cu.logicalNodeAddress === item.logicalAddress) &&
166
168
  (cu.masterAddress === masterAddress) &&
167
169
  (cu.masterPort == masterPort));
168
- // there exists an active unit of this node
170
+ // if there is: set active to true of this node
169
171
  item.active = !!unitConfig;
170
172
  }
173
+ // for units
171
174
  if (item instanceof protocol_1.Unit) {
172
175
  const masterAddress = item.node.master.getAddress();
173
176
  const masterPort = item.node.master.getPort();
177
+ // see if there is a config record for this unit
174
178
  const unitConfig = this.config.cunits.find((cu) => (cu.logicalAddress === item.logicalAddress) &&
175
179
  (cu.logicalNodeAddress === item.logicalNodeAddress) &&
176
180
  (cu.masterAddress === masterAddress) &&
177
181
  (cu.masterPort == masterPort));
178
- ;
182
+ // if there is: copy active, used, displayName and group
179
183
  if (unitConfig) {
180
184
  item.active = (unitConfig.active === "Y");
181
185
  item.used = (unitConfig.used === "Y");
182
186
  item.displayName = unitConfig.displayName || unitConfig.name;
183
187
  item.group = unitConfig.group;
188
+ (0, logger_1.log)("system", "System.setActiveState(unit) -> config name: " + unitConfig.name + ", item name: " + item.name);
184
189
  }
185
190
  else {
186
191
  item.active = false;
@@ -166,31 +166,40 @@ export class System extends Base {
166
166
  }
167
167
 
168
168
  setActiveState(item: Node | Unit) {
169
+ // for nodes
169
170
  if (item instanceof Node) {
170
171
  const masterAddress = item.master.getAddress();
171
172
  const masterPort = item.master.getPort();
173
+
174
+ // check if at least 1 unit is used
172
175
  const unitConfig = this.config.cunits.find((cu: UnitConfig) =>
173
176
  (cu.logicalNodeAddress === item.logicalAddress) &&
174
177
  (cu.masterAddress === masterAddress) &&
175
178
  (cu.masterPort == masterPort));
176
179
 
177
- // there exists an active unit of this node
180
+ // if there is: set active to true of this node
178
181
  item.active = !! unitConfig;
179
182
  }
183
+
184
+ // for units
180
185
  if (item instanceof Unit) {
181
186
  const masterAddress = item.node.master.getAddress();
182
187
  const masterPort = item.node.master.getPort();
188
+
189
+ // see if there is a config record for this unit
183
190
  const unitConfig = this.config.cunits.find((cu: UnitConfig) =>
184
191
  (cu.logicalAddress === item.logicalAddress) &&
185
192
  (cu.logicalNodeAddress === item.logicalNodeAddress) &&
186
193
  (cu.masterAddress === masterAddress) &&
187
194
  (cu.masterPort == masterPort));
188
- ;
195
+
196
+ // if there is: copy active, used, displayName and group
189
197
  if (unitConfig) {
190
198
  item.active = (unitConfig.active === "Y");
191
199
  item.used = (unitConfig.used === "Y");
192
200
  item.displayName = unitConfig.displayName || unitConfig.name;
193
201
  item.group = unitConfig.group;
202
+ log("system", "System.setActiveState(unit) -> config name: " + unitConfig.name + ", item name: " + item.name);
194
203
  } else {
195
204
  item.active = false;
196
205
  }
package/duotecno/types.js CHANGED
@@ -273,8 +273,9 @@ exports.Sanitizers = {
273
273
  return config;
274
274
  },
275
275
  shelly: function (config) {
276
- config = exports.Sanitizers.powerbase(config);
277
- return config;
276
+ const cfg = exports.Sanitizers.powerbase(config);
277
+ cfg.addresses = (config === null || config === void 0 ? void 0 : config.addresses) || "";
278
+ return cfg;
278
279
  },
279
280
  switchConfig: function (aSwitch) {
280
281
  const sw = exports.Sanitizers.unitDef(aSwitch);
package/duotecno/types.ts CHANGED
@@ -273,6 +273,7 @@ export interface SmappeeConfig extends PowerBaseConfig {
273
273
  export interface P1Config extends PowerBaseConfig {
274
274
  }
275
275
  export interface ShellyConfig extends PowerBaseConfig {
276
+ addresses: string;
276
277
  }
277
278
 
278
279
  ////////////////
@@ -453,9 +454,9 @@ export const Sanitizers = {
453
454
  return config;
454
455
  },
455
456
  shelly: function(config: ShellyConfig): ShellyConfig {
456
- config = Sanitizers.powerbase(config);
457
-
458
- return config;
457
+ const cfg = <ShellyConfig> Sanitizers.powerbase(config);
458
+ cfg.addresses = config?.addresses || "";
459
+ return cfg;
459
460
  },
460
461
 
461
462
  switchConfig: function(aSwitch): Switch {
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.5",
4
+ "version": "6.3.1",
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",