homebridge-smartsystem 7.1.7 → 7.1.10
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 +9 -11
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.10",
|
|
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
|
@@ -659,7 +659,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
661
|
deleteLink(inx) {
|
|
662
|
-
if ((inx >= 0) && (inx < this.
|
|
662
|
+
if ((inx >= 0) && (inx < this.links.length)) {
|
|
663
663
|
this.links.splice(inx, 1);
|
|
664
664
|
this.initLinks();
|
|
665
665
|
this.writeConfig();
|
|
@@ -762,11 +762,11 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
762
762
|
const devices = this.getDeviceList();
|
|
763
763
|
if (ws.readyState === WebSocket.OPEN) {
|
|
764
764
|
const json = JSON.stringify(devices);
|
|
765
|
-
(0, logger_1.
|
|
765
|
+
(0, logger_1.debug)("smartapp", "sendDeviceList -> " + json);
|
|
766
766
|
ws.send(json);
|
|
767
767
|
}
|
|
768
768
|
else {
|
|
769
|
-
(0, logger_1.
|
|
769
|
+
(0, logger_1.err)("smartapp", "sendDeviceList -> WebSocket not open (state=" + ws.readyState + ")");
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
772
|
getDeviceList() {
|
|
@@ -776,7 +776,6 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
776
776
|
if (device.unit) {
|
|
777
777
|
relayState = device.unit.status > 0;
|
|
778
778
|
}
|
|
779
|
-
(0, logger_1.log)("smartapp", `getDeviceList: device "${device.name}" (id=${device.id}) powerSource=${device.powerSource} powerChannel="${device.powerChannel}" relay=${relayState}`);
|
|
780
779
|
// Get power measurements based on power source
|
|
781
780
|
let power = 0;
|
|
782
781
|
let energy = 0;
|
|
@@ -815,7 +814,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
815
814
|
power = relayState ? (device.estimatedPower || 0) : 0;
|
|
816
815
|
measured = false;
|
|
817
816
|
}
|
|
818
|
-
(0, logger_1.
|
|
817
|
+
(0, logger_1.debug)("smartapp", `getDeviceList: device "${device.name}" (id=${device.id}) powerSource=${device.powerSource} powerChannel="${device.powerChannel}" relay=${relayState} power=${power} measured=${measured}`);
|
|
819
818
|
return {
|
|
820
819
|
id: device.id,
|
|
821
820
|
name: device.name,
|
|
@@ -833,7 +832,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
833
832
|
return null;
|
|
834
833
|
try {
|
|
835
834
|
const power = this.power.smappee.evalPower(channel);
|
|
836
|
-
|
|
835
|
+
//log("smartapp", `getPowerFromSmappee: channel="${channel}" -> power=${power}`);
|
|
837
836
|
return power;
|
|
838
837
|
}
|
|
839
838
|
catch (e) {
|
|
@@ -846,7 +845,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
846
845
|
return null;
|
|
847
846
|
try {
|
|
848
847
|
const power = this.power.p1.evalPower(channel);
|
|
849
|
-
|
|
848
|
+
//log("smartapp", `getPowerFromP1: channel="${channel}" -> power=${power}`);
|
|
850
849
|
return power;
|
|
851
850
|
}
|
|
852
851
|
catch (e) {
|
|
@@ -859,7 +858,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
859
858
|
return null;
|
|
860
859
|
try {
|
|
861
860
|
const power = this.power.shelly.evalPower(channel);
|
|
862
|
-
|
|
861
|
+
//log("smartapp", `getPowerFromShelly: channel="${channel}" -> power=${power}`);
|
|
863
862
|
return power;
|
|
864
863
|
}
|
|
865
864
|
catch (e) {
|
|
@@ -869,7 +868,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
869
868
|
}
|
|
870
869
|
handleDeviceMessage(ws, data) {
|
|
871
870
|
return __awaiter(this, void 0, void 0, function* () {
|
|
872
|
-
|
|
871
|
+
//log("smartapp", "handleDeviceMessage: received -> " + JSON.stringify(data));
|
|
873
872
|
if (!Array.isArray(data)) {
|
|
874
873
|
(0, logger_1.err)("smartapp", "WebSocket message must be an array");
|
|
875
874
|
return;
|
|
@@ -877,7 +876,6 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
877
876
|
// Process relay control commands if any
|
|
878
877
|
for (const cmd of data) {
|
|
879
878
|
if (cmd.id && cmd.relay !== undefined) {
|
|
880
|
-
(0, logger_1.log)("smartapp", `handleDeviceMessage: relay command id=${cmd.id} state=${cmd.relay}`);
|
|
881
879
|
yield this.setDeviceRelay(cmd.id, cmd.relay);
|
|
882
880
|
}
|
|
883
881
|
}
|
|
@@ -890,7 +888,6 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
890
888
|
// Convert ID to node/unit (id = node * 256 + unit)
|
|
891
889
|
const node = Math.floor(id / 256);
|
|
892
890
|
const unit = id % 256;
|
|
893
|
-
(0, logger_1.log)("smartapp", `Setting device ${id} (node=${node}, unit=${unit}) to ${state}`);
|
|
894
891
|
// Get the first master
|
|
895
892
|
const master = this.system.masters[0];
|
|
896
893
|
if (!master) {
|
|
@@ -909,6 +906,7 @@ class SmartApp extends webapp_1.WebApp {
|
|
|
909
906
|
return;
|
|
910
907
|
}
|
|
911
908
|
// Set the unit state
|
|
909
|
+
(0, logger_1.debug)("smartapp", `Setting device ${id} (node=${node}, unit=${unit}) to ${state}`);
|
|
912
910
|
yield master.setUnitStatus(unitObj, state);
|
|
913
911
|
});
|
|
914
912
|
}
|