Double tap a switch to start a scene

Is there any way to run a scene based on double tapping a switch? For example if Switch 1 is pressed on twice in a row it would trigger a particular scene, if pressed once only that load.

Thanks,

M

Directly with the switch reporting the double tap to Vera? No.
This should be possible as Vera presents herself as being associated to all groups, MCV would need to implement this feature.

Try this: Associate a device to group 2. Double tap the switch to turn the device on or off and wait for Vera to poll the device. Does the GUI update the status of that associated device?

You can do this using LUA code. I have several scenes where the first tap turns on just one light, but a second tap (within a couple of seconds of the first tap) will turn on additional lights.

I use this example LUA code:

function ResetFRIndicator(stuff)
sFRIndicator = “0”
end
if (sFRIndicator == “1”) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },21)
else
sFRIndicator = “1”
luup.call_timer(“ResetFRIndicator”, 1, “10”, “”, “”)
end

Thanks. Which line of this code do I change to indicate which switch this is assigned to? Or do i just create a trigger with that device on or off and add this code to actual the trigger?

M

I use a scene controller for this function (currently using an Intermatic HA07 scene contoller). You set the scene up (in Vera) to turn on the first light, when the proper scene controller butoon is pressed.

You then set the LUA code into that scene. Note that in the LUA code you need to replace the module number with the module number of your second light (my module number was 21, yours will be different).

The original question was

Is there any way to run a scene based on double tapping a switch?

Wouldn’t the suggestions only work if the “switch” was a scene controller, or perhaps one of the brands that directly report their status? Vera would have no way of knowing that a dimmer or on/off switch was double-tapped when it polls, does it?

@aa6vh:
Nice! Thanks for sharing.
I will try this to extend some of my scenes with the Remotec 550

Are you saying that you can use a “second tap” on the HA07 to trigger a different scene than the first press? How does this affect dimming and “off”, since those functions are controlled by the HA07, not Vera?

[quote=“aa6vh, post:5, topic:171402”]I use a scene controller for this function (currently using an Intermatic HA07 scene contoller). You set the scene up (in Vera) to turn on the first light, when the proper scene controller butoon is pressed.

You then set the LUA code into that scene. Note that in the LUA code you need to replace the module number with the module number of your second light (my module number was 21, yours will be different).[/quote]

I want the double tap to control a whole scene consisting of many devices - how would I code that?

One way would be to create a new scene with all of the commands you desire when the second tap occurs. You would then code the LUA in the first scene as follows (note that you will need to find the scene number for the second scene, here coded as scene #32):

function ResetFRIndicator(stuff)
sFRIndicator = “0”
end
if (sFRIndicator == “1”) then
lul_args = {}
lul_args[“SceneNum”]=“32”
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,lul_args,0)
else
sFRIndicator = “1”
luup.call_timer(“ResetFRIndicator”, 1, “10”, “”, “”)
end

And as asked above, one deficiency with the above methodology is that the scene off button does not work for the second light (or second scene). I just use other scenes/buttons to turn off that second light.

Thanks, I will try this out. I will also try this on a slave type switch which does seem to transmit both on and off commands.

I’m liking this idea, but still a new mcv programmer. So far, I’ve only written LUUP code the runs on scenes. This seems to be a challenge that requires going beyond LUUP.

I tried the code above, and it is not working - the only way I made it work was to run the scene that was waiting for the second tap, but with the light on, then turning the light off triggered the rest of the event. As I see it, the events are only triggered when lights go off, not when switches are pressed.

I’ve looked at the logs, and the vera does see the switch presses, and presents the following log messages:

[pre]06 10/22/12 22:18:24.341 Device_Variable::m_szValue_set device: 43 service: urn:micasaverde-com:serviceId:ZWaveDevice1 variable: NodeInfo was: 25,27,70,72,73,77,86, now: 25,27,70,72,73,77,86, #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2bddb680>
04 10/22/12 22:18:24.491 <0x2bddb680>
[/pre]

So I think what I need to do is to write some code that grabs those switch press events, and then when it sees two of them in a short period of time, it triggers the desired scene. Can someone point me in the right direction - how do I get started doing this?

Geoff

I just tried this code (UI5) in a scene’s LUUP and get an error in the status window: “Error in lua for scenes and events”.

function ResetFRIndicator(stuff)
  sFRIndicator = "0"
end
if (sFRIndicator == "1") then
  lul_args = {}
  lul_args["SceneNum"]="37"
  luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","RunScene",lul_args,0)
else
  sFRIndicator = "1"
  luup.call_timer("ResetFRIndicator", 1, "10", "", "")

When I try it in the Test Luup code (Lua) section, it says “Code failed”. Any help as to what the problem is? Thanks.

There’s no “end” to match the “if”.

For future reference: If you look at the Luup log it will tell you this.

futzle, thanks very much for the help. I obviously screwed up when I copied the code. I’m completely clueless about LUA/LUUP. Where is the log file you mentioned?

You can download the log viewer plugin here
http://forum.micasaverde.com/index.php?topic=13246.0

Or you will need to manually connect using a program such as winscp.

[quote=“aa6vh, post:3, topic:171402”]function ResetFRIndicator(stuff)
sFRIndicator = “0”
end
if (sFRIndicator == “1”) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },21)
else
sFRIndicator = “1”
luup.call_timer(“ResetFRIndicator”, 1, “10”, “”, “”)
end[/quote]
Sorry to dredge up an old thread, but I am trying to implement a double-tap light switch like the OP. In fact, I even would like to be able to triple-tap the switch but I want to first get the double-tap working. My idea is to be able to single-tap the kitchen light switch to turn them on, then double-tap it to turn on the island lights, and then triple-tap it to turn on the kitchen table light.

I’ve tried the code above in the “Test Loop Code (Lua)” screen in Vera. The “Message sent successful” popup appears but nothing happens. I have made sure to change the 21 above to 16 for my specific device. I’ve also tried double-tapping the switch as well as double-clicking the ON button in the Vera UI to no avail.

Is there something I’m missing? I’ve never messed around with Lua before and trying to wrap my head around it.

Thanks!
Dave

Unfortunately the “Lua Test Code” area does not work exactly like a live scene does.

Try it in your regular scene. You can always erase the LUA code if you need to.

(I always keep my LUA code in a regular text file separate from Vera, so that I can change it and upload it again, without worrying about Vera dumping it. It also helps if you need to recreate your Vera after a factory reset. Just copy and paste to Vera when you need to update Vera.)

Sorry to resurrect an old thread, but I wanted to confirm a successful implementation of the code that was posted here, to launch a scene - this was the only working solution to my situation, so hopefully future searchers will find this thread.

Thanks to the code here, I was able to assign a scene to a double tap (both on and off) of the linear WT00Z-1 and Evolve LTM-5 accessory switches. Those switches had been advertised as having 4 groups, so that 1 tap activates 1 thing, 2 another, etc, but those features apparently don’t actually work (at least with Vera).