Errors with combined device and timer script
Posted: Thursday 04 January 2018 22:30
I am trying to control a thermostat to have 2 modes Home and Away with Domoticz v3.8795. When Away is On the temperature is set low and does not change. When Home is On (Away is Off) I want the temperature to change a few times during the day. I have listed my script below
When a time event triggers I get an error for the if statement for the device, line 16. When I manually trigger the Away on and off I get an error at the first if for the triggerInfo,trigger.
I know I am missing something, your help correcting my dumb mistakes would be greatly appreciated.
When a time event triggers I get an error for the if statement for the device, line 16. When I manually trigger the Away on and off I get an error at the first if for the triggerInfo,trigger.
I know I am missing something, your help correcting my dumb mistakes would be greatly appreciated.
Code: Select all
local Away_temp = 50
local Home_temp_dayh = 68
local Home_temp_dayl = 63
local Home_temp_nght = 60
return {
on = {
devices = {'Away Switch'},
timer = { 'at 05:30', -- raise temp
'at 08:00', -- lower temp up stairs
'at 19:00', -- raise temp up stairs
'at 23:00' -- lower temp
}
},
execute = function(domoticz, device, triggerInfo)
if (device.state == 'On') then
domoticz.devices('Down Stairs Set').updateSetPoint(Away_temp)
domoticz.devices('Up Stairs Set').updateSetPoint(Away_temp)
domoticz.log('Away Set Point changed to: ' .. Away_temp, domoticz.LOG_INFO)
else
--domoticz.log('Home Set Point ' .. triggerInfo.trigger, domoticz.LOG_INFO)
if (triggerInfo.trigger == 'at 05:30') then
domoticz.devices('Down Stairs Set').updateSetPoint(Home_temp_dayh)
domoticz.devices('Up Stairs Set').updateSetPoint(Home_temp_dayh)
domoticz.log('Home Set Point ' .. triggerInfo.trigger .. ' changed to: ' .. Home_temp_dayh, domoticz.LOG_INFO)
elseif (triggerInfo.trigger == 'at 08:00') then
domoticz.devices('Up Stairs Set').updateSetPoint(Home_temp_dayl)
domoticz.log('Home Set Point ' .. triggerInfo.trigger .. ' changed to: ' .. Home_temp_dayl, domoticz.LOG_INFO)
elseif (triggerInfo.trigger == 'at 19:00') then
domoticz.devices('Up Stairs Set').updateSetPoint(Home_temp_dayh)
domoticz.log('Home Set Point ' .. triggerInfo.trigger .. ' changed to: ' .. Home_temp_dayh, domoticz.LOG_INFO)
elseif (triggerInfo.trigger == 'at 23:00') then
domoticz.devices('Down Stairs Set').updateSetPoint(Home_temp_nght)
domoticz.devices('Up Stairs Set').updateSetPoint(Home_temp_nght)
domoticz.log('Home Set Point ' .. triggerInfo.trigger .. ' changed to: ' .. Home_temp_nght, domoticz.LOG_INFO)
else
domoticz.devices('Down Stairs Set').updateSetPoint(Home_temp_dayh)
domoticz.devices('Up Stairs Set').updateSetPoint(Home_temp_dayh)
domoticz.log('Home Set Point changed to: ' .. Home_temp_dayh, domoticz.LOG_INFO)
end
end
end
}