Code: Select all
return {
on = {
devices = {
49, --Pana Compressor_Freq
}
},
data = {
---------------------------------------
-- compressor state
-- 1: compressor off
-- 2: compressor startup
-- 3: compressor relaxing
-- 4: compressor continuous operation
state = { initial = 1 }
},
logging = {
level = domoticz.LOG_DEBUG, -- change to LOG_ERROR when OK - was LOG_DEBUG
marker = scriptVar,
},
execute = function(domoticz, triggeredItem)
local heatshift = domoticz.devices(82)
local target_temp = domoticz.devices(66)
local outlet_temp = domoticz.devices(65)
local CompressorFreq = domoticz.devices(49)
if(CompressorFreq.sValue == "0") then
domoticz.log('State: compressor off', domoticz.LOG_INFO)
domoticz.data.state = 1
correction = 0
elseif(domoticz.data.state == 1 or domoticz.data.state == 2) then
domoticz.log('State: compressor startup', domoticz.LOG_INFO)
domoticz.data.state = 2
correction = outlet_temp.temperature - target_temp.temperature + heatshift.setPoint -1
if(tonumber(CompressorFreq.sValue) > 22) then
domoticz.data.state = 3
end
elseif(domoticz.data.state == 3) then
domoticz.log('State: compressor relaxing', domoticz.LOG_INFO)
correction = outlet_temp.temperature - target_temp.temperature + heatshift.setPoint -1
if((outlet_temp.temperature - target_temp.temperature) >= 1) and (tonumber(CompressorFreq.sValue) < 23) then
domoticz.data.state = 4
end
elseif(domoticz.data.state == 4) then
domoticz.log('State: continuous operation', domoticz.LOG_INFO)
if((outlet_temp.temperature - target_temp.temperature) >= 0) then
domoticz.log('Continu met voorwaarde Shift+1 voldaan', domoticz.LOG_INFO)
correction = heatshift.setPoint + 1
else
correction = heatshift.setPoint
domoticz.log('Continu zonder aanpassing Shift', domoticz.LOG_INFO)
end
else
domoticz.log('State: undefined', domoticz.LOG_INFO)
domoticz.data.state = 1
correction = 0
end
if correction < -5 then correction = -5 end
if correction > 0 then correction = 0 end
if heatshift.setPoint == correction then
domoticz.log('No correction', domoticz.LOG_INFO)
else
domoticz.log('Correction set to ' .. tostring(correction), domoticz.LOG_INFO)
heatshift.updateSetPoint(correction)
end
end
}