Node status offline without setTimeout; handel turn line logs according to total_energy.js
This commit is contained in:
parent
0c993f50b1
commit
5540cee8ec
4 changed files with 110 additions and 136 deletions
|
|
@ -36,6 +36,7 @@ let mainSocket;
|
|||
let phases;
|
||||
//phases where voltage is 0 (set)
|
||||
let noVoltage;
|
||||
let energyToSwitchLamps;
|
||||
|
||||
exports.install = function(instance) {
|
||||
|
||||
|
|
@ -306,15 +307,12 @@ exports.install = function(instance) {
|
|||
|
||||
const actualTotalPower = values.total_power;
|
||||
|
||||
const numberOfNodes = Object.keys(FLOW.GLOBALS.nodesData).length;
|
||||
if (numberOfNodes == 0) numberOfNodes = 20; // to make sure, we send notification if totalPower is more than 300
|
||||
|
||||
if (actualTotalPower > numberOfNodes * 15 && this.onNotificationSent == false) {
|
||||
if (actualTotalPower > energyToSwitchLamps && this.onNotificationSent == false) {
|
||||
sendNotification("modbus_reader: lampSwitchNotification", tbName, "lamps_have_turned_on", {}, "", SEND_TO.tb, instance);
|
||||
this.onNotificationSent = true;
|
||||
this.offNotificationSent = false;
|
||||
}
|
||||
else if (actualTotalPower <= numberOfNodes * 15 && this.offNotificationSent == false) {
|
||||
else if (actualTotalPower <= energyToSwitchLamps && this.offNotificationSent == false) {
|
||||
sendNotification("modbus_reader: lampSwitchNotification", tbName, "lamps_have_turned_off", {}, "", SEND_TO.tb, instance);
|
||||
this.onNotificationSent = false;
|
||||
this.offNotificationSent = true;
|
||||
|
|
@ -332,6 +330,7 @@ exports.install = function(instance) {
|
|||
phases = FLOW.GLOBALS.settings.phases;
|
||||
tbName = FLOW.GLOBALS.settings.rvoTbName;
|
||||
noVoltage = FLOW.GLOBALS.settings.no_voltage;
|
||||
energyToSwitchLamps = FLOW.GLOBALS.settings.energy_to_switch_lamps / 2.5; //half value is enought to show if lamps are turned on or off
|
||||
if (deviceConfig.length) mainSocket = new SocketWithClients();
|
||||
else console.log("Modbus_reader: no modbus device in configuration");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue