[Edge] Virtual Scene Switcher, more than a fun way to cycle through scenes

My first virtual device :smiling_face:. Designed as a companion for smart buttons to easily cycle through scenes, it is not short on features like automatic cycling, random selection of scenes and even brings double-tap and beyond to any button.

I’ve been adding more features over time to fit multiple scenarios, at the end of the post there are links to fun use cases like blinkers, pomodoro timers, presence simulation routines, wake-up machines, etc.

Scene switching made easy: each Switcher manages a set of scenes from 1 to N. Scenes can be anything, they’re just a number and you create routines to assign actions to each scene like 1 turning on a light red. The driver handles the switchting with high-level actions and settings to define its behaviour.

At its core it is a specialised virtual counter with lots of extra features and scene-oriented design decisions that eliminates most boring work. Previously, just like other users, for scene switching I was using a combination of the auto-repeat feature of my IKEA button driver and the great Counter Utility by @TAustin which inspired this and actually helped me a lot to understand how virtual devices work.

Let’s start with the main feature, setting a simple scene-switching scenario to cycle through four colours pressing a button. It won’t take long to get crazy.

Install the driver from:

https://bestow-regional.api.smartthings.com/invite/Kr2zNDg0Wr2A

Create the virtual device:

  • In the SmartThings app “Add a device” and “Scan nearby”. It will create a device called Scene Switcher. Let’s rename it to Colour Switcher.
  • To create more, use the “Create Switcher” button in the switcher.

Perform the 3 steps to scene switching:

  1. Set the number of scenes. Just go to the Switcher settings and change the number, by default is 4 so you can skip this step!

  2. Map each scene number. In the Switcher routines tab click add routine. You’ll have to create four routines that will read like “If the Switcher Active scene is 1/2/3/4 Then (Run routine or Control devices)”. For testing let’s just try changing the colours of a light.

  3. Assign actions to the buttons. The Switcher device is not short on commands, in your button pick “Next” as action to cycle forwards and “Previous” for backwards. You can also use the dashboard button with configurable actions instead of a physical button.

It’s done! You may have noticed it already saved you at least two boring routines to handle the circular loop in each direction. Let’s spice it up!

What if you want to…

… add more colours? Easy! Just change the number of scenes and assign the new actions.

… make it stop in the last one instead of looping? Sure, change the cycle mode to Linear. That’s useful if your scenes follow an increasing order, like brightness levels, you would not want to suddenly switch from full to lowest brightness.

… fight monotony with something less predictable than next/previous? Got you! Use the Surprise Me action and let the driver pick the scene for you!

… cycle scenes while holding a button? Glad you asked, auto-cycle has you covered! It is incredibly satisfying to see the scenes changing and just stop it when you like. There are settings to start / stop the cycling with buttons that don’t support hold/release.

… assign a colour to triple-tap even if your button has single-tap only? Yup! The driver has a special action called Register Pressed. If you call this action from your button, the driver understands it is a multi-tap sequence so it will wait until the sequence is over. If you press it three times it will activate scene 3. Neat, right? :grin: You can change the default waiting time for the next tap to fit your button behaviour. Supports buttons with native double-tap! Try 1 second delay and don’t forget to also assign the action Register Double to the double pressed event. You can have up to 1000x multi-tap :sweat_smile:.

Those were just some ideas, some I use every day like the auto-cycling or the basic switching, others were implemented in my IKEA button drivers and now are available for every button. There are even features I haven’t even put in practice yet! :rofl:

More fun things you can do:

This is a recopilation of comments I’ve been writing over time featuring multiple use cases.

Play around with the actions or take a peek at the source to see what you’re installing!

Hope you like it and it’s useful!

12 Likes

Very cool! :sunglasses:

2 Likes

We have this installed on our station, but we can’t figure out how to use it.

(Remember that, like some other users, i’m using a text to voice screen reader and can’t see the images in your posts)

Here’s the details screen for the scene switcher. What do we do next?

1 Like

In settings you can set the number of scenes, by default is 4.

The driver works as a counter, it will update the active scene and trigger a event. So you have to create routines “when the active scene is 1 do this” “when the active scene is 2 do that”.

Then in the buttons add the actions like Next or Previous.

1 Like

Where is this? (Which screen in the app?)

The button actions? You can either go to the button view and assign any of the actions there like Pressed or create a routine from the routine screen.

In that case, the If action would be: device status, button, Pressed. And the Then action, control devices, scene switcher, actions, Next.

2 Likes

Got it, thanks! So…

  1. go to the details page for the scene switcher virtual device and use “settings” to set the number of scenes you want to have.

  2. create individual routines so that when the scene switcher virtual device is set to one of its scenes, other things happen on the SmartThings platform. Like a light changes to a specific color or you change the location mode or whatever. This is the outcome you want to get to.

So far all we’ve done is define what the scene switcher virtual device outcomes could be.

Now the magic happens. :wink:

  1. create a routine using one of your existing buttons as the if.

When you choose the scene switcher virtual device for the then, you will now get a whole bunch of different possible actions that can cycle through the scenes you created for the scene switcher virtual device in step 2.

End result: your physical button presses on your existing buttons can now do a lot more by triggering various scene switcher virtual device actions.

Did I get that right?

3 Likes

Could not be explained better!! :smile:

That’s the idea, smart buttons got superpowers now, they can execute random actions, they can cycle through actions, they can execute different actions on multi-tap even if the buttons don’t have multi-tap and even use hold / release to automatically switch scenes.

Indeed, even if it is scene oriented, they are just routines after all so it’s easy to get creative and use it in many scenarios. And can be triggered from other routines, not necessarily buttons although it’s made thinking in them.

1 Like

Also, if I’m understanding this, if I want to take a regular button and turn it into dimming control, I’m going to still have to create a scene for each dim level that I want to be able to adjust to. So 0%/10%/20%/ etc or 0%/25%/75%/100% or whatever. There’s no increment option, right? Or did I miss something?

I’m just asking because this is a very popular use case question. :thinking:

3 Likes

That is correct, the driver can only trigger other routines when the scene number changes, it cannot set the brightness of a light for instance. If you want to emulate a dimmer with 10 steps you would need 10 routines, one with 10%, another with 20% etc.

It would still be useful because the auto-cycle can go through them automatically so it would imitate the behaviour of a dimmer. And you could for instance make lower brighness scenes with warmer temperature and higher brightness ones with cooler temperature. Or, in low scenes turn off some devices and in high scenes turn on everything.

3 Likes

This driver works nicely for dimming lights connected to the SmartLife/Tuya app. I created Tap-to-Run Automations (scenes) in the SmartLife/Tuya app for 25%, 50%, 75%, & 100% brightness plus OFF. These scenes get imported in SmartThings and I used your Scene Switcher to connect the 5 scenes in ST to both a virtual button and a physical button.

The same thing could be done for fan speed control.

One question, would it be possible to build a virtual button into your Scene Switcher? It would eliminate the need for a separate virtual button in my use case. If not the existing set up works fine.

Thanks for developing this driver and sharing it with the community.

5 Likes

Thanks for the feedback! Glad you like the switcher :slight_smile:

I didn’t include any “controls” in the device for two reasons, the official one is so you can toss the device in some hidden room, forget it exists and control it how you like with buttons or other means like the virtual button you mention.

The second reason is probably the real one, I’m new to “custom capabilities” and just showing the list of commands was a pain :rofl:. I hope not having to touch that part because testing any little change requires waiting minutes or hours or creating new capabilities and presentations each time. I was about to give up even before implementing the code I enjoy writing which is the functionality :see_no_evil:.

Having said that, I’ll probably look into it eventually, a button could be helpful, that implies adding more settings to define the behaviour of the button. What would be the idea? Just going next to cycle?

Edit: Looks like it’s either the counter or the button but not both. I’ll let it stay that way for now…

5 Likes

Thanks for considering. Like I said it works fine the way it is.

1 Like

I have this set up. Took me a while to work out what was required, but I now have it working as a dimmer control for one of my lamps.

There is actually no need to set up a scene for each dimming increment as the routine can control the device directly.

The logic I have used is:

If up button pressed, then increase scene number by 1.

If down button pressed, decrement scene number by 1.

Also:

If scene number = 1, lamp dimmer value =10%
If scene number = 2, lamp dimmer value =20%
If scene number = 3, lamp dimmer value =30%

If scene number = 9, lamp dimmer value =90%
If scene number = 10, lamp dimmer value =100%

All up, I have 12 routines.

Is that the right approach?

1 Like

It’s a good approach if the lights don’t support increment actions or continuous change modes. If your lights are compatible with Mariano’s drivers then there are better ways to do that instead of cycling scenes.

I have also sets of different brightness/colour temperatures. When the brightness is low I prefer a warmer temperature so I usually change both values. In the living room there are scenes for max bright cool white, max bright 2700k, a less brighter 2700k and a night mode which goes down to 2200k and adds some colour touches on the back of the TV.

2 Likes

In this case, the term “scene” refers to the settings for the scene switcher virtual device. Not a SmartThings “manual routine.”

In your own post, you show setting up 10 scenes in the scene switcher virtual device settings. Which is one for each 10% increment.

3 Likes

I agree. I ramped the colour temp from 2750 to 5000 in 250 degree steps with each 10% brightness change.

1 Like

The globe I am controlling is a Nanoleaf Matter over Thread bulb. I don’t have the option to change drivers. Your system is a good work-around. Thanks for developing it.

2 Likes

Edit: Thanks to @Mariano_Colmenarejo in some comments below, the scene value surviving thing must be solved for the most part (although not the presets of the preset/recall mode, I’ll have to rethink that). Still, if the last scene used could not be recovered after a restart (I’m not exactly sure under which conditions that happens), it will use the Default Scene in settings.


Original text:

Let’s review a core feature more in-depth: Default Scene setting and how it can mitigate some shortcomings or simplify some use cases:

The Active scene value cannot survive a hub or driver restart, which will happen when I update the driver and it’s the reason I’ll try not to do it frequently. In that case you will see the Active scene is 0. However, 0 is not the actual current scene used internally after a restart but the Default Scene setting, which by default is 1.

What Default Scene to use? Let’s say you use it to switch lighting scenes from 1 to 10 which are supposed to be brighter as you increase the number. You were in 8, the driver restarted, you hit the Next button and instead of being in 9 you’re in 2! That would be so annoying. If you set the Default Scene to something intermediate, like 5, while there is still a gap between the expectations and what happened, it will be smaller on average.

‘Default’ is also one of the available actions you can assign to a button or trigger from other routines, so it is kind of a wildcard scene. Maybe you don’t even want to cycle scenes and just have the lights turn on a different way in summer and winter. That would be two scenes, call the Default action on your buttons or routines and change the default scene when the season changes instead of having to change it in every button and routine that turns on those lights.

2 Likes

New update: the blinker! (2024-04-05T10:04:17.625273583).

There is a new setting to account for routines that blink lights. I read someone at Reddit asking for it and thought “the switcher can do that!”. Then I tried to do it and something didn’t feel right, now it does!

Tutorial: How to build a Blinker or Flasher

Blink any light all the number of times you want with sub-second delay with only 4 simple routines or even 3 if the final state is predetermined.

Follow instructions in first post to install the driver and create the first Switcher if you haven’t already.

The switcher settings:

  • Set Number of scenes to 2. Only need On and Off for blink.
  • In the Auto-cycle settings, select Starting scene “< Scene 1 / Scene 2 >”. This will allow us to start the blinker from on or from off, depending on the previous state of the light.
  • Circular behaviour if not stopped: “Ends right before starting scene”. This will make sure the blinker finishes in the correct state, which is the opposite of the starting one.
  • Circular max loops is the number of blinks, pick 3 for instance.

The routines:

  • Create two routines to assign scene 1 to the On action and scene 2 to the Off action. Will look like this.

  • Now, if you want the light to finish in the current state, you’ll need two routines with the precondition being the state of the light and the trigger a button / sensor / virtual switch / whatever. One to call Auto-cycle [>] if the light is on (so it starts with off), and another to call Auto-cycle [<] if the light is off (so it starts with on).

3 Likes