I want to use the following code but it gives an error whivch i cannot explain.
local status = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status",59)
local skipdim = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",68)
local away = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",69)
if (tonumber(status)== 1) and (tonumber(away) == 0) and (tonumber(skipdim) == 0)
then
return true
end
return false
It errors on retrieving the DayTime virtual switch.
When i use only the check for the daytime switch it gives also an error.
I already tried and other code which i found in the tutorial in this forum but this also errors when i try to retrieve the status of day/night.
What i want to achieve is the following:
I want that the lights in my home are turned on on the following conditions:
motion sensor is tripped
away and/or skip buttons are turned OFF
it is evening
I don’t know if i can achieve this by simple scene/luup scripting, maybe someone has an better idea how to get this to work.
There are no errors in your code - assuming you have used the correct device numbers. If you are testing this in Test Luup code (Lua) it will flag an error when your code returns false. This can be very confusing.
I assume you are triggering the scene based on motion.
I want that the lights in my home are turned on on the following conditions:
- motion sensor is tripped
- away and/or skip buttons are turned OFF
- it is evening
You coded this as:
away AND skip buttons are turned OFF
The lua test gives an error, my vera also give a lua startup error on this code.
When i remove the code for daynight is gives no error and runs, but as soon as i use the daynight part it errors.
When i only use the daynight part is also errors and does not run…
The code should not cause any errors. Even if DayTime does not exist or the device number is wrong it would simply return nil. How are you writing it into Test Luup code (Lua)?
local status = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status",59)
local skipdim = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",68)
local away = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",69)
if (tonumber(status)== 1) and (tonumber(away) == 0) and (tonumber(skipdim) == 0) then
return true
end
return false
When you put the code in the scene, include the return false. I only suggested removing it so that you could test the code in Test Luup code (Lua). It does not differentiate between code errors and return false. This is why I don’t use it.
It seems we have fixed the problem by correcting the wrap-around of your then.
Best Home Automation shopping experience. Shop at Ezlo!