Conditional Scene - 1 Switch, 1 Light or All Lights On - Is there a better way?

In my living room I have one light switch and 4 lamps. Pre-Vera I had turn on one light with the switch, them walk (gasp) to each of the other 3 lamps to turn them on one by one. I wanted to be able to use the Z-Wave wall switch as a controller of sorts to either turn on one lamp or all lamps. In this room I’d like it to look as traditional as possible. I don’t like the look of any controllers I’ve found so far, except the Cooper Anyplace switch, but it’s flaky at best. I’d rather not put a Aeotec Wallmote or Remotec 90 on the wall. This is what I’ve have now:
A) 1 Wall switch - GE Smart Toggle Switch controlling 1 outlet with 1 Lamp connected
B) 2 LB60Z bulbs in 2 of the other 3 lamps
C) 1 Qubino Flush 2 in the last lamp (A converted oil lamp with a 60 watt bulb in the top and a night light in the old glass tank. A, B, A+B, Off Switch)
D) 1 older Leviton lamp module with nothing attached as my “condition.” It’s plugged into a spare outlet in the basement.
Scene 1 - Trigger when “A” wall switch turns on (and lamp A by default) immediately turn on module D, then turn off module D with 5 seconds delay
Scene 2 - Trigger when “A” wall switch turns on, immediately turn on all LR lights, execute a Luup code which checks module D, and stops scene execution if module D is off
Result - 1st “on” of the switch, 1 lamp goes on. Turn off and back on within 5 seconds, all lights on.

It works, but I have a lamp module doing nothing.
Does anyone have a better suggestion?

Hey Brad, i might have a solution for you

  1. Create a Scene with your “A” as the trigger
  2. Dont select a Triggered device but instead press next
  3. Under Step 3 located ‘No Luup Code Defined’ click the arrow next to it and paste in the following code

local status = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, )
if (status == “0”) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, )
luup.call_delay(10)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “0”}, )
else
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, )
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, )
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, )
end

You will need to change the Corresponding Letters to their device Ids, they can be found under the device in settings they look like this device #14
an example of how your code should look is as follows
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = “1”}, 15)

I am currently on leave so im not sure how well this would work as im away from my workshop but hopefully it gets you on the right track

I like it. It does not solve the problem of having an otherwise unused ?condition ? device, but it introduces other logic that could be useful. I don?t know much of the luup syntax, so this is helpful. It gives me more ideas! One problem I?m having and perhaps I should be adding this as a new thread (??) but here goes. When I turn on the A light by using the wall switch, my Vera stopped seeing this status change. The logic now fails. I?ve done a lot of experimenting as I?ve started with my new Vera system so I?m wondering if I have some corruption. I have a lot of unused device numbers now because of devices I?ve removed. The problem is not limited to this one switch, none of the switces update in the Vera if turned on manually. The switches are Z-Wave Plus. Should I wipe it out and start over or is there a way to fix this problem?

luup.call_delay(10)

[tt]luup.sleep[/tt] is the call I think TechPigeon was thinking of here (call_delay won’t work as shown), but it’s a bit dicey and most seasoned Vera users avoid it (you can cause deadlocks and reloads if your delay is too long).

Why not try Reactor? It’s got a built-in feature for stuff like this. I use the “repeats N times with X seconds” option to make certain switches do extra jobs, for example: if we cycle the first switch nearest the bottom of the basement stairs (which operates a light there normally) off twice within 15 seconds, all the lights go out in every part of the basement. You could easily reverse this process as well, and have an on cycle turn on all the lights. Built-in functionality. Done and run.

Do not use “Sleep”. And in the above code, call_delay is used incorrectly. The correct code might be (I haven’t tested it):

function XXXUniqueName(stuff)
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, <D>)
end

local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", <D>)
if (status == "0") then
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, <D>)
  luup.call_delay("XXXUniqueName", 10, "")
else
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, <B1>)
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, <B2>)
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, <C>)
end

Thank you for the correction there rigpapa, for some reason i keep getting those commands mixed up :smiley: if reactor makes setting up these tasks simpler i would say go for it.

I think Reactor is what I am looking for. That was the point of my post to find a better way to do what I was doing. I will try it!

About my my post from this morning, I?m still having trouble with Vera not recognizing when switches are changed manually. I?ll keep searching the forum, but if anyone has a suggestion for that, please reply! :wink:

Hey Brad,

When does the status of the light eventually update in the interface?
If this is the case you might have an older switch module that if i can remember used to not automatically update its status to the controller, i think i have an old code from when there was an old system i was using a couple of years ago.

Does the status not update at all even if you wait 5-10 minutes?
In this case it might be possible that the wall switch mech itself is connected directly to the light itself and not using the Z-wave module to switch the light on or off, its recommend that if this is the case you would need to sparky to check it out.

Not sure what else it could be but then again there are probably more experienced people then me that could assist you.

The switches are newer Z-Wave Plus. When I configured them they updated Vera when manually switched. The status used to change within 1 second. Now they don?t update at all even overnight. They work fine when controlled by Vera. I recently replaced one thinking it might be the switch. It worked normally for about 15 minutes then stopped.