Hello,
I don’t have central air, but am working on an automatic thermostat program for my upstairs and downstairs. Basically I envision someone setting the cool setting on the thermostat to the desired temp and it triggers the necessary appliance switches to turn on my window AC units. Once cool enough, it shuts off.
I created a virtual button to enable this “auto pilot” feature. If enabled, it’ll check an upstairs temp sensor, and the downstairs thermostat. The program runs every 15 minutes checking. I have the program working great with setting the manual upper and lower temperatures within Lua, but would like to retrieve the “cool” setpoint on my thermostat and emulate how a central AC would work. Once set–it’ll trigger the necessary appliance modules and start up. My window AC’s remember their powersetting and if power is cut when on, they’ll resume once restored.
I looked through the XML file for the D_TemperatureSetpoint1_Cool which references S_TemperatureSetpoint1.xml for the actual variables. When looking, I can use variable_get to get the current temp, but i’m interested in getting the Cool setting temp, not the real temp. This is within the Action section.
Am I correct in using a call_action method to get variable? I’m lost on the specific syntax needed if so.
Code samples below. Thanks.
Working Manual setting (currently set for a temp that triggers the AC’s if above 75 and turns off below 72
[code]local AC_Run = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,87)
local upstairs_temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 84)
local downstairs_temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 11)
if(AC_Run==“1”) then
if (tonumber(upstairs_temp) >= 75) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 49)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 50)
elseif (tonumber(upstairs_temp) < 72) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 49)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 50)
end
if (tonumber(downstairs_temp) >= 75) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 51)
elseif (tonumber(downstairs_temp) < 72) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 51)
end
end
[/code]
Proposed code change that isn’t working.
[code]local AC_Run = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,87)
local upstairs_temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 84)
local downstairs_temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 11)
local tempSetpoint = luup.get_action(“urn:upnp-org:serviceId:TemperatureSetpoint1_Cool”, “GetCurrentSetpoint”, 11)
upperLimit = tempSetpoint + 2
lowerLimit = tempSetpoint - 2
if(AC_Run==“1”) then
if (tonumber(upstairs_temp) >= upperLimit) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 49)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 50)
elseif (tonumber(upstairs_temp) < lowerLimit) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 49)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 50)
end
if (tonumber(downstairs_temp) >= UpperLimit) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 51)
elseif (tonumber(downstairs_temp) < lowerLimit) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 51)
end
end
[/code]