homebridge-smartsystem 5.14.1 → 6.0.0

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.
@@ -213,7 +213,7 @@ class Master extends base_1.Base {
213
213
  }
214
214
  try {
215
215
  // params 3-6: data message, closed, log and error functions
216
- this.socket = yield smartsocket_1.getSocket(this.config.address, this.config.port, (msg) => {
216
+ this.socket = yield (0, smartsocket_1.getSocket)(this.config.address, this.config.port, (msg) => {
217
217
  this.handleData(msg);
218
218
  }, (end) => {
219
219
  this.isOpen = false;
@@ -354,7 +354,7 @@ class Master extends base_1.Base {
354
354
  else {
355
355
  if ((next.cmd != protocol_1.Rec.TimeDateStatus) &&
356
356
  (next.cmd != protocol_1.Rec.Sensor))
357
- this.info(protocol_1.recName(next.cmd) + " -> " + ((!next.message) ?
357
+ this.info((0, protocol_1.recName)(next.cmd) + " -> " + ((!next.message) ?
358
358
  "--" : ((next.message instanceof Array) ? next.message.join(",") : next.message)));
359
359
  this.Q.do();
360
360
  if (next.isStatus) {
@@ -125,7 +125,7 @@ class Node {
125
125
  return this.getName().toLowerCase();
126
126
  }
127
127
  getNumber() {
128
- return types_1.hex(this.logicalAddress);
128
+ return (0, types_1.hex)(this.logicalAddress);
129
129
  }
130
130
  getDescription() {
131
131
  return this.getName() + ", active: " + this.active + ", type: " + this.typeName() + ", node: " + this.getName();
@@ -218,7 +218,7 @@ class Unit {
218
218
  return this.displayName;
219
219
  }
220
220
  getNumber() {
221
- return this.node.getNumber() + ";" + types_1.hex(this.logicalAddress);
221
+ return this.node.getNumber() + ";" + (0, types_1.hex)(this.logicalAddress);
222
222
  }
223
223
  getSort() {
224
224
  const name = this.getName().toLowerCase();
@@ -322,7 +322,7 @@ class Unit {
322
322
  return "N" + this.logicalNodeAddress + "-U" + this.logicalAddress;
323
323
  }
324
324
  getModelName() {
325
- return this.typeName() + " " + types_1.hex(this.node.logicalAddress) + ";" + types_1.hex(this.logicalAddress);
325
+ return this.typeName() + " " + (0, types_1.hex)(this.node.logicalAddress) + ";" + (0, types_1.hex)(this.logicalAddress);
326
326
  }
327
327
  isCtrl() {
328
328
  return this.isSwitch() || this.isDimmer() || this.isUpDown();
@@ -402,7 +402,7 @@ class Unit {
402
402
  return (isNaN(aval) ? "-" :
403
403
  ((aval < 10000) ?
404
404
  (aval + " W") :
405
- (Math.round(aval / 1000) + "." + types_1.two(Math.round(aval % 1000 / 100)) + " kW")));
405
+ (Math.round(aval / 1000) + "." + (0, types_1.two)(Math.round(aval % 1000 / 100)) + " kW")));
406
406
  case types_1.UnitExtendedType.kTemperature:
407
407
  return isNaN(this.value) ? "-" : ((this.value / 10.0) + 'C');
408
408
  case types_1.UnitExtendedType.kCondition:
package/index.spec.js CHANGED
@@ -12,7 +12,7 @@ function adder(plugin, platform, list) {
12
12
  console.log("************* plugin: " + plugin + ", platform: " + platform, list);
13
13
  }
14
14
  function tester() {
15
- const platform = new platform_1.Platform(console.log, { debug: false, smappee: true, smartapp: true, socapp: false, system: true,
15
+ const platform = new platform_1.Platform(console, { debug: false, smappee: true, smartapp: true, socapp: false, system: true,
16
16
  manufacturer: "Duotecno", platform: "ssoc" }, { registerPlatformAccessories: adder });
17
17
  // testing
18
18
  let m = new master_1.Master(platform.system, types_1.Sanitizers.masterConfig({ name: "master1", address: "12", port: 21, password: "x", active: true, nodenames: {} }));
package/index.spec.ts CHANGED
@@ -13,7 +13,7 @@ function adder(plugin: string, platform: string, list: any[]) {
13
13
  }
14
14
 
15
15
  function tester() {
16
- const platform = new Platform(console.log, {debug: false, smappee: true, smartapp: true, socapp: false, system: true,
16
+ const platform = new Platform(console, {debug: false, smappee: true, smartapp: true, socapp: false, system: true,
17
17
  manufacturer: "Duotecno", platform: "ssoc"}, {registerPlatformAccessories: adder});
18
18
 
19
19
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
- "displayname": "Duotechno Bridge",
4
- "version": "5.14.1",
3
+ "displayname": "Duotecno Bridge",
4
+ "version": "6.0.0",
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",
@@ -12,8 +12,8 @@
12
12
  "watch": "npx tsc --build . --watch"
13
13
  },
14
14
  "engines": {
15
- "node": ">=8.0.0",
16
- "homebridge": ">=0.4.0"
15
+ "node": ">=14.18.1",
16
+ "homebridge": ">=1.3.5"
17
17
  },
18
18
  "keywords": [
19
19
  "websockets",
@@ -34,12 +34,13 @@
34
34
  "mqtt": "^4.3.7",
35
35
  "node-fetch": "^3.2.4",
36
36
  "rpi-gpio": "^2.1.7",
37
- "typescript": "^4.0.5",
38
37
  "ws": "^7.4.6"
39
38
  },
40
39
  "devDependencies": {
41
40
  "@types/mime-types": "^2.1.0",
42
- "@types/node": "^11.15.3",
43
- "@types/ws": "^6.0.4"
41
+ "@types/node": "^16.10.9",
42
+ "@types/ws": "^6.0.4",
43
+ "typescript": "^4.7.4",
44
+ "homebridge": "^1.3.9"
44
45
  }
45
46
  }
package/server/base.js CHANGED
@@ -30,7 +30,7 @@ class Base {
30
30
  this.logger("[" + this.type + "] " + msg);
31
31
  }
32
32
  err(msg) {
33
- this.logger("[" + this.type + "] *** " + types_1.now() + " *** " + msg + " ***");
33
+ this.logger("[" + this.type + "] *** " + (0, types_1.now)() + " *** " + msg + " ***");
34
34
  }
35
35
  //////////////////
36
36
  // Config stuff //
@@ -28,25 +28,25 @@ const lock_1 = require("../accessories/lock");
28
28
  class Platform extends base_1.Base {
29
29
  constructor(log, config, homebridge) {
30
30
  // set debug to true for new config files
31
- super("homebridge", log);
31
+ super("homebridge", log.info);
32
32
  this.accessoryList = [];
33
33
  this.ready = false;
34
34
  this.startWaiting = 0;
35
35
  this.config = Object.assign({}, config);
36
36
  this.config.debug = (config && ("debug" in config)) ? config.debug : false;
37
- log("running in directory: " + process.cwd());
38
- log("with config:" + JSON.stringify(config, null, 2));
37
+ this.log("running in directory: " + process.cwd());
38
+ this.log("with config:" + JSON.stringify(config, null, 2));
39
39
  // log("homebridge object:", homebridge);
40
40
  this.homebridge = homebridge;
41
41
  if (this.config.system) {
42
42
  try {
43
- this.system = new system_1.System(log, false);
43
+ this.system = new system_1.System(this.log, false);
44
44
  this.system.openMasters(true);
45
45
  this.system.emitter.on('ready', this.systemReady.bind(this));
46
46
  this.system.emitter.on('update', this.updateState.bind(this));
47
47
  }
48
48
  catch (err) {
49
- log(err);
49
+ log.error(err);
50
50
  if (!this.system) {
51
51
  this.log("platform - Can't run without a System.");
52
52
  return;
@@ -60,7 +60,7 @@ class Platform extends base_1.Base {
60
60
  // startup a Smappee MQTT subscriber, if one is configured
61
61
  if (this.config.smappee) {
62
62
  try {
63
- this.smappee = new smappee_1.Smappee(this.system, log);
63
+ this.smappee = new smappee_1.Smappee(this.system, this.log);
64
64
  }
65
65
  catch (err) {
66
66
  this.log(err);
@@ -75,7 +75,7 @@ class Platform extends base_1.Base {
75
75
  // startup a smartApp if configured -> only on Raspberry's
76
76
  if (this.config.smartapp) {
77
77
  try {
78
- this.smartapp = new smartapp_1.SmartApp(this.system, this.smappee, this, log, false);
78
+ this.smartapp = new smartapp_1.SmartApp(this.system, this.smappee, this, this.log, false);
79
79
  this.smartapp.serve();
80
80
  }
81
81
  catch (err) {
@@ -92,7 +92,7 @@ class Platform extends base_1.Base {
92
92
  if (this.config.socapp) {
93
93
  try {
94
94
  // reuse the config file from the smartapp
95
- this.smartsoc = new socapp_1.SocApp(this.system, 'smartapp', log);
95
+ this.smartsoc = new socapp_1.SocApp(this.system, 'smartapp', this.log);
96
96
  this.smartsoc.serve();
97
97
  }
98
98
  catch (err) {
@@ -1,4 +1,5 @@
1
1
  import { LogFunction, PlatformConfig, UnitExtendedType } from "../duotecno/types";
2
+ import { Logger } from "homebridge";
2
3
  import { System } from "../duotecno/system";
3
4
  import { Smappee } from "./smappee";
4
5
  import { SmartApp } from "./smartapp";
@@ -27,30 +28,31 @@ export class Platform extends Base {
27
28
  accessoryList: Array<Accessory> = [];
28
29
  ready = false;
29
30
  startWaiting = 0;
31
+ log: LogFunction;
30
32
 
31
- constructor(log: LogFunction, config: PlatformConfig, homebridge) {
33
+ constructor(log: Logger, config: PlatformConfig, homebridge) {
32
34
  // set debug to true for new config files
33
- super("homebridge", log);
35
+ super("homebridge", log.info);
34
36
 
35
37
  this.config = {... config};
36
38
  this.config.debug = (config && ("debug" in config)) ? config.debug : false;
37
39
 
38
- log("running in directory: " + process.cwd());
39
- log("with config:" + JSON.stringify(config, null, 2));
40
+ this.log("running in directory: " + process.cwd());
41
+ this.log("with config:" + JSON.stringify(config, null, 2));
40
42
  // log("homebridge object:", homebridge);
41
43
 
42
44
  this.homebridge = homebridge;
43
45
 
44
46
  if (this.config.system) {
45
47
  try {
46
- this.system = new System(log, false);
48
+ this.system = new System(this.log, false);
47
49
  this.system.openMasters(true);
48
50
 
49
51
  this.system.emitter.on('ready', this.systemReady.bind(this));
50
52
  this.system.emitter.on('update', this.updateState.bind(this));
51
53
 
52
54
  } catch(err) {
53
- log(err);
55
+ log.error(err);
54
56
  if (!this.system) {
55
57
  this.log("platform - Can't run without a System.");
56
58
  return;
@@ -64,7 +66,7 @@ export class Platform extends Base {
64
66
  // startup a Smappee MQTT subscriber, if one is configured
65
67
  if (this.config.smappee) {
66
68
  try {
67
- this.smappee = new Smappee(this.system, log);
69
+ this.smappee = new Smappee(this.system, this.log);
68
70
 
69
71
  } catch(err) {
70
72
  this.log(err);
@@ -79,7 +81,7 @@ export class Platform extends Base {
79
81
  // startup a smartApp if configured -> only on Raspberry's
80
82
  if (this.config.smartapp) {
81
83
  try {
82
- this.smartapp = new SmartApp(this.system, this.smappee, this, log, false);
84
+ this.smartapp = new SmartApp(this.system, this.smappee, this, this.log, false);
83
85
  this.smartapp.serve();
84
86
 
85
87
  } catch(err) {
@@ -96,7 +98,7 @@ export class Platform extends Base {
96
98
  if (this.config.socapp) {
97
99
  try {
98
100
  // reuse the config file from the smartapp
99
- this.smartsoc = new SocApp(this.system, 'smartapp', log);
101
+ this.smartsoc = new SocApp(this.system, 'smartapp', this.log);
100
102
  this.smartsoc.serve();
101
103
 
102
104
  } catch(err) {
@@ -53,7 +53,7 @@ const kAccessoryPins = {
53
53
  "577-03-010": "CC:22:3D:E3:A1:0A"
54
54
  };
55
55
  // Mac file system -> write locally
56
- const isMac = fs_1.existsSync("/Volumes");
56
+ const isMac = (0, fs_1.existsSync)("/Volumes");
57
57
  const kDHCPConfigFile = isMac ? "./config.dhcpcd" : "/etc/dhcpcd.conf";
58
58
  var ContentType;
59
59
  (function (ContentType) {
@@ -187,7 +187,7 @@ class SmartApp extends webapp_1.WebApp {
187
187
  let unit = null;
188
188
  let logicalNodeAddress, logicalAddress;
189
189
  let name = context.getParam({ name: "unit" + boundary, type: "string", default: "--" });
190
- const value = types_1.actionValue(context.getParam({ name: "value" + boundary, type: "string", default: "0" }));
190
+ const value = (0, types_1.actionValue)(context.getParam({ name: "value" + boundary, type: "string", default: "0" }));
191
191
  // hex addresses or name
192
192
  if ((name[0] === "0") && (name[1] === "x")) {
193
193
  ({ logicalNodeAddress, logicalAddress } = context.addr(name));
@@ -245,7 +245,7 @@ class SmartApp extends webapp_1.WebApp {
245
245
  writeDHCP(context, config) {
246
246
  try {
247
247
  this.resetDHCP(context);
248
- fs_1.writeFileSync(kDHCPConfigFile, this.DHCPdFile(config.network));
248
+ (0, fs_1.writeFileSync)(kDHCPConfigFile, this.DHCPdFile(config.network));
249
249
  }
250
250
  catch (err) {
251
251
  context.message = JSON.stringify(err);
@@ -253,8 +253,8 @@ class SmartApp extends webapp_1.WebApp {
253
253
  }
254
254
  resetDHCP(context) {
255
255
  try {
256
- if (fs_1.existsSync(kDHCPConfigFile))
257
- fs_1.truncateSync(kDHCPConfigFile);
256
+ if ((0, fs_1.existsSync)(kDHCPConfigFile))
257
+ (0, fs_1.truncateSync)(kDHCPConfigFile);
258
258
  }
259
259
  catch (err) {
260
260
  context.message = JSON.stringify(err);
@@ -283,7 +283,7 @@ class SmartApp extends webapp_1.WebApp {
283
283
  doRequest: { get: () => super.doRequest }
284
284
  });
285
285
  return __awaiter(this, void 0, void 0, function* () {
286
- const kDir = os_1.homedir() + "/.homebridge/";
286
+ const kDir = (0, os_1.homedir)() + "/.homebridge/";
287
287
  const kFN = kDir + "config.json";
288
288
  let message;
289
289
  let config;
@@ -297,8 +297,8 @@ class SmartApp extends webapp_1.WebApp {
297
297
  }
298
298
  else if (context.action === "save") {
299
299
  const bridge = this.scrapePlatformConfig(context);
300
- if (!fs_1.existsSync(kDir))
301
- fs_1.mkdirSync(kDir);
300
+ if (!(0, fs_1.existsSync)(kDir))
301
+ (0, fs_1.mkdirSync)(kDir);
302
302
  config = this.read("homebridge", kFN);
303
303
  config.bridge = bridge;
304
304
  this.log("writing config");
@@ -424,7 +424,7 @@ class SmartApp extends webapp_1.WebApp {
424
424
  swtch.status = swtch.unit.status;
425
425
  }
426
426
  else {
427
- this.log("** error ** missing unit: " + types_1.hex(swtch.logicalNodeAddress) + "/" + types_1.hex(swtch.logicalAddress) + " **");
427
+ this.log("** error ** missing unit: " + (0, types_1.hex)(swtch.logicalNodeAddress) + "/" + (0, types_1.hex)(swtch.logicalAddress) + " **");
428
428
  }
429
429
  }
430
430
  });
package/server/somfy.js CHANGED
@@ -36,7 +36,7 @@ function setlogger(logF) {
36
36
  }
37
37
  exports.setlogger = setlogger;
38
38
  function myLogger(msg) {
39
- console.log("[" + types_1.now() + "] [somfy] " + msg);
39
+ console.log("[" + (0, types_1.now)() + "] [somfy] " + msg);
40
40
  }
41
41
  function mS(nr) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -75,7 +75,8 @@ function toggle(pin) {
75
75
  }
76
76
  function selected(screen) {
77
77
  return __awaiter(this, void 0, void 0, function* () {
78
- const screens = [false, !(yield gpio.read(sScreen1)),
78
+ const screens = [false,
79
+ !(yield gpio.read(sScreen1)),
79
80
  !(yield gpio.read(sScreen2)),
80
81
  !(yield gpio.read(sScreen3)),
81
82
  !(yield gpio.read(sScreen4))];
package/server/webapp.js CHANGED
@@ -215,7 +215,7 @@ class WebApp extends base_1.Base {
215
215
  this.server.listen(this.port, onConnected);
216
216
  }
217
217
  addFile(name, filename, type, enc) {
218
- this.addContent(name, fs.readFileSync(filename, enc || 'utf-8'), type || "text/html", filename);
218
+ this.addContent(name, fs.readFileSync(filename, { encoding: enc || 'utf-8' }), type || "text/html", filename);
219
219
  }
220
220
  addContent(name, content, type, filename) {
221
221
  this.files[name] = { content, type, filename };
@@ -322,7 +322,7 @@ class WebApp extends base_1.Base {
322
322
  // 2) add file to sudo
323
323
  // sudo /etc/sudoers.d/mysudoersfile
324
324
  return new Promise((resolve, reject) => {
325
- child_process_1.exec("sudo shutdown -r now", (error, stdout, stderr) => {
325
+ (0, child_process_1.exec)("sudo shutdown -r now", (error, stdout, stderr) => {
326
326
  if (error) {
327
327
  // context.message = stderr;
328
328
  // console.log("error shutting down: ", error, stdout, stderr);
package/server/webapp.ts CHANGED
@@ -269,8 +269,8 @@ export class WebApp extends Base {
269
269
  this.server.listen(this.port, onConnected);
270
270
  }
271
271
 
272
- addFile(name: string, filename: string, type?: string, enc?: string) {
273
- this.addContent(name, fs.readFileSync(filename, enc || 'utf-8'), type || "text/html", filename);
272
+ addFile(name: string, filename: string, type?: string, enc?: BufferEncoding) {
273
+ this.addContent(name, fs.readFileSync(filename, {encoding: enc || 'utf-8'}), type || "text/html", filename);
274
274
  }
275
275
  addContent(name: string, content: string, type: string, filename: string) {
276
276
  this.files[name] = { content, type, filename };