homebridge-smartsystem 6.4.5 → 6.4.7

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/config.json CHANGED
@@ -315,7 +315,7 @@
315
315
  "masterPort": 5001,
316
316
  "name": "<Solar Panels",
317
317
  "displayName": "<Solar Panels",
318
- "extendedType": 0,
318
+ "extendedType": 4,
319
319
  "active": "N",
320
320
  "used": "Y",
321
321
  "group": 0
@@ -327,7 +327,7 @@
327
327
  "masterPort": 5001,
328
328
  "name": ">Cars",
329
329
  "displayName": ">Cars",
330
- "extendedType": 0,
330
+ "extendedType": 4,
331
331
  "active": "N",
332
332
  "used": "Y",
333
333
  "group": 0
@@ -339,7 +339,7 @@
339
339
  "masterPort": 5001,
340
340
  "name": ">Grid",
341
341
  "displayName": ">Grid",
342
- "extendedType": 0,
342
+ "extendedType": 4,
343
343
  "active": "N",
344
344
  "used": "Y",
345
345
  "group": 0
@@ -351,7 +351,7 @@
351
351
  "masterPort": 5001,
352
352
  "name": ">Swimmingpool",
353
353
  "displayName": ">Swimmingpool",
354
- "extendedType": 0,
354
+ "extendedType": 4,
355
355
  "active": "N",
356
356
  "used": "Y",
357
357
  "group": 0
@@ -268,7 +268,7 @@ export class Unit {
268
268
  if (this.type === UnitType.kSwitchingMotor)
269
269
  return (((this.value == UnitState.kOpening) && (value == 4)) ||
270
270
  ((this.value == UnitState.kClosing) && (value == 5)) ||
271
- ((this.value <= UnitState.kOpen) && (value == 3)));
271
+ ((this.value as number <= UnitState.kOpen) && (value == 3)));
272
272
  else
273
273
  return this.value == value;
274
274
  }
@@ -803,7 +803,7 @@ export const Protocol = {
803
803
 
804
804
  case UnitType.kInput:
805
805
  case UnitType.kMood:
806
- if (value < 0)
806
+ if (value as number < 0)
807
807
  return { cmd: Cmd.SetControl, method: 2 }; // short pulse
808
808
  else
809
809
  return { cmd: Cmd.SetControl, method: 3, value: (value) ? 1 : 0 }; // long event + 0/1
package/log.txt ADDED
@@ -0,0 +1,61 @@
1
+ ...
2
+ accessory: getState was called for SB 1 - Lamp-Bottom -> 1
3
+ smartapp: HTTP-Switch(true) -> http://localhost:3001/api/demo/haha?set=true
4
+ smartapp: The request to http://localhost:3001/api/demo/haha?set=true, error:
5
+ accessory: getState was called for SB 1 - Lamp-Top -> 1
6
+ accessory: setPower: *** waiting *** false
7
+ accessory: setPower: false
8
+ smartapp: The request to http://192.168.0.96/light/0?brightness=75&turn=off, error: connect EHOSTUNREACH 192.168.0.96:80
9
+ smartapp: The request to http://192.168.0.96/light/0?brightness=75&turn=off, error: connect EHOSTUNREACH 192.168.0.96:80
10
+ master: 192.168.0.97: receiveRegister(1) = 3450
11
+ accessory: setPower: *** waiting *** false
12
+ accessory: setPower: false
13
+ master: 192.168.0.97: receiveRegister(12) = 696
14
+ power: smappee > RealTime totals: Power = 4350, Export = 72508338000, Import = 532857808800
15
+ master: 192.168.0.97: receiveRegister(2) = 914
16
+ power: p1 > RealTime totals: Power = 915, Export = 15971.894, Import = 60105.418
17
+ master: 192.168.0.97: Received heartbeat at Tue May 20 2025 10:20:19 GMT+0200 (Central European Summer Time)
18
+ master: 192.168.0.5: Received heartbeat at Tue May 20 2025 10:20:19 GMT+0200 (Central European Summer Time)
19
+ power: shelly > RealTime totals: Power = 132.24, Export = 0, Import = 265734.9
20
+ master: 192.168.0.97: receiveRegister(1) = 3450
21
+ master: 192.168.0.97: receiveRegister(12) = 914
22
+ accessory: get CurrentPosition was called of Salon Top
23
+ accessory: get PositionState was called of Salon Top -> 0
24
+ accessory: get Characteristic.TargetPosition was called
25
+ accessory: get CurrentPosition was called of Tim Small
26
+ accessory: get PositionState was called of Tim Small -> 0
27
+ accessory: get Characteristic.TargetPosition was called
28
+ ...
29
+ accessory: getBrightness was called for SB 1 - Red LED -> 75
30
+ accessory: getState was called for SB 1 - Lamp-Bottom -> 1
31
+ smartapp: HTTP-Switch(true) -> http://localhost:3001/api/demo/haha?set=true
32
+ smartapp: The request to http://localhost:3001/api/demo/haha?set=true, error:
33
+ accessory: getState was called for SB 1 - Lamp-Top -> 1
34
+ accessory: setBrightness 54
35
+ accessory: setBrightness 55
36
+ accessory: setBrightness 73
37
+ accessory: setBrightness 63
38
+ master: 192.168.0.97: receiveRegister(2) = 757
39
+ accessory: setBrightness 100
40
+ [20/05/2025, 10:20:36] TypeError: Cannot read properties of undefined (reading 'message')
41
+ at ClientRequest.<anonymous> (/var/lib/homebridge/node_modules/homebridge-smartsystem/server/smartapp.js:706:91)
42
+ at ClientRequest.emit (node:events:518:28)
43
+ at Socket.emitRequestTimeout (node:_http_client:863:9)
44
+ at Object.onceWrapper (node:events:632:28)
45
+ at Socket.emit (node:events:530:35)
46
+ at Socket._onTimeout (node:net:609:8)
47
+ at listOnTimeout (node:internal/timers:588:17)
48
+ at processTimers (node:internal/timers:523:7)
49
+ [20/05/2025, 10:20:36] Got SIGTERM, shutting down Homebridge...
50
+ [20/05/2025, 10:20:36] TypeError: Cannot read properties of undefined (reading 'message')
51
+ at ClientRequest.<anonymous> (/var/lib/homebridge/node_modules/homebridge-smartsystem/server/smartapp.js:706:91)
52
+ at ClientRequest.emit (node:events:518:28)
53
+ at Socket.emitRequestTimeout (node:_http_client:863:9)
54
+ at Object.onceWrapper (node:events:632:28)
55
+ at Socket.emit (node:events:530:35)
56
+ at Socket._onTimeout (node:net:609:8)
57
+ at listOnTimeout (node:internal/timers:588:17)
58
+ at processTimers (node:internal/timers:523:7)
59
+ master: 192.168.0.97: receiveRegister(1) = 3359
60
+ [20/05/2025, 10:20:41] [HB Supervisor] Homebridge process ended. Code: 143, signal: null.
61
+ [20/05/2025, 10:20:46] [HB Supervisor] Restarting Homebridge...
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.4.5",
4
+ "version": "6.4.7",
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",
@@ -700,15 +700,15 @@ class SmartApp extends webapp_1.WebApp {
700
700
  req.write(formdata);
701
701
  }
702
702
  req.on("error", (e) => {
703
- (0, logger_1.log)("smartapp", "The request to " + url + ", error: " + e.message);
703
+ (0, logger_1.log)("smartapp", "The request to " + url + ", error: " + (e ? e.message : "unknown"));
704
704
  });
705
705
  req.on("timeout", (e) => {
706
- (0, logger_1.log)("smartapp", "The request to " + url + ", timeout: " + e.message);
706
+ (0, logger_1.log)("smartapp", "The request to " + url + ", timeout: " + (e ? e.message : "unknown"));
707
707
  });
708
708
  req.end();
709
709
  }
