Basic LUUP - Can some one double check its correct?

Hi chaps

This is my first LUUP entry and want someone to have a quick check to ensure i have everything in place (i stole the main LUUP) body from another topic)

The idea is to have the lights dimm 1% every 18 seconds.
This will ultimately power down the light after 30 minuets

[code]local dID = 8
luup.call_delay(“delayDim”,18,dID)

function delayDim(dev)
local devno = tonumber(dev)
local lls = tonumber((luup.variable_get(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelStatus”, devno)))
local newlls = lls - 1
if newlls < 0 then newlls = 0 end
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = newlls}, devno)
if newlls > 0 then luup.call_delay(“delayDim”,2,dev) end
end[/code]

Thanks
N

Hi,

One thing I would change is split the line

local lls = tonumber((luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", devno)))

The variable_get returns two values, the variable and the timestamp it was last changes and this will throw the tonumber function. So

local lls = luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", devno)

lls = tonumber(lls)[/code]
Is more reliable.

And welcome to the team :slight_smile:

Cheers Rene.

The second luup.call_delay should wait 18 seconds and not 2

Thanks chaps!
Still getting to grips with it all

Appreciate the help!