homebridge-smartsystem 6.8.13 → 6.8.18

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
@@ -315,6 +315,7 @@ Homebridge UI version
315
315
  - 9: corrected reading the local config file + dump it in the logs
316
316
  - 10: wrong default port for cloud server
317
317
  - 11: use new DNS entries + exponential backoff for new connections, give up after 16 seconds.
318
+ - 12, 13: small changes for missing value for Target...
318
319
 
319
320
  ## Hardware
320
321
  A Raspberry Pi that connects to a Duotecno IP Node
@@ -49,8 +49,16 @@ class Accessory {
49
49
  getState(next) {
50
50
  if (this.unit) {
51
51
  this.unit.reqState(unit => {
52
- next(null, unit.status);
53
- (0, logger_1.log)("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
52
+ try {
53
+ if (!unit) {
54
+ return next(new Error("Unit state not available"));
55
+ }
56
+ next(null, unit.status);
57
+ (0, logger_1.log)("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
58
+ }
59
+ catch (err) {
60
+ next(err);
61
+ }
54
62
  }).catch(err => next(err));
55
63
  }
56
64
  else {
@@ -60,8 +68,16 @@ class Accessory {
60
68
  getValue(next) {
61
69
  if (this.unit) {
62
70
  this.unit.reqState(unit => {
63
- next(null, unit.value);
64
- (0, logger_1.log)("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
71
+ try {
72
+ if (!unit) {
73
+ return next(new Error("Unit state not available"));
74
+ }
75
+ next(null, unit.value);
76
+ (0, logger_1.log)("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
77
+ }
78
+ catch (err) {
79
+ next(err);
80
+ }
65
81
  }).catch(err => next(err));
66
82
  }
67
83
  else {
@@ -68,8 +68,15 @@ export class Accessory {
68
68
  getState(next) {
69
69
  if (this.unit) {
70
70
  this.unit.reqState(unit => {
71
- next(null, unit.status);
72
- log("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
71
+ try {
72
+ if (!unit) {
73
+ return next(new Error("Unit state not available"));
74
+ }
75
+ next(null, unit.status);
76
+ log("accessory", "getState was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status);
77
+ } catch(err) {
78
+ next(err);
79
+ }
73
80
  }).catch(err => next(err));
74
81
  } else {
75
82
  next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
@@ -79,14 +86,22 @@ export class Accessory {
79
86
  getValue(next) {
80
87
  if (this.unit) {
81
88
  this.unit.reqState(unit => {
82
- next(null, unit.value);
83
- log("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
89
+ try {
90
+ if (!unit) {
91
+ return next(new Error("Unit state not available"));
92
+ }
93
+ next(null, unit.value);
94
+ log("accessory", "getValue was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
95
+ } catch(err) {
96
+ next(err);
97
+ }
84
98
  }).catch(err => next(err));
85
99
  } else {
86
100
  next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
87
101
  }
88
102
  }
89
103
 
104
+
90
105
  setState(value, next) {
91
106
  if (this.unit)
92
107
  this.unit.setState(value)
@@ -25,11 +25,6 @@ class Bulb extends accessory_1.Accessory {
25
25
  .then(() => next())
26
26
  .catch(err => next(err));
27
27
  }
28
- setBrightness(value, next) {
29
- this.unit.setState(value)
30
- .then(() => next())
31
- .catch(err => next(err));
32
- }
33
28
  }
34
29
  exports.Bulb = Bulb;
35
30
  //# sourceMappingURL=bulb.js.map
@@ -34,9 +34,5 @@ export class Bulb extends Accessory {
34
34
  .then(() => next())
35
35
  .catch(err => next(err))
36
36
  }
37
- setBrightness(value, next) {
38
- this.unit.setState(value)
39
- .then(() => next())
40
- .catch(err => next(err))
41
- }
37
+
42
38
  }
@@ -30,12 +30,20 @@ class Dimmer extends accessory_1.Accessory {
30
30
  getBrightness(next) {
31
31
  if (this.unit) {
32
32
  this.unit.reqState(unit => {
33
- next(null, unit.value);
34
- (0, logger_1.log)("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
33
+ try {
34
+ if (!unit) {
35
+ return next(new Error("Unit state not available"));
36
+ }
37
+ next(null, unit.value);
38
+ (0, logger_1.log)("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
39
+ }
40
+ catch (err) {
41
+ next(err);
42
+ }
35
43
  }).catch(err => next(err));
36
44
  }
37
45
  else {
38
- next(new Error("accessory - getState needs to be overridden if no unit is provided."));
46
+ next(new Error("accessory - getBrightness needs to be overridden if no unit is provided."));
39
47
  }
40
48
  }
41
49
  setPower(powerOn, next) {
@@ -41,14 +41,21 @@ export class Dimmer extends Accessory {
41
41
  getBrightness(next) {
42
42
  if (this.unit) {
43
43
  this.unit.reqState(unit => {
44
- next(null, unit.value);
45
- log("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
44
+ try {
45
+ if (!unit) {
46
+ return next(new Error("Unit state not available"));
47
+ }
48
+ next(null, unit.value);
49
+ log("accessory", "getBrightness was called for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
50
+ } catch(err) {
51
+ next(err);
52
+ }
46
53
  }).catch(err => next(err));
47
54
  } else {
48
- next( new Error("accessory - getState needs to be overridden if no unit is provided.") );
55
+ next( new Error("accessory - getBrightness needs to be overridden if no unit is provided.") );
49
56
  }
50
57
  }
51
-
58
+
52
59
  setPower(powerOn, next) {
53
60
  this.waitingSetPower = true;
54
61
  log("accessory", "setPower: *** waiting *** " + powerOn);
@@ -13,7 +13,7 @@ const accessory_1 = require("./accessory");
13
13
  class GarageDoor extends accessory_1.Accessory {
14
14
  constructor(homebridge, unit) {
15
15
  super(homebridge, unit);
16
- this.targetState = this.homebridge.Characteristic.CurrentDoorState.STOPPED;
16
+ this.targetState = this.homebridge.Characteristic.TargetDoorState.CLOSED;
17
17
  }
18
18
  getAccessoryServices() {
19
19
  // GarageDoorOpener needs authentication
@@ -39,13 +39,15 @@ class GarageDoor extends accessory_1.Accessory {
39
39
  return this.homebridge.Characteristic.CurrentDoorState.OPENING;
40
40
  else if (status == types_1.UnitState.kStopped)
41
41
  return this.homebridge.Characteristic.CurrentDoorState.STOPPED;
42
- else
43
- return this.homebridge.Characteristic.CurrentDoorState.STOPPED; // ????
42
+ else {
43
+ (0, logger_1.log)("accessory", `Unknown Door/UnitState ${status}, defaulting to STOPPED`);
44
+ return this.homebridge.Characteristic.CurrentDoorState.STOPPED;
45
+ }
44
46
  }
45
47
  HB2DT(state) {
46
- if (state == this.homebridge.Characteristic.CurrentDoorState.OPEN)
48
+ if (state == this.homebridge.Characteristic.TargetDoorState.OPEN)
47
49
  return types_1.UnitMotorCmd.kOpen;
48
- else if (state == this.homebridge.Characteristic.CurrentDoorState.CLOSED)
50
+ else if (state == this.homebridge.Characteristic.TargetDoorState.CLOSED)
49
51
  return types_1.UnitMotorCmd.kClose;
50
52
  else if (state == this.homebridge.Characteristic.CurrentDoorState.STOPPED)
51
53
  return types_1.UnitMotorCmd.kStop;
@@ -56,7 +58,7 @@ class GarageDoor extends accessory_1.Accessory {
56
58
  try {
57
59
  this.unit.reqState(unit => {
58
60
  const hb = this.DT2HB(unit.status);
59
- (0, logger_1.log)("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
61
+ (0, logger_1.log)("accessory", "Get CurrentDoorState of " + this.name + " = " + unit.status + " -> " + hb);
60
62
  next(null, hb);
61
63
  });
62
64
  }
@@ -86,9 +88,17 @@ class GarageDoor extends accessory_1.Accessory {
86
88
  }
87
89
  // in response to Duotecno status messages
88
90
  updateState() {
89
- const value = this.DT2HB(this.unit.status);
90
- (0, logger_1.log)("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
91
- this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
91
+ const current = this.DT2HB(this.unit.status);
92
+ const target = current === this.homebridge.Characteristic.CurrentDoorState.OPEN
93
+ ? this.homebridge.Characteristic.TargetDoorState.OPEN
94
+ : this.homebridge.Characteristic.TargetDoorState.CLOSED;
95
+ (0, logger_1.log)("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " -> passing to HB (current/target): " + current + " / " + target);
96
+ this.me
97
+ .getCharacteristic(this.homebridge.Characteristic.CurrentDoorState)
98
+ .updateValue(current);
99
+ this.me
100
+ .getCharacteristic(this.homebridge.Characteristic.TargetDoorState)
101
+ .updateValue(target);
92
102
  }
93
103
  }
94
104
  exports.GarageDoor = GarageDoor;
@@ -14,7 +14,7 @@ import { Accessory } from "./accessory";
14
14
 
15
15
 
16
16
  export class GarageDoor extends Accessory {
17
- targetState = this.homebridge.Characteristic.CurrentDoorState.STOPPED;
17
+ targetState = this.homebridge.Characteristic.TargetDoorState.CLOSED;
18
18
 
19
19
  constructor(homebridge: API, unit: Unit) {
20
20
  super(homebridge, unit);
@@ -56,15 +56,17 @@ export class GarageDoor extends Accessory {
56
56
  else if (status == UnitState.kStopped)
57
57
  return this.homebridge.Characteristic.CurrentDoorState.STOPPED;
58
58
 
59
- else
60
- return this.homebridge.Characteristic.CurrentDoorState.STOPPED; // ????
59
+ else {
60
+ log("accessory", `Unknown Door/UnitState ${status}, defaulting to STOPPED`);
61
+ return this.homebridge.Characteristic.CurrentDoorState.STOPPED;
62
+ }
61
63
  }
62
64
 
63
65
  HB2DT(state): UnitMotorCmd | null {
64
- if (state == this.homebridge.Characteristic.CurrentDoorState.OPEN)
66
+ if (state == this.homebridge.Characteristic.TargetDoorState.OPEN)
65
67
  return UnitMotorCmd.kOpen;
66
68
 
67
- else if (state == this.homebridge.Characteristic.CurrentDoorState.CLOSED)
69
+ else if (state == this.homebridge.Characteristic.TargetDoorState.CLOSED)
68
70
  return UnitMotorCmd.kClose;
69
71
 
70
72
  else if (state == this.homebridge.Characteristic.CurrentDoorState.STOPPED)
@@ -78,7 +80,7 @@ export class GarageDoor extends Accessory {
78
80
  try {
79
81
  this.unit.reqState(unit => {
80
82
  const hb = this.DT2HB(unit.status);
81
- log("accessory", "Get TargetDoorState of " + this.name + " = " + unit.status + " -> " + hb);
83
+ log("accessory", "Get CurrentDoorState of " + this.name + " = " + unit.status + " -> " + hb);
82
84
  next(null, hb);
83
85
  });
84
86
 
@@ -114,9 +116,19 @@ export class GarageDoor extends Accessory {
114
116
 
115
117
  // in response to Duotecno status messages
116
118
  updateState() {
117
- const value = this.DT2HB(this.unit.status);
118
- log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " / " + this.unit.value + " -> passing to HB: " + value);
119
- this.me.getCharacteristic(this.homebridge.Characteristic.CurrentDoorState).updateValue(value);
119
+ const current = this.DT2HB(this.unit.status);
120
+ const target =
121
+ current === this.homebridge.Characteristic.CurrentDoorState.OPEN
122
+ ? this.homebridge.Characteristic.TargetDoorState.OPEN
123
+ : this.homebridge.Characteristic.TargetDoorState.CLOSED;
124
+
125
+ log("accessory", "Received updateState -> Homekit GarageDoor for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.status + " -> passing to HB (current/target): " + current + " / " + target);
126
+ this.me
127
+ .getCharacteristic(this.homebridge.Characteristic.CurrentDoorState)
128
+ .updateValue(current);
129
+ this.me
130
+ .getCharacteristic(this.homebridge.Characteristic.TargetDoorState)
131
+ .updateValue(target);
120
132
  }
121
133
 
122
134
  }
@@ -63,9 +63,17 @@ class Lock extends accessory_1.Accessory {
63
63
  }
64
64
  getCurrent(next) {
65
65
  this.unit.reqState(unit => {
66
- (0, logger_1.log)("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
67
- next(null, !!this.unit.status);
68
- });
66
+ try {
67
+ if (!unit) {
68
+ return next(new Error("Unit state not available"));
69
+ }
70
+ (0, logger_1.log)("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
71
+ next(null, !!this.unit.status);
72
+ }
73
+ catch (err) {
74
+ next(err);
75
+ }
76
+ }).catch(err => next(err));
69
77
  }
70
78
  // in response to Duotecno status messages
71
79
  updateState() {
@@ -81,9 +81,16 @@ export class Lock extends Accessory {
81
81
 
82
82
  getCurrent(next) {
83
83
  this.unit.reqState(unit => {
84
- log("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
85
- next(null, !!this.unit.status);
86
- });
84
+ try {
85
+ if (!unit) {
86
+ return next(new Error("Unit state not available"));
87
+ }
88
+ log("accessory", "HB getting current state of lock = " + this.unit.status + " of " + this.unit.getDescription());
89
+ next(null, !!this.unit.status);
90
+ } catch(err) {
91
+ next(err);
92
+ }
93
+ }).catch(err => next(err));
87
94
  }
88
95
 
89
96
 
@@ -23,8 +23,16 @@ class Temperature extends accessory_1.Accessory {
23
23
  getTemperature(next) {
24
24
  if (this.unit) {
25
25
  this.unit.reqState(unit => {
26
- (0, logger_1.log)("accessory", "reqState/getTemperature returned a value for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
27
- next(null, unit.value / 10.0);
26
+ try {
27
+ if (!unit) {
28
+ return next(new Error("Unit state not available"));
29
+ }
30
+ (0, logger_1.log)("accessory", "reqState/getTemperature returned a value for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
31
+ next(null, unit.value / 10.0);
32
+ }
33
+ catch (err) {
34
+ next(err);
35
+ }
28
36
  })
29
37
  .catch(err => next(err));
30
38
  }
@@ -31,8 +31,15 @@ export class Temperature extends Accessory {
31
31
  getTemperature(next) {
32
32
  if (this.unit) {
33
33
  this.unit.reqState(unit => {
34
- log("accessory", "reqState/getTemperature returned a value for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
35
- next(null, <number>unit.value / 10.0);
34
+ try {
35
+ if (!unit) {
36
+ return next(new Error("Unit state not available"));
37
+ }
38
+ log("accessory", "reqState/getTemperature returned a value for " + this.unit.node.getName() + " - " + this.unit.getName() + " -> " + this.unit.value);
39
+ next(null, <number>unit.value / 10.0);
40
+ } catch(err) {
41
+ next(err);
42
+ }
36
43
  })
37
44
  .catch(err => next(err));
38
45
  } else {
@@ -93,13 +93,21 @@ class WindowCovering extends accessory_1.Accessory {
93
93
  getCurrentPosition(next) {
94
94
  (0, logger_1.log)("accessory", "get CurrentPosition was called of " + this.name);
95
95
  this.unit.reqState(unit => {
96
- if (unit.status == types_1.UnitState.kOpen)
97
- next(null, 100);
98
- else if (unit.status == types_1.UnitState.kClosed)
99
- next(null, 0);
100
- else
101
- next(null, 50); // ????
102
- });
96
+ try {
97
+ if (!unit) {
98
+ return next(new Error("Unit state not available"));
99
+ }
100
+ if (unit.status == types_1.UnitState.kOpen)
101
+ next(null, 100);
102
+ else if (unit.status == types_1.UnitState.kClosed)
103
+ next(null, 0);
104
+ else
105
+ next(null, 50);
106
+ }
107
+ catch (err) {
108
+ next(err);
109
+ }
110
+ }).catch(err => next(err));
103
111
  }
104
112
  setTargetPosition(value, next) {
105
113
  // homekit is giving 0-100 for windows
@@ -123,13 +131,21 @@ class WindowCovering extends accessory_1.Accessory {
123
131
  getTargetPosition(next) {
124
132
  (0, logger_1.log)("accessory", "get Characteristic.TargetPosition was called");
125
133
  this.unit.reqState(unit => {
126
- if (this.unit.status == types_1.UnitState.kOpen)
127
- next(null, 100);
128
- else if (this.unit.status == types_1.UnitState.kClosed)
129
- next(null, 0);
130
- else
131
- next(null, 50); // ????
132
- });
134
+ try {
135
+ if (!unit) {
136
+ return next(new Error("Unit state not available"));
137
+ }
138
+ if (this.unit.status == types_1.UnitState.kOpen)
139
+ next(null, 100);
140
+ else if (this.unit.status == types_1.UnitState.kClosed)
141
+ next(null, 0);
142
+ else
143
+ next(null, 50);
144
+ }
145
+ catch (err) {
146
+ next(err);
147
+ }
148
+ }).catch(err => next(err));
133
149
  }
134
150
  // called in response to Duotecno status update
135
151
  updateState() {
@@ -110,15 +110,22 @@ export class WindowCovering extends Accessory {
110
110
 
111
111
  getCurrentPosition(next) {
112
112
  log("accessory", "get CurrentPosition was called of " + this.name);
113
-
113
+
114
114
  this.unit.reqState(unit => {
115
- if (unit.status == UnitState.kOpen)
116
- next(null, 100);
117
- else if (unit.status == UnitState.kClosed)
118
- next(null, 0);
119
- else
120
- next(null, 50); // ????
121
- });
115
+ try {
116
+ if (!unit) {
117
+ return next(new Error("Unit state not available"));
118
+ }
119
+ if (unit.status == UnitState.kOpen)
120
+ next(null, 100);
121
+ else if (unit.status == UnitState.kClosed)
122
+ next(null, 0);
123
+ else
124
+ next(null, 50);
125
+ } catch(err) {
126
+ next(err);
127
+ }
128
+ }).catch(err => next(err));
122
129
  }
123
130
 
124
131
 
@@ -147,13 +154,20 @@ export class WindowCovering extends Accessory {
147
154
  log("accessory", "get Characteristic.TargetPosition was called");
148
155
 
149
156
  this.unit.reqState(unit => {
150
- if (this.unit.status == UnitState.kOpen)
151
- next(null, 100);
152
- else if (this.unit.status == UnitState.kClosed)
153
- next(null, 0);
154
- else
155
- next(null, 50); // ????
156
- });
157
+ try {
158
+ if (!unit) {
159
+ return next(new Error("Unit state not available"));
160
+ }
161
+ if (this.unit.status == UnitState.kOpen)
162
+ next(null, 100);
163
+ else if (this.unit.status == UnitState.kClosed)
164
+ next(null, 0);
165
+ else
166
+ next(null, 50);
167
+ } catch(err) {
168
+ next(err);
169
+ }
170
+ }).catch(err => next(err));
157
171
  }
158
172
 
159
173
  // called in response to Duotecno status update
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.8.13",
4
+ "version": "6.8.18",
5
5
  "description": "SmartServer (Proxy TCP sockets to the cloud, Smappee MQTT, Duotecno IP Nodes, Homekit interface)",
6
6
  "main": "index.js",
7
7
  "author": "Johan Coppieters",
@@ -10,7 +10,11 @@
10
10
  "scripts": {
11
11
  "start": "DEBUG=* homebridge -D -P '/Users/johan/Development/duotecno/smartsocket'",
12
12
  "watch": "npx tsc --build . --watch",
13
- "publish": "npx tsc --build && npm i && npm publish"
13
+ "build": "npx tsc --build",
14
+ "prepublishOnly": "npm run build",
15
+ "publish": "npm publish",
16
+ "version:patch": "npm version patch && npm publish",
17
+ "version:minor": "npm version minor && npm publish"
14
18
  },
15
19
  "engines": {
16
20
  "node": "^18.20.4 || ^20.15.1 || ^22",