Need help to understand swtiching on device and timer
Posted: Sunday 12 November 2017 12:25
Hi,
Just started my first dzVents script. I have a small greenhouse which I would like to heat during the day and during the night, but at different temperatures. I can get the script below to work for a min and max temp over the whole day, but if I define 4 if conditions (min and max temp during the day, and min and max temp during the night), the script doesnt run.
Any pointers in the right direction would be great
Just started my first dzVents script. I have a small greenhouse which I would like to heat during the day and during the night, but at different temperatures. I can get the script below to work for a min and max temp over the whole day, but if I define 4 if conditions (min and max temp during the day, and min and max temp during the night), the script doesnt run.
Any pointers in the right direction would be great

Code: Select all
return {
active = true, -- set to false to disable this script
on = {
devices = {
'Erker kasje rechts', -- device name
}
},
execute = function(domoticz, device)
local heater = domoticz.devices('Xiaomi Smart Plug (temp kasje)')
if (timer == {'between 10:01 and 22:00'}) and
(device.name == 'Erker kasje rechts' and device.temperature <= 25) and
(heater.state == 'Off') then
heater.switchOn()
domoticz.log('dzVentz: Kasje dag heater on')
end
if (timer == {'between 10:01 and 22:00'}) and
(device.name == 'Erker kasje rechts' and device.temperature >= 28) and
(heater.state == 'On') then
heater.switchOff()
domoticz.log('dzVentz: Kasje dag heater off')
end
if (timer == {'between 22:01 and 10:00'}) and
(device.name == 'Erker kasje rechts' and device.temperature <= 18) and
(heater.state == 'Off') then
heater.switchOn()
domoticz.log('dzVentz: Kasje nacht heater on')
end
if (timer == {'between 22:01 and 10:00'}) and
(device.name == 'Erker kasje rechts' and device.temperature >= 21) and
(heater.state == 'On') then
heater.switchOff()
domoticz.log('dzVentz: Kasje nacht heater off')
end
end
}