homebridge-smartsystem 6.3.1 → 6.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -278,6 +278,7 @@ Homebridge UI version
278
278
 
279
279
  ### v6.3.x - 23-09-2022 - Shelly PM release
280
280
  - 1: first test 1 PM
281
+ - 2: logging now more according to debug true/false in the config file
281
282
 
282
283
 
283
284
  ## Hardware
package/config.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "manufacturer": "Duotecno-Coppieterscc",
3
3
  "platform": "DuotecnoPlatform",
4
4
  "smappee": {
5
+ "debug": false,
5
6
  "rules": [
6
7
  {
7
8
  "type": "sun",
@@ -140,7 +141,6 @@
140
141
  ],
141
142
  "address": "192.168.0.186",
142
143
  "uid": "57e3e0d8-bb05-4b04-8662-1a9871998f3f",
143
- "debug": false,
144
144
  "bindings": [
145
145
  {
146
146
  "logicalNodeAddress": 252,
@@ -189,6 +189,7 @@
189
189
  ]
190
190
  },
191
191
  "p1": {
192
+ "debug": false,
192
193
  "rules": [
193
194
  {
194
195
  "type": "power",
@@ -250,6 +251,7 @@
250
251
  "address": "192.168.0.207"
251
252
  },
252
253
  "shelly": {
254
+ "debug": false,
253
255
  "address": "192.168.0.95",
254
256
  "addresses": "192.168.0.95,192.168.0.95",
255
257
  "rules": [],
@@ -18,7 +18,7 @@ exports.logSettings = {
18
18
  "protocol": LogLevel.noLog,
19
19
  "webapp": LogLevel.log,
20
20
  "p1": LogLevel.log,
21
- "shelly": LogLevel.debug,
21
+ "shelly": LogLevel.log,
22
22
  "power": LogLevel.log,
23
23
  "smartapp": LogLevel.log
24
24
  };
@@ -13,7 +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
+ "shelly": LogLevel.log,
17
17
  "power": LogLevel.log,
18
18
  "smartapp": LogLevel.log
19
19
  };
package/duotecno/types.js CHANGED
@@ -254,6 +254,7 @@ exports.Sanitizers = {
254
254
  powerbase: function (config) {
255
255
  if (!config)
256
256
  config = {};
257
+ config.debug = config.debug || false;
257
258
  config.rules = config.rules || [];
258
259
  config.rules = config.rules.map(sw => exports.Sanitizers.ruleConfig(sw));
259
260
  config.bindings = config.bindings || [];
@@ -269,10 +270,14 @@ exports.Sanitizers = {
269
270
  return cfg;
270
271
  },
271
272
  p1: function (config) {
272
- config = exports.Sanitizers.powerbase(config);
273
- return config;
273
+ if (!config)
274
+ config = {};
275
+ const cfg = exports.Sanitizers.powerbase(config);
276
+ return cfg;
274
277
  },
275
278
  shelly: function (config) {
279
+ if (!config)
280
+ config = {};
276
281
  const cfg = exports.Sanitizers.powerbase(config);
277
282
  cfg.addresses = (config === null || config === void 0 ? void 0 : config.addresses) || "";
278
283
  return cfg;
@@ -325,6 +330,9 @@ exports.Sanitizers = {
325
330
  b.power = binding.power || NaN;
326
331
  return b;
327
332
  },
333
+ //////////////
334
+ // Duotecno //
335
+ //////////////
328
336
  masterConfig: function (config) {
329
337
  config = (config) ? Object.assign({}, config) : {};
330
338
  config.name = config.name || "IP Master";
package/duotecno/types.ts CHANGED
@@ -259,6 +259,13 @@ export interface SmartAppConfig extends BaseConfig {
259
259
  switches: Array<Switch>;
260
260
  }
261
261
 
262
+ /////////////////////
263
+ // Smartapp config //
264
+ /////////////////////
265
+ export interface BaseConfig {
266
+ debug?: boolean;
267
+ }
268
+
262
269
  ///////////
263
270
  // Power //
264
271
  ///////////
@@ -292,9 +299,7 @@ export interface Bridge {
292
299
  pin: string // "577-02-003"
293
300
  };
294
301
 
295
- export interface BaseConfig {
296
- debug?: boolean;
297
- }
302
+
298
303
  export interface PlatformConfig extends BaseConfig {
299
304
  manufacturer: string;
300
305
  platform: string;
@@ -429,6 +434,7 @@ export const Sanitizers = {
429
434
 
430
435
  powerbase: function(config: PowerBaseConfig): PowerBaseConfig {
431
436
  if (!config) config = <PowerBaseConfig>{};
437
+ config.debug = config.debug || false;
432
438
 
433
439
  config.rules = config.rules || [];
434
440
  config.rules = config.rules.map(sw => Sanitizers.ruleConfig(sw));
@@ -442,19 +448,21 @@ export const Sanitizers = {
442
448
 
443
449
  smappee: function(config: SmappeeConfig): SmappeeConfig {
444
450
  if (!config) config = <SmappeeConfig>{};
445
-
446
451
  const cfg = <SmappeeConfig> Sanitizers.powerbase(config);
447
452
 
448
453
  cfg.uid = config.uid || "--none--";
449
454
  return cfg;
450
455
  },
451
456
  p1: function(config: P1Config): P1Config {
452
- config = Sanitizers.powerbase(config);
457
+ if (!config) config = <P1Config>{};
458
+ const cfg = Sanitizers.powerbase(config);
453
459
 
454
- return config;
460
+ return cfg;
455
461
  },
456
462
  shelly: function(config: ShellyConfig): ShellyConfig {
463
+ if (!config) config = <ShellyConfig>{};
457
464
  const cfg = <ShellyConfig> Sanitizers.powerbase(config);
465
+
458
466
  cfg.addresses = config?.addresses || "";
459
467
  return cfg;
460
468
  },
@@ -511,6 +519,9 @@ export const Sanitizers = {
511
519
  return b;
512
520
  },
513
521
 
522
+ //////////////
523
+ // Duotecno //
524
+ //////////////
514
525
  masterConfig: function(config?: MasterConfig): MasterConfig {
515
526
  config = (config) ? {...config} : <MasterConfig>{};
516
527
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.3.1",
4
+ "version": "6.3.2",
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
@@ -14,7 +14,9 @@ class Base {
14
14
  else
15
15
  this.readConfig();
16
16
  if (this.debug)
17
- logger_1.logSettings["system"] = logger_1.LogLevel.debug;
17
+ logger_1.logSettings[this.type] = logger_1.LogLevel.debug;
18
+ else if (logger_1.logSettings[this.type] == logger_1.LogLevel.debug)
19
+ logger_1.logSettings[this.type] = logger_1.LogLevel.log;
18
20
  (0, logger_1.debug)("system", "==== read config -> " + JSON.stringify(this.config));
19
21
  }
20
22
  //////////////////
package/server/base.ts CHANGED
@@ -21,7 +21,9 @@ export class Base {
21
21
  this.readConfig();
22
22
 
23
23
  if (this.debug)
24
- logSettings["system"] = LogLevel.debug;
24
+ logSettings[this.type] = LogLevel.debug;
25
+ else if (logSettings[this.type] == LogLevel.debug)
26
+ logSettings[this.type] = LogLevel.log;
25
27
 
26
28
  debug("system", "==== read config -> " + JSON.stringify(this.config))
27
29
  }
@@ -106,7 +106,7 @@ class PowerBase extends base_1.Base {
106
106
  b.power = value;
107
107
  // debug("homebridge", "set unit " + b.name + " to " + value);
108
108
  })
109
- .catch((e) => (0, logger_1.err)(this.type, e));
109
+ .catch((e) => (0, logger_1.err)(this.type, e.message || e));
110
110
  }
111
111
  else {
112
112
  (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));
@@ -131,10 +131,10 @@ class PowerBase extends base_1.Base {
131
131
  // Rules execution //
132
132
  /////////////////////
133
133
  applyRules() {
134
- if (this.realtimeCounter % 30 === 0) {
135
- (0, logger_1.log)("power", this.type + " > processRealTime: totalPower = " + this.realtime.totalPower +
136
- ", export = " + this.realtime.totalExportEnergy +
137
- ", import = " + this.realtime.totalImportEnergy);
134
+ if (this.realtimeCounter % 60 === 0) {
135
+ (0, logger_1.log)("power", this.type + " > RealTime totals: Power = " + this.realtime.totalPower +
136
+ ", Export = " + this.realtime.totalExportEnergy +
137
+ ", Import = " + this.realtime.totalImportEnergy);
138
138
  }
139
139
  if (this.realtimeCounter % 5 === 0) {
140
140
  // for all rules
@@ -1,6 +1,6 @@
1
1
  import { System } from "../duotecno/system";
2
2
  import { PowerBaseConfig, Rule, Binding, Sanitizers, Boundaries, Action, kEmptyBinding, kEmptyRule } from "../duotecno/types";
3
- import { err, debug, log } from "../duotecno/logger";
3
+ import { err, debug, log, logSettings, LogLevel } from "../duotecno/logger";
4
4
  import { Base } from "./base";
5
5
  import { Context } from "./webapp";
6
6
 
@@ -89,7 +89,7 @@ export class PowerBase extends Base {
89
89
  async updateConfig(config: any) {
90
90
  if (config.address)
91
91
  this.config.address = config.address;
92
-
92
+
93
93
  this.writeConfig();
94
94
 
95
95
  return this.init(false);
@@ -123,7 +123,7 @@ export class PowerBase extends Base {
123
123
  b.power = value;
124
124
  // debug("homebridge", "set unit " + b.name + " to " + value);
125
125
  })
126
- .catch((e) => err(this.type, e));
126
+ .catch((e) => err(this.type, e.message || e));
127
127
 
128
128
  } else {
129
129
  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))
@@ -149,10 +149,10 @@ export class PowerBase extends Base {
149
149
  // Rules execution //
150
150
  /////////////////////
151
151
  applyRules() {
152
- if (this.realtimeCounter % 30 === 0) {
153
- log("power", this.type + " > processRealTime: totalPower = " + this.realtime.totalPower +
154
- ", export = " + this.realtime.totalExportEnergy +
155
- ", import = " + this.realtime.totalImportEnergy);
152
+ if (this.realtimeCounter % 60 === 0) {
153
+ log("power", this.type + " > RealTime totals: Power = " + this.realtime.totalPower +
154
+ ", Export = " + this.realtime.totalExportEnergy +
155
+ ", Import = " + this.realtime.totalImportEnergy);
156
156
  }
157
157
 
158
158
  if (this.realtimeCounter % 5 === 0) {
package/server/shelly.js CHANGED
@@ -167,7 +167,7 @@ class Shelly extends powerbase_1.PowerBase {
167
167
  return true;
168
168
  }
169
169
  catch (error) {
170
- (0, logger_1.err)("shelly", error.message);
170
+ (0, logger_1.err)("shelly", error.message || error);
171
171
  return false;
172
172
  }
173
173
  });
package/server/shelly.ts CHANGED
@@ -182,7 +182,7 @@ export class Shelly extends PowerBase {
182
182
  return true;
183
183
 
184
184
  } catch(error) {
185
- err("shelly", error.message);
185
+ err("shelly", error.message || error);
186
186
  return false;
187
187
  }
188
188
  }