General > Lighting & Load Control

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

(1/2) > >>

bradkw:
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? 

TechPigeon:
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", <D>)
if (status == "0") then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, <D>)
luup.call_delay(10)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, <D>)
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

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

bradkw:
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? 

rigpapa:

--- Quote ---luup.call_delay(10)
--- End quote ---

luup.sleep 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.

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


--- Code: ---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

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version