Toggle Through Scenes


Disclaimer I’m coming from the Veralite world and am trying to replicate a setup that I had (using PLEG).

My room has two z-wave devices. Device #1 is a GE/Jasco Paddle switch, connected to an unlighted ceiling fan. Device #2 is a z-wave outlet with a lamp attached to it.

What I’d like to do is use Device #1 to control itself and Device #2.

If I enter the room and turn the switch on, I want it to turn on the outlet (and turn itself off). This is the Light On “scene”

If I turn it on again, it should turn OFF the outlet, and stay on. This is my Fan On “scene”

If while the Fan is On, I turn it off and on again quickly, then turn the outlet on and keep it on. This is my Light and Fan “scene”.

I have been trying to figure out how to code this but am not sure how to do it. I’ve got a few good guesses, but nothing concrete. looking through the code of some of the smart apps, i see things like subscribing to events, and how to turn on off… but that middle scene of turning both on … i just cant wrap my head around.


For those that “speak” PLEG… we (i had help from a forum member + writer of pleg) did this by having
Two inputs/triggers of FanOn and LightOn; and three conditions and 3 actions. I can link the thread or expand on these, if it would help

Hey ArmedMetallica!

So let me see if I understand this correctly. You have a paddle switch which a SmartApp can read the status of, that is connected to a fan. You have a separate smart outlet with a lamp. You want the switch to alternately toggle the devices (first the light, then the fan) and if thrown in quick succession then activate both. Is that correct?

Thanks - that’s right Chad.

Last night, I saw the smart app “Off as Toggle” and it seemed like I might have been able to use that. However either due to the ST cloud or gremlins, it wasn’t working via simulator or published. After several tries, I got frustrated and ordered up some AEOTEC Minimotes. I had no choice the WAF was fading on this.

Then I come down this morning and boom off as toggle is sort of working … (when it wasn’t working, I tried several different switches being toggled, and they were all going on/off). very surreal.

So I’m reserved to my AEOTEC Minimote for now.

What would stop you from using a pair of variables as a set of flags and a doIn() command to reset them? For example:

(in the initialize section)
def masterCounter = 0 // determines if the light switch has recently been sprung
def smallCounter = 0 // determines if the light switch has recently been sprung twice

(in your event handler for switch on)
if (masterCounter==0) {
// activate your light here
masterCounter = 1
smallCounter = 0
} else {
// now we need to see if this is the first or second rapid switch
if (smallCounter == 1) {
// activate both fan and lamp
// put a doIn() function here to launch a clean up
} else {
// activate your fan here
smallCounter = 1

Then just use doIn() to launch a cleanup to reset both counters in whatever time you feel works best for you! There may be a more elegant way, perhaps just using one variable and letting them all cycle through? It’s up to you! :smile:

1 Like

thank you - while i am a coder… some of this is still very new to me. my minimotes are arriving today. I’m going to play with them first. But will probably still want to implement this in other scenarios.

aka… “i’ll be back”


Thanks again for your solution - just wanted to say that I ended up getting the minimotes, which work great for the WAF.,. and also finally got “Off as Toggle” working. All the trouble I was haivng was related to the outlet not reporting it’s status properly. As soon as I fixed that Off as Toggle worked fine. So now I have two ways of controlling the light physically (without needing the app). I’m still going to track this, in the event that I decide I want to go this route.