homebridge-smartsystem 7.1.17 → 7.1.19
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/powerbase.js +10 -7
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.19",
|
|
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/powerbase.js
CHANGED
|
@@ -108,12 +108,15 @@ class PowerBase extends base_1.Base {
|
|
|
108
108
|
// no previous value -> always update
|
|
109
109
|
if (isNaN(previous))
|
|
110
110
|
return true;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
if (
|
|
116
|
-
return
|
|
111
|
+
const absCurrent = Math.abs(current);
|
|
112
|
+
const absPrevious = Math.abs(previous);
|
|
113
|
+
const diff = Math.abs(previous - current);
|
|
114
|
+
// less than 1000W -> update on: difference > 5% of previous absolute value
|
|
115
|
+
if (absCurrent < 1000)
|
|
116
|
+
return diff > (absPrevious * 0.05);
|
|
117
|
+
// more than 1000W -> update on: difference > 2% of previous absolute value
|
|
118
|
+
if (absCurrent >= 1000)
|
|
119
|
+
return diff > (absPrevious * 0.02);
|
|
117
120
|
return false;
|
|
118
121
|
}
|
|
119
122
|
applyBindings() {
|
|
@@ -138,7 +141,7 @@ class PowerBase extends base_1.Base {
|
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
143
|
else {
|
|
141
|
-
(0, logger_1.debug)("power", `[Binding ${idx}] NOT significant for channel ${b.channel} -> register ${b.register}: ${currentValue}W -> ${power}W (diff: ${Math.abs(currentValue - power)}W, threshold: ${currentValue < 1000 ? '5%=' + Math.abs(currentValue * 0.05) : '2%=' + Math.abs(currentValue * 0.02)}W)`);
|
|
144
|
+
(0, logger_1.debug)("power", `[Binding ${idx}] NOT significant for channel ${b.channel} -> register ${b.register}: ${currentValue}W -> ${power}W (diff: ${Math.abs(currentValue - power)}W, threshold: ${Math.abs(currentValue) < 1000 ? '5%=' + Math.abs(currentValue * 0.05) : '2%=' + Math.abs(currentValue * 0.02)}W)`);
|
|
142
145
|
}
|
|
143
146
|
});
|
|
144
147
|
}
|