homebridge-smartsystem 6.0.1 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.0.1",
4
+ "version": "6.0.4",
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",
package/server/base.js CHANGED
@@ -10,7 +10,7 @@ const types_1 = require("../duotecno/types");
10
10
  class Base {
11
11
  constructor(type, logger, config) {
12
12
  this.type = type || "base";
13
- this.logger = logger || console.log;
13
+ this.logger = console.log; // logger || console.log;
14
14
  if (config)
15
15
  this.config = config;
16
16
  else
@@ -43,7 +43,7 @@ class Base {
43
43
  this.write(this.type, this.config);
44
44
  }
45
45
  read(type, fname = "") {
46
- const fn = fname || (__dirname + 'config.' + type + '.json');
46
+ const fn = fname || (__dirname + '/../config.' + type + '.json');
47
47
  let config = null;
48
48
  try {
49
49
  const configBuf = fs.readFileSync(fn);
@@ -61,7 +61,7 @@ class Base {
61
61
  return temp;
62
62
  }
63
63
  write(type, config, fname = "") {
64
- const fn = fname || ('./config.' + type + '.json');
64
+ const fn = fname || (__dirname + '/../config.' + type + '.json');
65
65
  try {
66
66
  config = types_1.Sanitizers[type](config);
67
67
  fs.writeFileSync(fn, JSON.stringify(config, null, 2));
package/server/base.ts CHANGED
@@ -15,7 +15,7 @@ export class Base {
15
15
 
16
16
  constructor(type: string, logger?: LogFunction, config?) {
17
17
  this.type = type || "base";
18
- this.logger = logger || console.log;
18
+ this.logger = console.log // logger || console.log;
19
19
 
20
20
  if (config)
21
21
  this.config = config;
@@ -57,7 +57,7 @@ export class Base {
57
57
 
58
58
 
59
59
  read(type: string, fname: string = "") {
60
- const fn = fname || (__dirname + 'config.' + type + '.json');
60
+ const fn = fname || (__dirname + '/../config.' + type + '.json');
61
61
  let config = null;
62
62
 
63
63
  try {
@@ -78,7 +78,7 @@ export class Base {
78
78
  }
79
79
 
80
80
  write(type: string, config, fname: string = "") {
81
- const fn = fname || ('./config.' + type + '.json');
81
+ const fn = fname || (__dirname + '/../config.' + type + '.json');
82
82
  try {
83
83
  config = Sanitizers[type](config);
84
84
  fs.writeFileSync(fn, JSON.stringify(config, null, 2));
@@ -36,17 +36,17 @@ class Platform extends base_1.Base {
36
36
  this.config.debug = (config && ("debug" in config)) ? config.debug : false;
37
37
  this.log("running in directory: " + process.cwd());
38
38
  this.log("with config:" + JSON.stringify(config, null, 2));
39
- // this.log("homebridge object:", homebridge);
39
+ // this.log("homebridge object:", api);
40
40
  this.homebridgeAPI = api;
41
41
  if (this.config.system) {
42
42
  try {
43
- this.system = new system_1.System(this.log, false);
43
+ this.system = new system_1.System(log.info, 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.error(err);
49
+ this.log(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, this.log);
63
+ this.smappee = new smappee_1.Smappee(this.system, log.info);
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, this.log, false);
78
+ this.smartapp = new smartapp_1.SmartApp(this.system, this.smappee, this, log.info, 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', this.log);
95
+ this.smartsoc = new socapp_1.SocApp(this.system, 'smartapp', log.info);
96
96
  this.smartsoc.serve();
97
97
  }
98
98
  catch (err) {
@@ -28,7 +28,6 @@ export class Platform extends Base {
28
28
  accessoryList: Array<Accessory> = [];
29
29
  ready = false;
30
30
  startWaiting = 0;
31
- log: LogFunction;
32
31
 
33
32
  constructor(log: Logger, config: PlatformConfig, api: API) {
34
33
  // set debug to true for new config files
@@ -39,20 +38,20 @@ export class Platform extends Base {
39
38
 
40
39
  this.log("running in directory: " + process.cwd());
41
40
  this.log("with config:" + JSON.stringify(config, null, 2));
42
- // this.log("homebridge object:", homebridge);
41
+ // this.log("homebridge object:", api);
43
42
 
44
43
  this.homebridgeAPI = api;
45
44
 
46
45
  if (this.config.system) {
47
46
  try {
48
- this.system = new System(this.log, false);
47
+ this.system = new System(log.info, false);
49
48
  this.system.openMasters(true);
50
49
 
51
50
  this.system.emitter.on('ready', this.systemReady.bind(this));
52
51
  this.system.emitter.on('update', this.updateState.bind(this));
53
52
 
54
53
  } catch(err) {
55
- log.error(err);
54
+ this.log(err);
56
55
  if (!this.system) {
57
56
  this.log("platform - Can't run without a System.");
58
57
  return;
@@ -66,7 +65,7 @@ export class Platform extends Base {
66
65
  // startup a Smappee MQTT subscriber, if one is configured
67
66
  if (this.config.smappee) {
68
67
  try {
69
- this.smappee = new Smappee(this.system, this.log);
68
+ this.smappee = new Smappee(this.system, log.info);
70
69
 
71
70
  } catch(err) {
72
71
  this.log(err);
@@ -81,7 +80,7 @@ export class Platform extends Base {
81
80
  // startup a smartApp if configured -> only on Raspberry's
82
81
  if (this.config.smartapp) {
83
82
  try {
84
- this.smartapp = new SmartApp(this.system, this.smappee, this, this.log, false);
83
+ this.smartapp = new SmartApp(this.system, this.smappee, this, log.info, false);
85
84
  this.smartapp.serve();
86
85
 
87
86
  } catch(err) {
@@ -98,7 +97,7 @@ export class Platform extends Base {
98
97
  if (this.config.socapp) {
99
98
  try {
100
99
  // reuse the config file from the smartapp
101
- this.smartsoc = new SocApp(this.system, 'smartapp', this.log);
100
+ this.smartsoc = new SocApp(this.system, 'smartapp', log.info);
102
101
  this.smartsoc.serve();
103
102
 
104
103
  } catch(err) {
@@ -76,21 +76,21 @@ class SmartApp extends webapp_1.WebApp {
76
76
  this.platform = platform;
77
77
  // when all masters are loaded -> attach units to the switches
78
78
  this.system.emitter.on('ready', this.initSwitchUnits.bind(this));
79
- this.addFile("unitList", "./server/views/unit-list.ejs", "application/json");
80
- this.addFile("masterList", "./server/views/master-list.ejs", "text/html");
81
- this.addFile("masterDetail", "./server/views/master-detail.ejs", "text/html");
82
- this.addFile("nodeDetail", "./server/views/node-details.ejs", "text/html");
83
- this.addFile("serviceList", "./server/views/service-list.ejs", "text/html");
84
- this.addFile("smappee", "./server/views/smappee.ejs", "text/html");
85
- this.addFile("homekit", "./server/views/homekit.ejs", "text/html");
86
- this.addFile("settings", "./server/views/settings.ejs", "text/html");
87
- this.addFile("switchDetail", "./server/views/switch-details.ejs", "text/html");
88
- this.addFile("switchList", "./server/views/switch-list.ejs", "text/html");
89
- this.addFile("smappeeRule", "./server/views/smappee-rule.ejs", "text/html");
90
- this.addFile("smappeeBinding", "./server/views/smappee-binding.ejs", "text/html");
91
- this.addFile("materializeCSS", "./server/views/assets/materialize.min.css", "text/css");
92
- this.addFile("materializeJS", "./server/views/assets/materialize.min.js", "text/javascript");
93
- this.addFile("favicon", "./server/views/assets/favicon.ico", "image/x-icon");
79
+ this.addFile("unitList", __dirname + "/views/unit-list.ejs", "application/json");
80
+ this.addFile("masterList", __dirname + "/views/master-list.ejs", "text/html");
81
+ this.addFile("masterDetail", __dirname + "/views/master-detail.ejs", "text/html");
82
+ this.addFile("nodeDetail", __dirname + "/views/node-details.ejs", "text/html");
83
+ this.addFile("serviceList", __dirname + "/views/service-list.ejs", "text/html");
84
+ this.addFile("smappee", __dirname + "/views/smappee.ejs", "text/html");
85
+ this.addFile("homekit", __dirname + "/views/homekit.ejs", "text/html");
86
+ this.addFile("settings", __dirname + "/views/settings.ejs", "text/html");
87
+ this.addFile("switchDetail", __dirname + "/views/switch-details.ejs", "text/html");
88
+ this.addFile("switchList", __dirname + "/views/switch-list.ejs", "text/html");
89
+ this.addFile("smappeeRule", __dirname + "/views/smappee-rule.ejs", "text/html");
90
+ this.addFile("smappeeBinding", __dirname + "/views/smappee-binding.ejs", "text/html");
91
+ this.addFile("materializeCSS", __dirname + "/views/assets/materialize.min.css", "text/css");
92
+ this.addFile("materializeJS", __dirname + "/views/assets/materialize.min.js", "text/javascript");
93
+ this.addFile("favicon", __dirname + "/views/assets/favicon.ico", "image/x-icon");
94
94
  }
95
95
  writeConfig() {
96
96
  // copy switches into config, eliminate the runtime stuff (like unit)
@@ -85,21 +85,21 @@ export class SmartApp extends WebApp {
85
85
  // when all masters are loaded -> attach units to the switches
86
86
  this.system.emitter.on('ready', this.initSwitchUnits.bind(this));
87
87
 
88
- this.addFile("unitList", "./server/views/unit-list.ejs", "application/json");
89
- this.addFile("masterList", "./server/views/master-list.ejs", "text/html");
90
- this.addFile("masterDetail", "./server/views/master-detail.ejs", "text/html");
91
- this.addFile("nodeDetail", "./server/views/node-details.ejs", "text/html");
92
- this.addFile("serviceList", "./server/views/service-list.ejs", "text/html");
93
- this.addFile("smappee", "./server/views/smappee.ejs", "text/html");
94
- this.addFile("homekit", "./server/views/homekit.ejs", "text/html");
95
- this.addFile("settings", "./server/views/settings.ejs", "text/html");
96
- this.addFile("switchDetail", "./server/views/switch-details.ejs", "text/html");
97
- this.addFile("switchList", "./server/views/switch-list.ejs", "text/html");
98
- this.addFile("smappeeRule", "./server/views/smappee-rule.ejs", "text/html");
99
- this.addFile("smappeeBinding", "./server/views/smappee-binding.ejs", "text/html");
100
- this.addFile("materializeCSS", "./server/views/assets/materialize.min.css", "text/css");
101
- this.addFile("materializeJS", "./server/views/assets/materialize.min.js", "text/javascript");
102
- this.addFile("favicon", "./server/views/assets/favicon.ico", "image/x-icon");
88
+ this.addFile("unitList", __dirname + "/views/unit-list.ejs", "application/json");
89
+ this.addFile("masterList", __dirname + "/views/master-list.ejs", "text/html");
90
+ this.addFile("masterDetail", __dirname + "/views/master-detail.ejs", "text/html");
91
+ this.addFile("nodeDetail", __dirname + "/views/node-details.ejs", "text/html");
92
+ this.addFile("serviceList", __dirname + "/views/service-list.ejs", "text/html");
93
+ this.addFile("smappee", __dirname + "/views/smappee.ejs", "text/html");
94
+ this.addFile("homekit", __dirname + "/views/homekit.ejs", "text/html");
95
+ this.addFile("settings", __dirname + "/views/settings.ejs", "text/html");
96
+ this.addFile("switchDetail", __dirname + "/views/switch-details.ejs", "text/html");
97
+ this.addFile("switchList", __dirname + "/views/switch-list.ejs", "text/html");
98
+ this.addFile("smappeeRule", __dirname + "/views/smappee-rule.ejs", "text/html");
99
+ this.addFile("smappeeBinding", __dirname + "/views/smappee-binding.ejs", "text/html");
100
+ this.addFile("materializeCSS", __dirname + "/views/assets/materialize.min.css", "text/css");
101
+ this.addFile("materializeJS", __dirname + "/views/assets/materialize.min.js", "text/javascript");
102
+ this.addFile("favicon", __dirname + "/views/assets/favicon.ico", "image/x-icon");
103
103
  }
104
104
 
105
105
  writeConfig() {