Hello this is my first code ever.
I have only a srt321 thermostat, 3 stellaz and 1 Vera Lite with multiswitch plug in installed.
Since my only input point is the SRT321, i’ve created a scene called whosathome that run every minute. Using special temperature setpoint on the srt321 i’d like to switch on/off the various multiswitch and so trigger some scenes.
For examples
if i put 13degrees it means that we are all at home and the stellaz will change their setpoint while the scenes linked to my boiler will return true.
On the contrary if we are away i put an other setpoint and all goes off. Of course after the input automatically i would like to return to the previous temperature.
(here is the post where i explain it better: http://forum.micasaverde.com/index.php/topic,23900.0.html )
So i wrote this code that works most of the time but…not always.
Can i ask your help to fix it ?
[code]currentset=luup.variable_get(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“CurrentSetpoint”, 4) --READ THE ACTUAL HEAT SET POINT AND CALL IT “CURRENTSET”
if (tonumber(currentset) > 18) then – IF CURRENTSET IS HIGHER THEN 18 THEN DONT DO ANYTHING (RETURN FALSE)
setpoint = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“CurrentSetpoint”, 4) – CREATE/UPDATE THE VARIABLE “SETPOINT” AND REMEMBER THE TEMP VALUE
return false
else
if (tonumber(currentset) == 15) then – IF CURRENTSET = 15 THEN MY WIFE IS @HOME SO SWITCH THE FIRST MULTISWITCH (STATUS1) AND SWITCH OFF THE AWAY MULTISWITCH SWITCH(STATUS4)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus1”,{ newStatus1=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“0” },12)
elseif (tonumber(currentset) == 16) then --SETPOINT=16 MEANS WIFE+KIDS(SWITCH 1 & 2) AT HOME
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus1”,{ newStatus1=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus2”,{ newStatus2=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“0” },12)
elseif (tonumber(currentset) == 17) then – SETPOINT=16 HUSBAND (SWITCH 3) AT HOME
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus3”,{ newStatus3=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“0” },12)
elseif (tonumber(currentset) == 14) then – SETPOINT 14 MEANS AWAY
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus1”,{ newStatus1=“0” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus2”,{ newStatus2=“0” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus3”,{ newStatus3=“0” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“1” },12)
elseif (tonumber(currentset) == 13) then --SETPOINT = 13 ALL AT HOME (SHORT CUT TO AVOID TO INPUT ALL THE SETPOINT FOR EACH ONE)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus1”,{ newStatus1=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus2”,{ newStatus2=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus3”,{ newStatus3=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“0” },12)
elseif (tonumber(currentset) == 12) then – SETPOINT=12 MEANS HOLIDAY YES/NO(SWITCH 5) SO SOME SCENES WILL NOT BE RUN AND OTHER YES
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus1”,{ newStatus1=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus2”,{ newStatus2=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus3”,{ newStatus3=“1” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus4”,{ newStatus4=“0” },12)
luup.call_action(“urn:dcineco-com:serviceId:MSwitch1”,“SetStatus5”,{ newStatus5=“-1” },12)
else
setpoint = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“CurrentSetpoint”, 4) --RELATED TO THE FIRST “IF” SO THE HEAT SETPOINT IS READED
end
end
luup.call_action(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”, “SetCurrentSetpoint”, {NewCurrentSetpoint = setpoint}, 4) – CHANGE BACK THE TEMPERATURE ACCORDING TO THE VARIABLE"SETPOINT" VALUE[/code]