Code: Select all
-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures
local BOILER_DEVICE = 'FB 42 Heizkreis Bad' -- switch device
local INFRAROT_DEVICE = 'FB 31 Infrarot' -- switch device
local SETPOINT_DEVICE = 'Solltemperatur Bad' -- selector dummy device
local TEMPERATURE_SENSOR = 'Bad'
local MODUS_DEVICE = 'Modus Waermepumpe' -- selector dummy device
local LOGGING = true
return {
on = {
timer = {'every 10 minutes'},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = 'setSetpoint',
},
active = true,
execute = function(domoticz, timer)
local sensor = domoticz.devices(TEMPERATURE_SENSOR)
local current = sensor.temperature
local boiler = domoticz.devices(BOILER_DEVICE)
local setpoint = domoticz.devices(SETPOINT_DEVICE)
local modus = domoticz.devices(MODUS_DEVICE)
local infrarot = domoticz.devices(INFRAROT_DEVICE)
-- now determine what to do
if (setpoint.state == nil or setpoint.state == 'Off') then
boiler.switchOff()
infrarot.switchOff()
return -- we're done here
end
local setpointValue = tonumber(setpoint.state)
if LOGGING then
domoticz.log('Setpoint: ' .. setpointValue, domoticz.LOG_DEBUG)
domoticz.log('Current boiler state: ' .. boiler.state, domoticz.LOG_DEBUG)
end
if (current > setpointValue and boiler.state == 'On') then
if LOGGING then domoticz.log('Target temperature reached, boiler off') end
boiler.switchOff()
infrarot.switchOff()
end
if (current <= setpointValue and boiler.state == 'Off' and modus.state == 'Heizen' ) then
if LOGGING then domoticz.log('Target temperature not reached, boiler on') end
boiler.switchOn()
infrarot.switchOn()
end
end
}
}I think monitoring temperature and setpoint every 10 minutes does the job.
But the script as is does not switch the devices as it should so I need help oncemore.
The days coming I'll have a lot of time tinkering around because here (Mallorca) we are bound to stay at home at least the next week