homebridge-smartsystem 6.0.10 → 6.1.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.
Files changed (73) hide show
  1. package/README.md +9 -0
  2. package/accessories/accessory.js +6 -6
  3. package/accessories/accessory.ts +6 -8
  4. package/accessories/bulb.js +2 -2
  5. package/accessories/bulb.ts +2 -3
  6. package/accessories/dimmer.js +9 -8
  7. package/accessories/dimmer.ts +9 -9
  8. package/accessories/door.js +4 -3
  9. package/accessories/door.ts +4 -5
  10. package/accessories/garagedoor.js +7 -7
  11. package/accessories/garagedoor.ts +8 -8
  12. package/accessories/lock.js +8 -8
  13. package/accessories/lock.ts +9 -9
  14. package/accessories/mood.js +4 -4
  15. package/accessories/mood.ts +5 -5
  16. package/accessories/switch.js +2 -2
  17. package/accessories/switch.ts +2 -3
  18. package/accessories/temperature.js +5 -4
  19. package/accessories/temperature.ts +5 -5
  20. package/accessories/windowcovering.js +10 -10
  21. package/accessories/windowcovering.ts +11 -11
  22. package/config.homebridge.json +2 -0
  23. package/config.p1-dev.json +6 -0
  24. package/config.p1.json +6 -0
  25. package/duotecno/Q.js +10 -9
  26. package/duotecno/Q.ts +10 -11
  27. package/duotecno/master.js +37 -21
  28. package/duotecno/master.ts +39 -22
  29. package/duotecno/protocol.js +15 -20
  30. package/duotecno/protocol.ts +14 -20
  31. package/duotecno/smartsocket.js +26 -22
  32. package/duotecno/smartsocket.ts +32 -26
  33. package/duotecno/system.js +17 -17
  34. package/duotecno/system.ts +17 -18
  35. package/duotecno/types.js +70 -3
  36. package/duotecno/types.ts +70 -5
  37. package/index.spec.js +18 -11
  38. package/index.spec.ts +20 -12
  39. package/package.json +1 -1
  40. package/run.js +1 -1
  41. package/run.ts +1 -1
  42. package/run9998.js +1 -1
  43. package/run9998.ts +1 -1
  44. package/run9999.js +1 -1
  45. package/run9999.ts +1 -1
  46. package/server/base.js +6 -21
  47. package/server/base.ts +8 -23
  48. package/server/p1.js +137 -0
  49. package/server/p1.ts +220 -0
  50. package/server/platform.js +63 -54
  51. package/server/platform.ts +65 -56
  52. package/server/powerbase.js +260 -0
  53. package/server/powerbase.ts +288 -0
  54. package/server/shelly.js +63 -0
  55. package/server/shelly.ts +65 -0
  56. package/server/{smappee.json → smappee-sample.json} +0 -0
  57. package/server/smappee.js +158 -274
  58. package/server/smappee.ts +156 -311
  59. package/server/smartapp.js +71 -127
  60. package/server/smartapp.ts +82 -129
  61. package/server/socapp.js +20 -18
  62. package/server/socapp.ts +20 -19
  63. package/server/somfy.js +12 -22
  64. package/server/somfy.ts +13 -22
  65. package/server/support.js +11 -11
  66. package/server/support.ts +11 -13
  67. package/server/views/nav.ejs +5 -3
  68. package/server/views/{smappee-binding.ejs → power-binding.ejs} +4 -2
  69. package/server/views/{smappee-rule.ejs → power-rule.ejs} +12 -10
  70. package/server/views/{smappee.ejs → power.ejs} +44 -38
  71. package/server/views/switch-details.ejs +0 -1
  72. package/server/webapp.js +21 -8
  73. package/server/webapp.ts +23 -9
package/README.md CHANGED
@@ -244,6 +244,15 @@ switch =>
244
244
  added "restart plugin" to settings,
245
245
  set lock target state to "locked"
246
246
 
