homebridge-smartsystem 7.1.5 → 7.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/smartapp.js +19 -28
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "7.1.5",
4
+ "version": "7.1.7",
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",
@@ -761,8 +761,12 @@ class SmartApp extends webapp_1.WebApp {
761
761
  sendDeviceList(ws) {
762
762
  const devices = this.getDeviceList();
763
763
  if (ws.readyState === WebSocket.OPEN) {
764
- (0, logger_1.debug)("smartapp", devices);
765
- ws.send(JSON.stringify(devices));
764
+ const json = JSON.stringify(devices);
765
+ (0, logger_1.log)("smartapp", "sendDeviceList -> " + json);
766
+ ws.send(json);
767
+ }
768
+ else {
769
+ (0, logger_1.log)("smartapp", "sendDeviceList -> WebSocket not open (state=" + ws.readyState + ")");
766
770
  }
767
771
  }
768
772
  getDeviceList() {
@@ -772,6 +776,7 @@ class SmartApp extends webapp_1.WebApp {
772
776
  if (device.unit) {
773
777
  relayState = device.unit.status > 0;
774
778
  }
779
+ (0, logger_1.log)("smartapp", `getDeviceList: device "${device.name}" (id=${device.id}) powerSource=${device.powerSource} powerChannel="${device.powerChannel}" relay=${relayState}`);
775
780
  // Get power measurements based on power source
776
781
  let power = 0;
777
782
  let energy = 0;
@@ -810,6 +815,7 @@ class SmartApp extends webapp_1.WebApp {
810
815
  power = relayState ? (device.estimatedPower || 0) : 0;
811
816
  measured = false;
812
817
  }
818
+ (0, logger_1.log)("smartapp", `getDeviceList: -> power=${power} measured=${measured}`);
813
819
  return {
814
820
  id: device.id,
815
821
  name: device.name,
@@ -826,16 +832,9 @@ class SmartApp extends webapp_1.WebApp {
826
832
  if (!this.power.smappee)
827
833
  return null;
828
834
  try {
829
- // Channel format could be "0", "0+1", "0+1+2", etc.
830
- const channels = channel.split('+').map(c => parseInt(c.trim()));
831
- let totalPower = 0;
832
- for (const ch of channels) {
833
- const binding = this.power.smappee.bindings.find(b => b.channel === ch.toString());
834
- if (binding && binding.value !== undefined) {
835
- totalPower += binding.value;
836
- }
837
- }
838
- return totalPower;
835
+ const power = this.power.smappee.evalPower(channel);
836
+ (0, logger_1.log)("smartapp", `getPowerFromSmappee: channel="${channel}" -> power=${power}`);
837
+ return power;
839
838
  }
840
839
  catch (e) {
841
840
  (0, logger_1.err)("smartapp", `Error getting Smappee power for channel ${channel}: ${e.message}`);
@@ -846,12 +845,9 @@ class SmartApp extends webapp_1.WebApp {
846
845
  if (!this.power.p1)
847
846
  return null;
848
847
  try {
849
- // P1 meter typically has single power value
850
- const binding = this.power.p1.bindings.find(b => b.channel === channel);
851
- if (binding && binding.value !== undefined) {
852
- return binding.value;
853
- }
854
- return null;
848
+ const power = this.power.p1.evalPower(channel);
849
+ (0, logger_1.log)("smartapp", `getPowerFromP1: channel="${channel}" -> power=${power}`);
850
+ return power;
855
851
  }
856
852
  catch (e) {
857
853
  (0, logger_1.err)("smartapp", `Error getting P1 power for channel ${channel}: ${e.message}`);
@@ -862,16 +858,9 @@ class SmartApp extends webapp_1.WebApp {
862
858
  if (!this.power.shelly)
863
859
  return null;
864
860
  try {
865
- // Shelly channel format similar to Smappee
866
- const channels = channel.split('+').map(c => parseInt(c.trim()));
867
- let totalPower = 0;
868
- for (const ch of channels) {
869
- const binding = this.power.shelly.bindings.find(b => b.channel === ch.toString());
870
- if (binding && binding.value !== undefined) {
871
- totalPower += binding.value;
872
- }
873
- }
874
- return totalPower;
861
+ const power = this.power.shelly.evalPower(channel);
862
+ (0, logger_1.log)("smartapp", `getPowerFromShelly: channel="${channel}" -> power=${power}`);
863
+ return power;
875
864
  }
876
865
  catch (e) {
877
866
  (0, logger_1.err)("smartapp", `Error getting Shelly power for channel ${channel}: ${e.message}`);
@@ -880,6 +869,7 @@ class SmartApp extends webapp_1.WebApp {
880
869
  }
881
870
  handleDeviceMessage(ws, data) {
882
871
  return __awaiter(this, void 0, void 0, function* () {
872
+ (0, logger_1.log)("smartapp", "handleDeviceMessage: received -> " + JSON.stringify(data));
883
873
  if (!Array.isArray(data)) {
884
874
  (0, logger_1.err)("smartapp", "WebSocket message must be an array");
885
875
  return;
@@ -887,6 +877,7 @@ class SmartApp extends webapp_1.WebApp {
887
877
  // Process relay control commands if any
888
878
  for (const cmd of data) {
889
879
  if (cmd.id && cmd.relay !== undefined) {
880
+ (0, logger_1.log)("smartapp", `handleDeviceMessage: relay command id=${cmd.id} state=${cmd.relay}`);
890
881
  yield this.setDeviceRelay(cmd.id, cmd.relay);
891
882
  }
892
883
  }