[quote=“RexBeckett, post:12, topic:170378”][quote=“Don Diego, post:10, topic:170378”]Hi Chixxi
I have two virtual code segments with virtual switches, both within the same lua code segment. One works one doesn’t.
The one that doesn’t work:
local status = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”, 237)
if(status==“1”)then
if ( luup.is_night() ) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget",
{newTargetValue = “1”}, 17)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”,
{newTargetValue = “1”}, 18)
return true
else
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”,
{newTargetValue = “0”}, 17)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”,
{newTargetValue = “0”}, 18)
return false
end
else
return false
end
The one that works:
local DEV_ID = 205
status = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”, 194)
if(status==“1”) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = “71”}, 0)
else
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”,
{newTargetValue = “0”}, DEV_ID )
end
Thanks in advance for your help.
Don[/quote]
@Don Diego, when you say:
I have two virtual code segments with virtual switches, both within the same lua code segment.
Do you mean that both pieces of code are in the same Luup tab of the same scene? If so, can you post the whole code? Note that, once Lua encounters a return statement, further code is not executed.
I cannot see any syntax errors in the first code chunk. In what way does it not behave as you expect?[/quote]
Hi Rex
Thanks for your reply. Yes they are both in the same tab. I’m trying to control two things at the same time. The second virtual switch doesn’t seem to control anything. Thee first one works fine. Thought maybe the then… else… ends were not correct. The returns are supposed to end the execution (in other works the second code segment is really the first that’s executed). Wanted to end the segment with the returns… but think they really do not matter.
Again thanks for your help. I’ve been over this a number of times.
Don