247
+ ## v6.1.0 - 15-07-2022
248
+ - global debug, log, err functions in types.ts
249
+ - split smappee.ts in PowerBase + smappee/p1/shelly
250
+
251
+ ## v6.1.1 - 21-07-2022 - P1 release
252
+ - R1: implemented P1 power meter telegram
253
+ - R2: bugfixes, timeout mgt, etc...
254
+
255
+
247
256
  ## Hardware
248
257
  A Raspberry Pi that connects to a Duotecno IP Node
249
258
  and (if configured) to a Smappee Infinity (power and plugs)
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Accessory = void 0;
4
+ const types_1 = require("../duotecno/types");
4
5
  // Johan Coppieters Jan 2019
5
6
  //
6
7
  // base class for all kind of accessories on our platform
7
8
  // handling the homekit required services.
8
9
  class Accessory {
9
- constructor(log, api, unit) {
10
+ constructor(api, unit) {
10
11
  this.homebridge = api.hap;
11
- this.log = log; // : function(message)
12
12
  this.unit = unit; // : Duotecno Unit
13
13
  this.name = unit.getDisplayName();
14
14
  this.uuid_base = unit.getSerialNr();
@@ -17,7 +17,7 @@ class Accessory {
17
17
  this.services.push(this.getInformationService());
18
18
  }
19
19
  makeService(service) {
20
- this.log("accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
20
+ (0, types_1.log)("accessory", "accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
21
21
  this.me = new service(this.name);
22
22
  return this.me;
23
23
  }
@@ -50,7 +50,7 @@ class Accessory {
50
50
  if (this.unit) {
51
51
  this.unit.reqState(unit => {
52
52
  next(null, unit.status);
53
- this.log("getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
53
+ (0, types_1.log)("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
54
54
  }).catch(err => next(err));
55
55
  }
56
56
  else {
@@ -61,7 +61,7 @@ class Accessory {
61
61
  if (this.unit) {
62
62
  this.unit.reqState(unit => {
63
63
  next(null, unit.value);
64
- this.log("getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
64
+ (0, types_1.log)("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
65
65
  }).catch(err => next(err));
66
66
  }
67
67
  else {
@@ -86,7 +86,7 @@ class Accessory {
86
86
  }
87
87
  updateState() {
88
88
  this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(this.unit.status);
89
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
89
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
90
90
  }
91
91
  }
92
92
  exports.Accessory = Accessory;
@@ -1,4 +1,4 @@
1
- import { LogFunction } from "../duotecno/types";
1
+ import { log } from "../duotecno/types";
2
2
  import { Unit } from "../duotecno/protocol";
3
3
  import { API, HAP, Service } from "homebridge";
4
4
 
@@ -9,7 +9,6 @@ import { API, HAP, Service } from "homebridge";
9
9
 
10
10
  export class Accessory {
11
11
  homebridge: HAP; // homebridge api endpoint
12
- log: LogFunction;
13
12
  unit: Unit;
14
13
  config: any; // all config params
15
14
  name: string;
@@ -18,9 +17,8 @@ export class Accessory {
18
17
  me: Service;
19
18
 
20
19
 
21
- constructor(log: LogFunction, api: API, unit: Unit) {
20
+ constructor(api: API, unit: Unit) {
22
21
  this.homebridge = api.hap;
23
- this.log = log; // : function(message)
24
22
  this.unit = unit; // : Duotecno Unit
25
23
  this.name = unit.getDisplayName();
26
24
  this.uuid_base = unit.getSerialNr();
@@ -31,7 +29,7 @@ export class Accessory {
31
29
  }
32
30
 
33
31
  makeService(service: any): Service {
34
- this.log("accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
32
+ log("accessory", "accessory - Making service: " + this.name + ", serial: " + this.uuid_base);
35
33
  this.me = new service(this.name);
36
34
  return this.me;
37
35
  }
@@ -71,7 +69,7 @@ export class Accessory {
71
69
  if (this.unit) {
72
70
  this.unit.reqState(unit => {
73
71
  next(null, unit.status);
74
- this.log("getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
72
+ log("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
75
73
  }).catch(err => next(err));
76
74
  } else {
77
75
  next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
@@ -82,7 +80,7 @@ export class Accessory {
82
80
  if (this.unit) {
83
81
  this.unit.reqState(unit => {
84
82
  next(null, unit.value);
85
- this.log("getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
83
+ log("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
86
84
  }).catch(err => next(err));
87
85
  } else {
88
86
  next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
@@ -109,7 +107,7 @@ export class Accessory {
109
107
 
110
108
  updateState() {
111
109
  this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(this.unit.status);
112
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
110
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> on = " + this.unit.status);
113
111
  }
114
112
 
115
113
  }
@@ -9,8 +9,8 @@ const accessory_1 = require("./accessory");
9
9
  // so when asking to Siri to turn off all lights, these get turned off too.
10
10
  // - does same thing as a dimmer (which is also a LightBulb), but we don't supper Brightness.
11
11
  class Bulb extends accessory_1.Accessory {
12
- constructor(log, homebridge, unit) {
13
- super(log, homebridge, unit);
12
+ constructor(homebridge, unit) {
13
+ super(homebridge, unit);
14
14
  }
15
15
  getAccessoryServices() {
16
16
  const lightbulbService = this.makeService(this.homebridge.Service.Lightbulb);
@@ -1,5 +1,4 @@
1
1
  import { Accessory } from "./accessory";
2
- import { LogFunction } from "../duotecno/types";
3
2
  import { Unit } from "../duotecno/protocol";
4
3
  import { API } from "homebridge";
5
4
 
@@ -13,8 +12,8 @@ import { API } from "homebridge";
13
12
 
14
13
  export class Bulb extends Accessory {
15
14
 
16
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
17
- super(log, homebridge, unit);
15
+ constructor(homebridge: API, unit: Unit) {
16
+ super(homebridge, unit);
18
17
  }
19
18
 
20
19
 
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Dimmer = void 0;
4
4
  const accessory_1 = require("./accessory");
5
+ const types_1 = require("../duotecno/types");
5
6
  // Johan Coppieters Jan 2019
6
7
  //
7
8
  // Dimmer
8
9
  // - a LightBulb to homekit, so a "light"
9
10
  //
10
11
  class Dimmer extends accessory_1.Accessory {
11
- constructor(log, homebridge, unit) {
12
- super(log, homebridge, unit);
12
+ constructor(homebridge, unit) {
13
+ super(homebridge, unit);
13
14
  this.currValue = 0;
14
15
  this.preventSetPower = false;
15
16
  this.waitingSetPower = false;
@@ -30,7 +31,7 @@ class Dimmer extends accessory_1.Accessory {
30
31
  if (this.unit) {
31
32
  this.unit.reqState(unit => {
32
33
  next(null, unit.value);
33
- this.log("getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
34
+ (0, types_1.log)("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
34
35
  }).catch(err => next(err));
35
36
  }
36
37
  else {
@@ -39,10 +40,10 @@ class Dimmer extends accessory_1.Accessory {
39
40
  }
40
41
  setPower(powerOn, next) {
41
42
  this.waitingSetPower = true;
42
- this.log("setPower: *** waiting *** " + powerOn);
43
+ (0, types_1.log)("accessory", "setPower: *** waiting *** " + powerOn);
43
44
  setTimeout(() => {
44
45
  if (!this.preventSetPower) {
45
- this.log("setPower: " + powerOn);
46
+ (0, types_1.log)("accessory", "setPower: " + powerOn);
46
47
  this.unit.setState(powerOn)
47
48
  .then(() => next())
48
49
  .catch(err => next(err));
@@ -59,16 +60,16 @@ class Dimmer extends accessory_1.Accessory {
59
60
  // crush set on/off requests, bug in homekit / homebridge
60
61
  if (this.waitingSetPower) {
61
62
  this.preventSetPower = true;
62
- this.log("setBrightness -> setPower: *** cancelled ***");
63
+ (0, types_1.log)("accessory", "setBrightness -> setPower: *** cancelled ***");
63
64
  }
64
- this.log("setBrightness " + value);
65
+ (0, types_1.log)("accessory", "setBrightness " + value);
65
66
  this.unit.setState(value)
66
67
  .then(() => next())
67
68
  .catch(err => next(err));
68
69
  }
69
70
  updateState() {
70
71
  this.me.getCharacteristic(this.homebridge.Characteristic.Brightness).updateValue(this.unit.value);
71
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
72
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
72
73
  }
73
74
  }
74
75
  exports.Dimmer = Dimmer;
@@ -1,7 +1,7 @@
1
1
  import { Accessory } from "./accessory";
2
- import { LogFunction } from "../duotecno/types";
3
2
  import { Unit } from "../duotecno/protocol";
4
3
  import { API } from "homebridge";
4
+ import { log } from "../duotecno/types";
5
5
 
6
6
  // Johan Coppieters Jan 2019
7
7
  //
@@ -15,8 +15,8 @@ export class Dimmer extends Accessory {
15
15
  preventSetPower: boolean;
16
16
  waitingSetPower: boolean;
17
17
 
18
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
19
- super(log, homebridge, unit);
18
+ constructor(homebridge: API, unit: Unit) {
19
+ super(homebridge, unit);
20
20
  this.currValue = 0;
21
21
  this.preventSetPower = false;
22
22
  this.waitingSetPower = false;
@@ -42,7 +42,7 @@ export class Dimmer extends Accessory {
42
42
  if (this.unit) {
43
43
  this.unit.reqState(unit => {
44
44
  next(null, unit.value);
45
- this.log("getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
45
+ log("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
46
46
  }).catch(err => next(err));
47
47
  } else {
48
48
  next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
@@ -51,10 +51,10 @@ export class Dimmer extends Accessory {
51
51
 
52
52
  setPower(powerOn, next) {
53
53
  this.waitingSetPower = true;
54
- this.log("setPower: *** waiting *** " + powerOn);
54
+ log("accessory", "setPower: *** waiting *** " + powerOn);
55
55
  setTimeout( () => {
56
56
  if (!this.preventSetPower) {
57
- this.log("setPower: " + powerOn);
57
+ log("accessory", "setPower: " + powerOn);
58
58
  this.unit.setState(powerOn)
59
59
  .then(() => next())
60
60
  .catch(err => next(err))
@@ -72,10 +72,10 @@ export class Dimmer extends Accessory {
72
72
  // crush set on/off requests, bug in homekit / homebridge
73
73
  if (this.waitingSetPower) {
74
74
  this.preventSetPower = true;
75
- this.log("setBrightness -> setPower: *** cancelled ***");
75
+ log("accessory", "setBrightness -> setPower: *** cancelled ***");
76
76
  }
77
77
 
78
- this.log("setBrightness " + value);
78
+ log("accessory", "setBrightness " + value);
79
79
 
80
80
  this.unit.setState(value)
81
81
  .then(() => next())
@@ -84,7 +84,7 @@ export class Dimmer extends Accessory {
84
84
 
85
85
  updateState() {
86
86
  this.me.getCharacteristic(this.homebridge.Characteristic.Brightness).updateValue(this.unit.value);
87
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
87
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> Brightness = " + this.unit.value);
88
88
  }
89
89
 
90
90
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Door = void 0;
4
+ const types_1 = require("../duotecno/types");
4
5
  const windowcovering_1 = require("./windowcovering");
5
6
  // Johan Coppieters Jun 2020
6
7
  //
@@ -46,8 +47,8 @@ const windowcovering_1 = require("./windowcovering");
46
47
 
47
48
  */
48
49
  class Door extends windowcovering_1.WindowCovering {
49
- constructor(log, homebridge, unit) {
50
- super(log, homebridge, unit);
50
+ constructor(homebridge, unit) {
51
+ super(homebridge, unit);
51
52
  }
52
53
  getAccessoryServices() {
53
54
  // DoorOpener needs authentication
@@ -67,7 +68,7 @@ class Door extends windowcovering_1.WindowCovering {
67
68
  // in response to Duotecno status messages
68
69
  updateState() {
69
70
  const value = this.DT2HB(this.unit.status);
70
- this.log("Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
71
+ (0, types_1.log)("accessory", "Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
71
72
  this.me.getCharacteristic(this.homebridge.Characteristic.CurrentPosition).updateValue(value);
72
73
  }
73
74
  }
@@ -1,5 +1,4 @@
1
- import { Accessory } from "./accessory";
2
- import { LogFunction, UnitMotorCmd, UnitState } from "../duotecno/types";
1
+ import { log } from "../duotecno/types";
3
2
  import { WindowCovering } from "./windowcovering";
4
3
  import { Unit } from "../duotecno/protocol";
5
4
  import { API } from "homebridge";
@@ -53,8 +52,8 @@ import { API } from "homebridge";
53
52
  export class Door extends WindowCovering {
54
53
  targetState;
55
54
 
56
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
57
- super(log, homebridge, unit);
55
+ constructor(homebridge: API, unit: Unit) {
56
+ super(homebridge, unit);
58
57
  }
59
58
 
60
59
  getAccessoryServices() {
@@ -82,7 +81,7 @@ export class Door extends WindowCovering {
82
81
  // in response to Duotecno status messages
83
82
  updateState() {
84
83
  const value = this.DT2HB(this.unit.status);
85
- this.log("Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
84
+ log("accessory", "Received updateState -> Homekit Door for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
86
85
  this.me.getCharacteristic(this.homebridge.Characteristic.CurrentPosition).updateValue(value);
87
86
  }
88
87
 
@@ -11,8 +11,8 @@ const accessory_1 = require("./accessory");
11
11
  //
12
12
  //
13
13
  class GarageDoor extends accessory_1.Accessory {
14
- constructor(log, homebridge, unit) {
15
- super(log, homebridge, unit);
14
+ constructor(homebridge, unit) {
15
+ super(homebridge, unit);
16
16
  }
17
17
  getAccessoryServices() {
18
18
  // GarageDoorOpener needs authentication
@@ -55,7 +55,7 @@ class GarageDoor extends accessory_1.Accessory {
55
55
  try {
56
56
  this.unit.reqState(unit => {
57
57
  const hb = this.DT2HB(unit.status);
58
- this.log("Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
58
+ (0, types_1.log)("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
59
59
  next(null, hb);
60
60
  });
61
61
  }
@@ -69,24 +69,24 @@ class GarageDoor extends accessory_1.Accessory {
69
69
  this.targetState = value;
70
70
  let cmd = this.HB2DT(value);
71
71
  if (cmd) {
72
- this.log("Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd=" + cmd);
72
+ (0, types_1.log)("accessory", "Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd=" + cmd);
73
73
  this.unit.setState(cmd)
74
74
  .then(() => next())
75
75
  .catch(err => next(err));
76
76
  }
77
77
  else {
78
- this.log("Set TargetDoorState of " + this.name + " -> failed for : " + value);
78
+ (0, types_1.log)("accessory", "Set TargetDoorState of " + this.name + " -> failed for : " + value);
79
79
  next(new Error("TargetDoorState of " + this.name + " -> failed"));
80
80
  }
81
81
  }
82
82
  getTargetDoorState(next) {
83
- this.log("Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
83
+ (0, types_1.log)("accessory", "Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
84
84
  next(null, this.targetState);
85
85
  }
86
86
  // in response to Duotecno status messages
87
87
  updateState() {
88
88
  const value = this.DT2HB(this.unit.status);
89
- // this.log("Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
89
+ // log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
90
90
  this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
91
91
  }
92
92
  }
@@ -1,6 +1,6 @@
1
1
  import { API } from "homebridge";
2
2
  import { Unit } from "../duotecno/protocol";
3
- import { LogFunction, UnitMotorCmd, UnitState } from "../duotecno/types";
3
+ import { log, UnitMotorCmd, UnitState } from "../duotecno/types";
4
4
  import { Accessory } from "./accessory";
5
5
 
6
6
  // Johan Coppieters Jun 2020
@@ -16,8 +16,8 @@ import { Accessory } from "./accessory";
16
16
  export class GarageDoor extends Accessory {
17
17
  targetState;
18
18
 
19
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
20
- super(log, homebridge, unit);
19
+ constructor(homebridge: API, unit: Unit) {
20
+ super(homebridge, unit);
21
21
  }
22
22
 
23
23
  getAccessoryServices() {
@@ -79,7 +79,7 @@ export class GarageDoor extends Accessory {
79
79
  try {
80
80
  this.unit.reqState(unit => {
81
81
  const hb = this.DT2HB(unit.status);
82
- this.log("Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
82
+ log("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
83
83
  next(null, hb);
84
84
  });
85
85
 
@@ -96,19 +96,19 @@ export class GarageDoor extends Accessory {
96
96
  let cmd = this.HB2DT(value);
97
97
 
98
98
  if (cmd) {
99
- this.log("Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd="+cmd);
99
+ log("accessory", "Set TargetDoorState of " + this.name + ", value =" + value + " -> cmd="+cmd);
100
100
  this.unit.setState(cmd)
101
101
  .then(() => next())
102
102
  .catch(err => next(err));
103
103
 
104
104
  } else {
105
- this.log("Set TargetDoorState of " + this.name + " -> failed for : " + value);
105
+ log("accessory", "Set TargetDoorState of " + this.name + " -> failed for : " + value);
106
106
  next(new Error("TargetDoorState of " + this.name + " -> failed"));
107
107
  }
108
108
  }
109
109
 
110
110
  getTargetDoorState(next) {
111
- this.log("Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
111
+ log("accessory", "Characteristic.TargetDoorState.get was called of " + this.name + " = " + this.targetState);
112
112
  next(null, this.targetState);
113
113
  }
114
114
 
@@ -116,7 +116,7 @@ export class GarageDoor extends Accessory {
116
116
  // in response to Duotecno status messages
117
117
  updateState() {
118
118
  const value = this.DT2HB(this.unit.status);
119
- // this.log("Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
119
+ // log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
120
120
  this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
121
121
  }
122
122
 
@@ -11,10 +11,10 @@ const accessory_1 = require("./accessory");
11
11
  // if name contains * = permanent locked=on/unlocked=off
12
12
  // else short press -> unlock, locked again after 1.2 sec
13
13
  class Lock extends accessory_1.Accessory {
14
- constructor(log, homebridge, unit) {
15
- super(log, homebridge, unit);
14
+ constructor(homebridge, unit) {
15
+ super(homebridge, unit);
16
16
  this.targetState = 1; // locked
17
- this.log("created Lock -> " + unit.getDescription());
17
+ (0, types_1.log)("accessory", "created Lock -> " + unit.getDescription());
18
18
  // set default for Unlocked to Locked
19
19
  if (this.unit.getType() === types_1.UnitExtendedType.kUnlocker)
20
20
  unit.setState(1);
@@ -36,7 +36,7 @@ class Lock extends accessory_1.Accessory {
36
36
  this.targetState = value;
37
37
  // unlocker is a mood, a lock is a switch
38
38
  const dtVal = (this.unit.getType() === types_1.UnitExtendedType.kUnlocker) ? -1 : value;
39
- this.log("HB setting target state of lock: to " + value + " of " + this.unit.getDescription() + " (duotecno: " + dtVal + ")");
39
+ (0, types_1.log)("accessory", "HB setting target state of lock: to " + value + " of " + this.unit.getDescription() + " (duotecno: " + dtVal + ")");
40
40
  this.unit.setState(dtVal)
41
41
  .then(() => {
42
42
  //bypass ip node update mechanism of Duotecno
@@ -45,7 +45,7 @@ class Lock extends accessory_1.Accessory {
45
45
  if (this.unit.getType() === types_1.UnitExtendedType.kUnlocker) {
46
46
  // always set to "locked" after sending the request.
47
47
  this.unit.resetTimer = setTimeout(() => {
48
- this.log("Autolock for an unlocker after 2 secs of " + this.unit.getDescription());
48
+ (0, types_1.log)("accessory", "Autolock for an unlocker after 2 secs of " + this.unit.getDescription());
49
49
  this.targetState = 1;
50
50
  this.me.getCharacteristic(this.homebridge.Characteristic.LockTargetState).updateValue(1);
51
51
  this.unit.status = 1;
@@ -57,18 +57,18 @@ class Lock extends accessory_1.Accessory {
57
57
  .catch(err => next(err));
58
58
  }
59
59
  getTarget(next) {
60
- this.log("HB getting target state of lock = " + this.unit.status + " of " + this.unit.getDescription());
60
+ (0, types_1.log)("accessory", "HB getting target state of lock = " + this.unit.status + " of " + this.unit.getDescription());
61
61
  next(null, this.targetState);
62
62
  }
63
63
  getCurrent(next) {
64
64
  this.unit.reqState(unit => {
65
- this.log("HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
65
+ (0, types_1.log)("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
66
66
  next(null, !!this.unit.status);
67
67
  });
68
68
  }
69
69
  // in response to Duotecno status messages
70
70
  updateState() {
71
- // this.log("Received updateState -> Homekit Lock for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
71
+ // log("accessory", "Received updateState -> Homekit Lock for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
72
72
  this.me.getCharacteristic(this.homebridge.Characteristic.LockCurrentState).updateValue(this.unit.status);
73
73
  }
74
74
  }
@@ -1,6 +1,6 @@
1
1
  import { API } from "homebridge";
2
2
  import { Unit } from "../duotecno/protocol";
3
- import { LogFunction, UnitExtendedType } from "../duotecno/types";
3
+ import { log, UnitExtendedType } from "../duotecno/types";
4
4
  import { Accessory } from "./accessory";
5
5
 
6
6
  // Johan Coppieters Jun 2020
@@ -16,9 +16,9 @@ import { Accessory } from "./accessory";
16
16
  export class Lock extends Accessory {
17
17
  targetState = 1; // locked
18
18
 
19
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
20
- super(log, homebridge, unit);
21
- this.log("created Lock -> " + unit.getDescription());
19
+ constructor(homebridge: API, unit: Unit) {
20
+ super(homebridge, unit);
21
+ log("accessory", "created Lock -> " + unit.getDescription());
22
22
 
23
23
  // set default for Unlocked to Locked
24
24
  if (this.unit.getType() === UnitExtendedType.kUnlocker)
@@ -49,7 +49,7 @@ export class Lock extends Accessory {
49
49
  // unlocker is a mood, a lock is a switch
50
50
  const dtVal = (this.unit.getType() === UnitExtendedType.kUnlocker) ? -1 : value;
51
51
 
52
- this.log("HB setting target state of lock: to " + value + " of " + this.unit.getDescription() + " (duotecno: " + dtVal + ")");
52
+ log("accessory", "HB setting target state of lock: to " + value + " of " + this.unit.getDescription() + " (duotecno: " + dtVal + ")");
53
53
 
54
54
  this.unit.setState(dtVal)
55
55
  .then(() => {
@@ -60,7 +60,7 @@ export class Lock extends Accessory {
60
60
  if (this.unit.getType() === UnitExtendedType.kUnlocker) {
61
61
  // always set to "locked" after sending the request.
62
62
  this.unit.resetTimer = setTimeout(() => {
63
- this.log("Autolock for an unlocker after 2 secs of " + this.unit.getDescription())
63
+ log("accessory", "Autolock for an unlocker after 2 secs of " + this.unit.getDescription())
64
64
  this.targetState = 1;
65
65
  this.me.getCharacteristic(this.homebridge.Characteristic.LockTargetState).updateValue(1);
66
66
  this.unit.status = 1;
@@ -74,13 +74,13 @@ export class Lock extends Accessory {
74
74
  }
75
75
 
76
76
  getTarget(next) {
77
- this.log("HB getting target state of lock = " + this.unit.status + " of " + this.unit.getDescription());
77
+ log("accessory", "HB getting target state of lock = " + this.unit.status + " of " + this.unit.getDescription());
78
78
  next(null, this.targetState);
79
79
  }
80
80
 
81
81
  getCurrent(next) {
82
82
  this.unit.reqState(unit => {
83
- this.log("HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
83
+ log("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
84
84
  next(null, !!this.unit.status);
85
85
  });
86
86
  }
@@ -88,7 +88,7 @@ export class Lock extends Accessory {
88
88
 
89
89
  // in response to Duotecno status messages
90
90
  updateState() {
91
- // this.log("Received updateState -> Homekit Lock for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
91
+ // log("accessory", "Received updateState -> Homekit Lock for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
92
92
  this.me.getCharacteristic(this.homebridge.Characteristic.LockCurrentState).updateValue(this.unit.status);
93
93
  }
94
94
 
@@ -9,8 +9,8 @@ const types_1 = require("../duotecno/types");
9
9
  // - is a Switch to homekit, so it doesn't get turned off with the "all lights out"
10
10
  //
11
11
  class Mood extends accessory_1.Accessory {
12
- constructor(log, homebridge, unit) {
13
- super(log, homebridge, unit);
12
+ constructor(homebridge, unit) {
13
+ super(homebridge, unit);
14
14
  }
15
15
  getAccessoryServices() {
16
16
  const moodService = this.makeService(this.homebridge.Service.Switch);
@@ -22,7 +22,7 @@ class Mood extends accessory_1.Accessory {
22
22
  return [moodService];
23
23
  }
24
24
  getMood(next) {
25
- this.log("getMood was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> false");
25
+ (0, types_1.log)("accessory", "getMood was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> false");
26
26
  next(null, !!this.unit.value);
27
27
  }
28
28
  setMood(value, next) {
@@ -50,7 +50,7 @@ class Mood extends accessory_1.Accessory {
50
50
  }
51
51
  updateState() {
52
52
  this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(!!this.unit.value);
53
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> On = " + !!this.unit.value);
53
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> On = " + !!this.unit.value);
54
54
  }
55
55
  }
56
56
  exports.Mood = Mood;
@@ -1,5 +1,5 @@
1
1
  import { Accessory } from "./accessory";
2
- import { LogFunction, UnitExtendedType } from "../duotecno/types";
2
+ import { log, UnitExtendedType } from "../duotecno/types";
3
3
  import { Unit } from "../duotecno/protocol";
4
4
  import { API } from "homebridge";
5
5
 
@@ -13,8 +13,8 @@ import { API } from "homebridge";
13
13
  export class Mood extends Accessory {
14
14
  myService;
15
15
 
16
- constructor(log: LogFunction, homebridge: API, unit: Unit) {
17
- super(log, homebridge, unit);
16
+ constructor(homebridge: API, unit: Unit) {
17
+ super(homebridge, unit);
18
18
 
19
19
  }
20
20
 
@@ -31,7 +31,7 @@ export class Mood extends Accessory {
31
31
  }
32
32
 
33
33
  getMood(next) {
34
- this.log("getMood was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> false");
34
+ log("accessory", "getMood was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> false");
35
35
 
36
36
  next(null, !!this.unit.value);
37
37
  }
@@ -61,7 +61,7 @@ export class Mood extends Accessory {
61
61
  }
62
62
  updateState() {
63
63
  this.me.getCharacteristic(this.homebridge.Characteristic.On).updateValue(!!this.unit.value);
64
- // this.log("Received status change -> update accessory -> " + this.unit.getName() + " -> On = " + !!this.unit.value);
64
+ // log("accessory", "Received status change -> update accessory -> " + this.unit.getName() + " -> On = " + !!this.unit.value);
65
65
  }
66
66
 
67
67
  }
@@ -8,8 +8,8 @@ const accessory_1 = require("./accessory");
8
8
  // - not a light.
9
9
  //
10
10
  class Switch extends accessory_1.Accessory {
11
- constructor(log, homebridge, unit) {
12
- super(log, homebridge, unit);
11
+ constructor(homebridge, unit) {
12
+ super(homebridge, unit);
13
13
  }
14
14
  getAccessoryServices() {
15
15
  const switchService = this.makeService(this.homebridge.Service.Switch);