homebridge-smartsystem 7.1.5 → 7.1.6
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/package.json +1 -1
- package/server/smartapp.js +26 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-smartsystem",
|
|
3
3
|
"displayname": "Duotecno Bridge",
|
|
4
|
-
"version": "7.1.
|
|
4
|
+
"version": "7.1.6",
|
|
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",
|
package/server/smartapp.js
CHANGED
|
@@ -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
|
-
|
|
765
|
-
|
|
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,
|
|
@@ -828,12 +834,18 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
828
834
|
try {
|
|
829
835
|
// Channel format could be "0", "0+1", "0+1+2", etc.
|
|
830
836
|
const channels = channel.split('+').map(c => parseInt(c.trim()));
|
|
837
|
+
const available = this.power.smappee.bindings.map(b => `ch=${b.channel}(${b.value})`).join(', ');
|
|
838
|
+
(0, logger_1.log)("smartapp", `getPowerFromSmappee: looking for channel(s) [${channels}], available bindings: [${available}]`);
|
|
831
839
|
let totalPower = 0;
|
|
832
840
|
for (const ch of channels) {
|
|
833
841
|
const binding = this.power.smappee.bindings.find(b => b.channel === ch.toString());
|
|
834
842
|
if (binding && binding.value !== undefined) {
|
|
843
|
+
(0, logger_1.log)("smartapp", `getPowerFromSmappee: matched ch=${ch} -> value=${binding.value}`);
|
|
835
844
|
totalPower += binding.value;
|
|
836
845
|
}
|
|
846
|
+
else {
|
|
847
|
+
(0, logger_1.log)("smartapp", `getPowerFromSmappee: no match for ch=${ch}`);
|
|
848
|
+
}
|
|
837
849
|
}
|
|
838
850
|
return totalPower;
|
|
839
851
|
}
|
|
@@ -847,10 +859,14 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
847
859
|
return null;
|
|
848
860
|
try {
|
|
849
861
|
// P1 meter typically has single power value
|
|
862
|
+
const available = this.power.p1.bindings.map(b => `ch=${b.channel}(${b.value})`).join(', ');
|
|
863
|
+
(0, logger_1.log)("smartapp", `getPowerFromP1: looking for channel "${channel}", available bindings: [${available}]`);
|
|
850
864
|
const binding = this.power.p1.bindings.find(b => b.channel === channel);
|
|
851
865
|
if (binding && binding.value !== undefined) {
|
|
866
|
+
(0, logger_1.log)("smartapp", `getPowerFromP1: matched ch=${channel} -> value=${binding.value}`);
|
|
852
867
|
return binding.value;
|
|
853
868
|
}
|
|
869
|
+
(0, logger_1.log)("smartapp", `getPowerFromP1: no match for channel "${channel}"`);
|
|
854
870
|
return null;
|
|
855
871
|
}
|
|
856
872
|
catch (e) {
|
|
@@ -864,12 +880,18 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
864
880
|
try {
|
|
865
881
|
// Shelly channel format similar to Smappee
|
|
866
882
|
const channels = channel.split('+').map(c => parseInt(c.trim()));
|
|
883
|
+
const available = this.power.shelly.bindings.map(b => `ch=${b.channel}(${b.value})`).join(', ');
|
|
884
|
+
(0, logger_1.log)("smartapp", `getPowerFromShelly: looking for channel(s) [${channels}], available bindings: [${available}]`);
|
|
867
885
|
let totalPower = 0;
|
|
868
886
|
for (const ch of channels) {
|
|
869
887
|
const binding = this.power.shelly.bindings.find(b => b.channel === ch.toString());
|
|
870
888
|
if (binding && binding.value !== undefined) {
|
|
889
|
+
(0, logger_1.log)("smartapp", `getPowerFromShelly: matched ch=${ch} -> value=${binding.value}`);
|
|
871
890
|
totalPower += binding.value;
|
|
872
891
|
}
|
|
892
|
+
else {
|
|
893
|
+
(0, logger_1.log)("smartapp", `getPowerFromShelly: no match for ch=${ch}`);
|
|
894
|
+
}
|
|
873
895
|
}
|
|
874
896
|
return totalPower;
|
|
875
897
|
}
|
|
@@ -880,6 +902,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
880
902
|
}
|
|
881
903
|
handleDeviceMessage(ws, data) {
|
|
882
904
|
return __awaiter(this, void 0, void 0, function* () {
|
|
905
|
+
(0, logger_1.log)("smartapp", "handleDeviceMessage: received -> " + JSON.stringify(data));
|
|
883
906
|
if (!Array.isArray(data)) {
|
|
884
907
|
(0, logger_1.err)("smartapp", "WebSocket message must be an array");
|
|
885
908
|
return;
|
|
@@ -887,6 +910,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
887
910
|
// Process relay control commands if any
|
|
888
911
|
for (const cmd of data) {
|
|
889
912
|
if (cmd.id && cmd.relay !== undefined) {
|
|
913
|
+
(0, logger_1.log)("smartapp", `handleDeviceMessage: relay command id=${cmd.id} state=${cmd.relay}`);
|
|
890
914
|
yield this.setDeviceRelay(cmd.id, cmd.relay);
|
|
891
915
|
}
|
|
892
916
|
}
|