I’m puzzeled. Vera keeps telling me there is an error in my lua code for this scene. Can you see what is wrong? I tried to comment the script properly and make it reusable for others. Right now, it bombs out with an ERROR : Error in lua for scenes and events. Does anyone know what I am doing wrong here?
[code]-- add this luup code to the heating ON scene for this room.
local SWITCH_NO = 36 – change 36 to device ID HOME (1) / AWAY (0) virtual switch.
local SENSOR_NO = 25 – change 25 to device ID temperature sensor for room.
local TEMP_LOW_AWAY = 10 – change 10 to desired temp when away for frost protection.
local TEMP_LOW_HOME_DAY = 21 – change 21 to desired daytime temp when home.
– DO NOT EDIT ANYTHING BELOW THIS LINE.
luup.log(“HEATING ON LOOP START”) – debug only
local home = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,SWITCH_NO)
local temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, SENSOR_NO)
luup.log(“HOME AWAY STATUS”) – debug only
luup.log(home) – debug only
luup.log(“ROOM TEMPERATURE”) – debug only
luup.log(tonumber(temp)) – debug only
if(home==“0”)then – nobody home status is AWAY.
if(tonumber(temp) => TEMP_LOW_AWAY) then – temperature high enough, do nothing.
luup.log(“DEBUG: AWAY and temp high enough”) – debug only
return false
elseif(tonumber(temp) < TEMP_LOW_AWAY) then – temperature too low, switch on heating.
luup.log(“DEBUG: AWAY and temp has not reached set temp”) – debug only
return true
else
luup.log(“DEBUG: something went wrong in heating ON AWAY loop”) – debug only
end – END home status is AWAY loop.
elseif(home==“1”)then – peeps at home status is HOME
if(tonumber(temp) => TEMP_LOW_HOME_DAY) then – temperature high enough, do nothing.
luup.log(“DEBUG: HOME and temp high enough”) – debug only
return false
elseif(tonumber(temp) < TEMP_LOW_HOME_DAY) then – temperature too low, switch on heating.
luup.log(“DEBUG: HOME and temp has not reached set temp”) – debug only
return true
else
luup.log(“DEBUG: something went wrong in heating ON HOME / AWAY loop”) – debug only
end – END home status is HOME loop.
end – END home status heating on loop.
[/code]