Solved. Problems with heat scene


Im trying to take my home to the next level with a LUA scene.

My code runs fine in the test but doesnt run in the scene.

Can anyone give me some hints?

Im trying to set the temperature in a room depending on my mode.

my code is as folows:

local tHome = 20.0
local tAway = 14.0
local tNight = 18.0
local tVacation = 10.0
local tSet = 10.0

local lul_mode =luup.variable_get(“urn:micasaverde-com:serviceId:HouseModes1”,“HMode”, 32)
local lul_temp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”, 14)

if (tonumber(lul_mode) == 1) then
tSet = tHome
if (tonumber(lul_mode) == 2) then
tSet = tAway
if (tonumber(lul_mode) == 3) then
tSet = tNight
if (tonumber(lul_mode) == 4) then
tSet = tVacation

if (tonumber(lul_temp) < tSet) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 28)

if (tonumber(lul_temp) > tSet) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, 28)

Thanks in advance

Can you explain what you mean by it works find in test but not in a scene?
Assuming you meant you ran the LUA code in the develope app test lua area and it worked?

When you paste the same code into a scene and run the scene manually it does not work?
Or are you trying to trigger the scene some how and that is what is not working?

You are correct.
I tried it in the develope app test lua area, where it worked and switched my switch.

When i try to use the same code in a scene that is triggered every 10 minutes, it doesnt work. No action on the switch.

Try using the debug procedure KWIKLOG as described in the conditional scenes sticky thread:

function kwikLog(message, clear)
  if bTrace == 1 then
    local socket = require("socket")
    local time = socket.gettime() or os.time()
    local tms = string.format(".%03d ",math.floor (1000 * (time % 1)))
    local stamp ="%d %b %Y %T",math.floor(time)) .. tms
    local mode = "a+"
    if clear then mode = "w+" end
    local file ="/www/kwikLog.txt", mode)
    file:write(stamp .. (message or "") .. "\n")

I place the above in the startup code section. I use the global “bTrace” variable so that I can start or stop logging at anytime.

I then place kwiklog statements inside my problem scene (remember to set bTrace to true):

kwiklog("Now entering the scene")
kwiklog("Variable bleah = " .. bleah)

To dump out the kwiklog file, enter the following in your browser (use your Vera IP, of course):

Thanks for your help.

I found that I had some code left in the starup LUA tab.

The scene works now.