Newb Trying to Turn On and Off Light Switch With One Sceen Controller Button

I have searched and found a few ways to do this but I am new to the programming stuff and would like to know the least messy way to do this.

I have kind of settled on this code I found for using a virtual switch in a different thread:

status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status", DEVICE_ID) if(status=="1")then luup.call_action("urn:upnp-org:serviceId:VSwitch1", "SetTarget", {newTargetValue = "0"}, DEVICE_ID) else luup.call_action("urn:upnp-org:serviceId:VSwitch1", "SetTarget", {newTargetValue = "1"}, DEVICE_ID) end

Basically I want to turn my living room light on and off using one button on my scene controller. Can I use this code in a single scene to turn on/off a light switch directly also?

I know I would have to replace the “VSwitch1” and “DEVICE_ID” with my switch values, but I’m not sure how exactly it should look when I’m done.

Here is my switch info:

If this is possible, what should the completed code look like? Are there any other better ways to do this? I just dont wan’t a bunch of scenes to perform this simple action. Thanks for your help.

Which scene controller are you using?

Also, you can toggle a device using the GUI, no code required. See this post.

I purchased a Cooper Aspire RFWDC 5-Scene controller.

I did not have enough wires in my electrical box to install the GE 45610 Aux switch to my 3-way setup so I figured the scene controller in the aux switch location would give me more options anyway.

Thanks for the link. I had not found that one yet.

Thanks; I don’t have that device. But if Vera is able to distinguish between ‘a scene is activated’ and ‘a scene is de-activated’, you would set up a scene for each event, and turn the light on and off, respectively.

Could I just use “a scene is activated” trigger and “a scene is de-activated” trigger on the same scene so no matter when I press the button the light will toggle?

Sounds like you’re going to control a GE device with it? I think you could give it a try in that case. However, if using it with scene-capable devices (Cooper, Leviton, Evolve, etc.), I’d keep it split in two scenes (with on and off).

I use a GE switch to control an GE external outlet. It’ll change state based on the switch state. It does require the creation of 2 scenes, one for on and one for off. Without LUUP code I’m not sure if you can read the state of the GE switch and toggle it tho.
It will require 2 buttons, one of switch on and one for switch off. Unless the cooper buttons have a on/off setup.

Create an ‘On’ scene for the cooper button, in devices select the GE switch and set it to On.
Create a trigger of the type 'A device is turned On or Off with Mode Device is turned On.

Save your scene.

Repeat the above for an Off screne. Set the GE switch to Off and the mode to Device is turned Off.

Once saved and reloaded, when you click the correct cooper scene controller button, it should switch the GE off or on based on the button.

Thanks for all the help. For anyone else who stumbles onto this thread, I found a page for the Cooper Aspire RFWDC Scene Controller in the wiki that helps describe how it works and some of its faults.

So, did you get it to work / which way did you go?

After reading the wiki page I figured out the scene controller doesnt work quite like I was hoping.

I ended up using one button to toggle living room lights. One to toggle kitchen lights. One to toggle the stair lights. One for a “Home” scene that will bypass the door/window sensors and set the thermostat. One for an “Away” scene that will turn off all the lights in the house, arm the sensors, and change thermostat.

The area I don’t like is that the controller doesn’t send a “scene is de-activated” signal to my Vera 3, so I can’t program anything for that function. I basically have to push the button twice for the light functions so they are in the most desired postion for next time. From an “off” condition, the first press activates the scene and lights come on after about 1.5 seconds, the light on the controller is lit. Then I press the button again, just to turn the light off on the controller. Then the controller is in the “off” position again and the next press will toggle the light.

I also do not like that I can’t use the “all off” feature button. If I program that button, whatever I set it to activate will be activated on every “off” press of the scene buttons per the wiki description. This is because I have all GE switches and they are not scene capable, so the Cooper cannot control them directly.

I see. What you could try is manually associating your GE switches with the appropriate scene controller buttons, through the [tt]Device Options[/tt] tab of the controller. Try [tt]Group ID[/tt] = 1 for the first button, etc.

This might make the Off part work. The drawback is that because the scene controller will turn off the devices directly, Vera doesn’t know about it, so she will show the wrong state until the devices have been polled.