710
710
  catch (e) {
711
- (0, logger_1.log)("smartapp", "** http error ** " + e.message + " **");
711
+ (0, logger_1.log)("smartapp", "** http error ** " + (e ? e.message : "unknown") + " **");
712
712
  }
713
713
  }
714
714
  //////////////
@@ -881,11 +881,32 @@ class SmartApp extends webapp_1.WebApp {
881
881
  // reponding to /units/[master ip address:port]/[logical node address]
882
882
  const nodeLogicalAddress = parseInt(context.id);
883
883
  let response = yield this.getNodeInfo(master, nodeLogicalAddress, true);
884
+ this.adjustUnitsToConfig(response.node);
884
885
  let N = this.sortCopy(response.node, context);
885
886
  return this.ejs("nodeDetail", context, { message: response.message, node: N });
886
887
  }
887
888
  });
888
889
  }
890
+ adjustUnitsToConfig(node) {
891
+ // check if units are still in config
892
+ node.units.forEach(unit => {
893
+ //console.log("Searching: ", unit.node.master.config.address, unit.node.master.config.port, unit.logicalNodeAddress, unit.logicalAddress)
894
+ const config = this.system.config.cunits.find(u => {
895
+ // console.log(u.masterAddress, u.masterPort, u.logicalNodeAddress, u.logicalAddress, ((unit.node.master.hasAddress(u.masterAddress) &&
896
+ // unit.node.master.hasPort(u.masterPort) &&
897
+ // (u.logicalNodeAddress == unit.logicalNodeAddress) &&
898
+ // (u.logicalAddress === unit.logicalAddress))));
899
+ return (unit.node.master.hasAddress(u.masterAddress) &&
900
+ unit.node.master.hasPort(u.masterPort) &&
901
+ (u.logicalNodeAddress == unit.logicalNodeAddress) &&
902
+ (u.logicalAddress === unit.logicalAddress));
903
+ });
904
+ if (config) {
905
+ unit.extendedType = config.extendedType;
906
+ unit.name = config.displayName;
907
+ }
908
+ });
909
+ }
889
910
  sortCopy(N, context) {
890
911
  // only need to re-sort if onAddress is requested, units should always be sorted on name
891
912
  const S = context["sortOnAddr"] = context.getParam({ name: "sortOnAddr", type: "string", default: "N" });
@@ -759,15 +759,15 @@ export class SmartApp extends WebApp {
759
759
  req.write(formdata);
760
760
  }
761
761
  req.on("error", (e) => {
762
- log("smartapp", "The request to " + url + ", error: " + e.message);
762
+ log("smartapp", "The request to " + url + ", error: " + (e ? e.message : "unknown"));
763
763
  });
764
764
  req.on("timeout", (e) => {
765
- log("smartapp", "The request to " + url + ", timeout: " + e.message);
765
+ log("smartapp", "The request to " + url + ", timeout: " + (e ? e.message : "unknown"));
766
766
  });
767
767
  req.end();
768
768
 
769
769
  } catch(e) {
770
- log("smartapp", "** http error ** " + e.message + " **");
770
+ log("smartapp", "** http error ** " + (e ? e.message : "unknown") + " **");
771
771
  }
