Limit, what we send
This commit is contained in:
parent
41d1ec28dd
commit
ef7817bf22
5 changed files with 122 additions and 74 deletions
|
|
@ -317,20 +317,24 @@ exports.install = function(instance) {
|
|||
}
|
||||
|
||||
/**
|
||||
* function sends notification to slack and to tb, if EM total_power value changes more than 500. This should show, that RVO lamps has been switched on or off
|
||||
* function sends notification to slack and to tb, if EM total_power value changes more than numberOfNodes*15. This should show, that RVO lamps has been switched on or off
|
||||
*/
|
||||
lampSwitchNotification = (values) => {
|
||||
|
||||
if(!values.hasOwnProperty("total_power")) return;
|
||||
|
||||
const actualTotalPower = values.total_power;
|
||||
if(actualTotalPower > 600 && this.onNotificationSent == false)
|
||||
|
||||
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)
|
||||
{
|
||||
sendNotification("modbus_reader: lampSwitchNotification", tbName, "lamps_have_turned_on", {}, "", SEND_TO.tb, instance);
|
||||
this.onNotificationSent = true;
|
||||
this.offNotificationSent = false;
|
||||
}
|
||||
else if(actualTotalPower <= 600 && this.offNotificationSent == false)
|
||||
else if(actualTotalPower <= numberOfNodes * 15 && this.offNotificationSent == false)
|
||||
{
|
||||
sendNotification("modbus_reader: lampSwitchNotification", tbName, "lamps_have_turned_off", {}, "", SEND_TO.tb, instance);
|
||||
this.onNotificationSent = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue