Эта страница является
переводом страницы
TempDeviation. Перевод выполнен на 100%.
Notification about incorrect work of climate control system
This article describes a situation when the current temperature does not reach the set value for a long time. In this case a user must be informed about incorrect work of equipment.
For example, a user must be notified if the difference between the current and the set temperature is more than 4 degrees for 4 hours.
Here is a step by step instruction how to do it.
1 Create a new project or open an existing one.
2 Add a driver you'll work with and set it.
3 Create feedback channels to display current and set temperatures.
4 Create a new script and add to it the following:
IR.AddListener(IR.EVENT_START,0,function() {
var l_nIntervalMilsec = 1000*60*60*4; // conversion 4 hours to a miliseconds
var MinTempDeviation = 4; // Minimum temperature outflow
var l_sDriverName = "KNX IP BAOS 770"; // The name of the driver used in the project.
var l_sSetTemp = "SetTemp"; // Name of the feedback temperature setpoint
var l_sTemp = "TempSensor"; // Name of the temperature sensor feedback
var l_nTimer = 0; // Number of seconds for the interval
var l_nInterval = 0; // Interval
// When the temperature arrives, we check if the temperature is higher than the set one, then we set the interval for counting 4 hours
// Remove interval if everything is ok
IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice(l_sDriverName), function(m_sName, m_sValue){
if(m_sName == l_sTemp) {
var m_nSetTemp = IR.GetVariable("Drivers."+l_sDriverName+"."+l_sSetTemp);
if(Math.abs(m_nSetTemp - m_sValue) > MinTempDeviation){
if(l_nInterval == 0){
SetInterval();
}
} else {
if(l_nInterval != 0){
IR.ClearInterval(l_nInterval);
l_nInterval = 0;
}
}
}
});
// The function sets the interval in which the temperature will be compared.
function SetInterval(){
l_nInterval = IR.SetInterval(1000, function(){
var m_nSetTemp = IR.GetVariable("Drivers."+l_sDriverName+"."+l_sSetTemp);
var m_nTemp = IR.GetVariable("Drivers."+l_sDriverName+"."+l_sTemp);
if(Math.abs(m_nSetTemp-m_nTemp) > MinTempDeviation){
l_nTimer++;
if(l_nTimer >= l_nIntervalMilsec){
Alarm();
l_nTimer = 0;
}
}
});
}
// The function that calls the necessary notification - inside this function you can use the necessary notification method
function Alarm(){
IR.Log("Attention temperature difference of 4 degrees is kept for 4 hours");
}
});
5 Write your values in the variables:
- l_nIntervalMilsec - time interval in miliseconds
- MinTempDeviation - difference between temperatures
- l_sDriverName - name of driver used in the project;
- l_sSetTemp - name of feedback channel, displaying the value of the set temperature
- l_sTemp - name of feedback, displaying the value of the current temperature.
6 Write a required notification means in the Alarm function. For example, Push-notifications can be used.