772
772
  }
773
773
 
@@ -943,11 +943,34 @@ export class SmartApp extends WebApp {
943
943
  // reponding to /units/[master ip address:port]/[logical node address]
944
944
  const nodeLogicalAddress = parseInt(context.id);
945
945
  let response = await this.getNodeInfo(master, nodeLogicalAddress, true);
946
+ this.adjustUnitsToConfig(response.node);
946
947
  let N = this.sortCopy(response.node, context);
947
948
  return this.ejs("nodeDetail", context, { message: response.message, node: N });
948
949
  }
949
950
  }
950
951
 
952
+ adjustUnitsToConfig(node: Node) {
953
+ // check if units are still in config
954
+ node.units.forEach(unit => {
955
+ //console.log("Searching: ", unit.node.master.config.address, unit.node.master.config.port, unit.logicalNodeAddress, unit.logicalAddress)
956
+ const config = this.system.config.cunits.find(u => {
957
+ // console.log(u.masterAddress, u.masterPort, u.logicalNodeAddress, u.logicalAddress, ((unit.node.master.hasAddress(u.masterAddress) &&
958
+ // unit.node.master.hasPort(u.masterPort) &&
959
+ // (u.logicalNodeAddress == unit.logicalNodeAddress) &&
960
+ // (u.logicalAddress === unit.logicalAddress))));
961
+
962
+ return (unit.node.master.hasAddress(u.masterAddress) &&
963
+ unit.node.master.hasPort(u.masterPort) &&
964
+ (u.logicalNodeAddress == unit.logicalNodeAddress) &&
965
+ (u.logicalAddress === unit.logicalAddress));
966
+ });
967
+ if (config) {
968
+ unit.extendedType = config.extendedType;
969
+ unit.name = config.displayName;
970
+ }
971
+ });
972
+ }
973
+
951
974
 
952
975
  sortCopy(N: Node, context: Context): Node {
953
976
  // only need to re-sort if onAddress is requested, units should always be sorted on name
@@ -8,7 +8,7 @@
8
8
  <% if (hasP1) { %><li <%= ((request === "power") && (type === "p1")) ? 'class="active"' : '' %></li><a href="/power?type=p1">P1</a></li><% } %>
9
9
  <% if (hasShelly) { %><li <%= ((request === "power") && (type === "shelly")) ? 'class="active"' : '' %></li><a href="/power?type=shelly">Shelly PM</a></li><% } %>
10
10
  <li <%= (request === "switches") ? 'class="active"' : '' %></li><a href="/switches">Switches</a></li>
11
- <li <%= (request === "settings") ? 'class="active"' : '' %></li><a href="/settings">Settings</a></li>
11
+ <!-- li <%= (request === "settings") ? 'class="active"' : '' %></li><a href="/settings">Settings</a></li -->
12
12
  </ul>
13
13
  </div>
14
14
  </nav>
@@ -23,7 +23,7 @@
23
23
  <table>
24
24
  <thead>
25
25
  <tr>
26
- <th>Name</th><th>Plug/Http</th><th>Addr</th><th>State</th>
26
+ <th>Name</th><th>Plug/Http</th><th>Addr</th><!-- th>State</th -->
27
27
  </tr>
28
28
  </thead>
29
29
 
@@ -33,7 +33,7 @@
33
33
  <td><a href="/switches/edit/<%= inx %>"><%= swtch.name %></a><br><small><%= swtch.type %></small></td>
34
34
  <td><a href="/switches/edit/<%= inx %>"><%= swtch.plug %></a></td>
35
35
  <td><a href="/switches/edit/<%= inx %>"><%= hex(swtch.logicalNodeAddress) %>/<%= hex(swtch.logicalAddress) %></a></td>
36
- <td>
36
+ <!--td>
37
37
  <div class="switch">
38
38
  <label>Off
39
39
  <input name="status_<%= swtch.name %>" <%= (swtch.status) ? 'checked' : '' %>
@@ -41,7 +41,7 @@
41
41
  <span class="lever"></span>On
42
42
  </label>
43
43
  </div>
44
- </td>
44
+ </td -->
45
45
  </tr>
46
46
  <% } %>
47
47
  </tbody>