I have this heating control script.
Code: Select all
-- assumptions:
-- the setpoint is set by a dummy device (not a selector type)
local CV_SWITCH = 'CV_switch_auto' -- switch device
local TEMP_SETPOINT = 'Thermostaat_setpoint' -- selector dummy device
local TEMP_SENSOR_1 = 'TFA1'
local TEMP_SENSOR_2 = 'Oregon'
local BAT_THRESHOLD = 30
local LOGGING = true
return
{
on =
{
timer =
{
'every 15 minutes'
},
},
--LOG levell: This is the log level you want for this script. Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
--marker: A string that is prefixed before each log message. That way you can easily create a filter in the Domoticz log to see just these messages.
logging =
{
level = LOGGING and domoticz.LOG_DEBUG or domoticz.LOG_ERROR,
--level = LOGGING and domoticz.LOG_ERROR,
marker = 'dzVents heating',
},
execute = function(dz)
-- collect all input data
local boiler_switch_state = dz.devices(CV_SWITCH).state
local temp_1 = dz.devices(TEMP_SENSOR_1).temperature
local temp_2 = dz.devices(TEMP_SENSOR_2).temperature
local bat_1 = dz.devices(TEMP_SENSOR_1).batteryLevel
local bat_2 = dz.devices(TEMP_SENSOR_2).batteryLevel
local setpointValue = dz.devices(TEMP_SETPOINT).setPoint
local average_temp = 40 -- very high so the heating will not fire
local temp_diff = temp_1 - temp_2
-- info only on log level = LOG_DEBUG
dz.log('CV_SWITCH : ' .. boiler_switch_state, dz.LOG_DEBUG)
dz.log('Temp_1 : ' .. temp_1, dz.LOG_DEBUG)
dz.log('Temp_2 : ' .. temp_2, dz.LOG_DEBUG)
dz.log('Bat_1 : ' .. bat_1, dz.LOG_DEBUG)
dz.log('Bat_2 : ' .. bat_2, dz.LOG_DEBUG)
dz.log('Setpoint_value : ' .. setpointValue, dz.LOG_DEBUG)
-- test if conditions are met and set acting values
if ((temp_1 - temp_2 > 1.1) or (temp_2 - temp_1 > 1.1)) then
dz.log('Temperature difference between sensors is more than 1.1 degrees : ' .. temp_diff, dz.LOG_DEBUG)
dz.notify('Notifyer', 'Temperature difference between sensors is more than 1.1 degrees' .. temp_diff , dz.PRIORITY_HIGH)
elseif (bat_1 < BAT_THRESHOLD) then
dz.log('Battery level of temperature sensor 1 = ' .. bat_1, dz.LOG_DEBUG)
dz.notify('Notifyer', 'Temperature sensor 1 ' .. bat_1 .. 'battery level low.',dz.PRIORITY_HIGH)
elseif (bat_2 < BAT_THRESHOLD) then
dz.log('Battery level of temperature sensor ' .. bat_2, dz.LOG_DEBUG)
dz.notify('Notifyer', 'Temperature sensor 2 ' .. bat_2 .. 'battery level low.',dz.PRIORITY_HIGH)
else
average_temp = (temp_1 + temp_2)/2
dz.log('Average temperature sensors value is : ' .. average_temp, dz.LOG_DEBUG)
end
-- now determine what to do
if (average_temp >= setpointValue) then
dz.devices(CV_SWITCH).switchOff()
dz.log('Target temperature reached, boiler off')
elseif (average_temp <= (setpointValue -1)) then
dz.log('Average temperature more than 1 degree below setpointValue, switchOn during 10 minutes')
dz.devices(CV_SWITCH).switchOn().forMin(10)
elseif ((average_temp > (setpointValue -1)) and (average_temp < setpointValue)) then
dz.log('Average temperature less than 1 degree below setpointValue, switchOn during 5 minutes')
dz.devices(CV_SWITCH).switchOn().forMin(5)
else -- not predicted situation
dz.log('Unpredicted situation, boiler off')
dz.devices(CV_SWITCH).switchOff()
end
end
}
However what it does is wait till 0, 15, 30, 45 minutes (the interval) to test.
So when it is toggled to 'on' it starts burning.
What am I overlooking in the above script.
I made another manual switch which toggles the heating on during 5 minutes (in case it is chilly in the house)
Code: Select all
return {
on = {
devices = { 'CV_switch_manual' }
},
execute = function(domoticz, TriggeredItem)
if (TriggeredItem.active) then -- state == 'On'
--domoticz.notify('Boiler switch is switched on manually', domoticz.PRIORITY_LOW)
TriggeredItem.switchOff().afterMin(5) -- if it is a switch
--domoticz.notify('The Boiler switch ' .. TriggeredItem.name .. ' will be switched off after 5 minutes')
end
end
}I know there are many ways of firing the heating with hysteresis and everything.
The script I made initiates heating and then waits 5 or 10 minutes to give the heat in the radiators the chance to heat up the room.
That's why this system has a 15 minutes interval for probing the temperature in the room.