Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/479.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点红色:如果测量值多次不同于设定值,则温度报警_Javascript_Monitoring_Node Red_Alarm_Temperature - Fatal编程技术网

Javascript 节点红色:如果测量值多次不同于设定值,则温度报警

Javascript 节点红色:如果测量值多次不同于设定值,则温度报警,javascript,monitoring,node-red,alarm,temperature,Javascript,Monitoring,Node Red,Alarm,Temperature,我正在使用Node Red监视一组aquaria。我们有14个DS18b20传感器,每个水族馆一个。如果一个传感器的测量温度与设定值不同,我可以通过电子邮件发送警报。然而,有时在维护期间,我们会将传感器从水族馆中取出。因此,我想写一个函数,仅在测量异常值时设置报警,例如连续三次(每15分钟测量一次值)。我怎么能这样做? 目前,我编写了一个函数,将msg.payload设置为“报警”,如果有msg.payload[I].temp(数组中的14个测量值)与设置值相差超过1.5°C。此功能后接一个开关

我正在使用Node Red监视一组aquaria。我们有14个DS18b20传感器,每个水族馆一个。如果一个传感器的测量温度与设定值不同,我可以通过电子邮件发送警报。然而,有时在维护期间,我们会将传感器从水族馆中取出。因此,我想写一个函数,仅在测量异常值时设置报警,例如连续三次(每15分钟测量一次值)。我怎么能这样做?
目前,我编写了一个函数,将
msg.payload
设置为“报警”,如果有
msg.payload[I].temp
(数组中的14个测量值)与设置值相差超过1.5°C。此功能后接一个开关,然后触发电子邮件。
你对我的问题有什么建议吗?谢谢你的帮助

您可以尝试使用保存连续异常测量的计数器。 例如,在名为“评估全局异常测量”的功能节点上

然后,您可以在global.GlobalAbnormalAlert上配置开关以触发邮件(或不触发):

然后,流看起来像这样:


其中,初始节点触发度量值是您的回忆过程(从中可以获得msg.payload[i].temp)

谢谢!好主意!
// Set the variable GlobalAbnormalAlert (the counter) to not get undefined error later
if(!global.get("GlobalAbnormalAlert")){
    global.set("GlobalAbnormalAlert", 0);
}

// Check if is anormal  measure, and if it so, add 1 to the counter
if (msg.payload[i].temp > 1.5 ){
    global.set("GlobalAbnormalAlert", global.get("GlobalAbnormalAlert") + 1);
}
else {
    // If not anormal, reset the counter
    global.set("GlobalAbnormalAlert", 0);
}
return msg;