Fun case number 9. Build an auto-repeat Step dimmer level while holding a button
Sometimes you need a way to auto-repeat something, for instance brightness steps of this virtual dimmer so you can mimic with buttons the behaviour of a smart dimmer when holding / releasing a button. Note there may be more ways depending on your devices, this is just one more alternative.
The EASY way: using TWO scene switchers
A switcher with one scene in circular mode is basically an auto-repeat, so use two, one for stepping up and another for stepping down. Just change these settings for each:
- Number of scenes: 1
- Circular max loops: 10
Then create the automations, quite trivial. For one, if Active scene is 1 then step up, for the other, if Active scene is 1 then step down. For the button held events run the Auto-cycle [>] and for the release the Auto-cycle [STOP].
That’s it, we can leave it here, thanks for watching
.
The HARD way: using ONE scene switcher
I saw this comment trying to achieve the same result with only one switcher to reduce the device count. Although I implemented the auto-repeat in the driver, I found the idea amazing and challenging so I’ve replicated it and will suggest some optimizations.
The clever idea is being able to step up with Auto-cycle [>] and step down with Auto-cycle [<] using just a couple routines, the linear mode and a high number of scenes. When we sit in the middle, the half in one direction repeats the step down and the other half repeats the step up.
Let’s build it to achieve this especifically: two buttons, one for brightening (>) and another for dimming (<) and just a stop in the release action:
First things first, create the virtual switcher and change these settings:
- Number of scenes to cycle: 21
- Cycle mode: Linear. Will not loop
- Targeted action window: 0 (at the very end of the settings, crucial for the reset)
Reseting to middle position
The idea is that scenes 1 to 10 step down and 12 to 21 step up, of course you won’t need 20 routines
. If we are in 11, an auto-cycle in one direction will auto-repeat the step down and in the other auto-repeat the step up.
We need to reset the position every time, for that we can use the routine condition Auto-cycle: stopped and set Scene 11:
The actual stepping
This is conceptually easy since it’s just two routines:
- If Active Scene is equal to or below 10 then step down 10%.
- If Active Scene is equal to or above 12 then step up 10%.
But that won’t work if you create the routines in the app because SmartThings will not trigger the routine multiple times as it creates the rules as changesOnly: true and will only trigger one time for scene 10 instead of every time for 10, 9, 8, etc.
You’ll need the Rules API for that. If you create the routine in the app it’s basically the same JSON code that you can see in the AWA but removing the changesOnly line and those type lines.
Rule to auto-repeat the step up
[
{
"if": {
"greaterThanOrEquals": {
"left": {
"device": {
"devices": [
"SCENE SWITCHER ID HERE"
],
"component": "main",
"capability": "panelorange55982.activeScene",
"attribute": "scene",
"trigger": "Always"
}
},
"right": {
"integer": 12
}
},
"then": [
{
"command": {
"devices": [
"DEVICE ID THAT YOU ARE STEPPING HERE",
"MORE DEVICES IF NEEDED",
"YOU MAY HAVE TO CHANGE THE COMMAND TOO"
],
"commands": [
{
"component": "main",
"capability": "panelorange55982.stepLevel",
"command": "stepLevel",
"arguments": [
{
"integer": 10
}
]
}
]
}
}
],
"sequence": {
"then": "Parallel",
"else": "Parallel"
}
}
}
]
Rule to auto-repeat the step down
[
{
"if": {
"lessThanOrEquals": {
"left": {
"device": {
"devices": [
"SCENE SWITCHER ID HERE"
],
"component": "main",
"capability": "panelorange55982.activeScene",
"attribute": "scene",
"trigger": "Always"
}
},
"right": {
"integer": 10
}
},
"then": [
{
"command": {
"devices": [
"DEVICE ID THAT YOU ARE STEPPING HERE",
"MORE DEVICES IF NEEDED",
"YOU MAY HAVE TO CHANGE THE COMMAND TOO"
],
"commands": [
{
"component": "main",
"capability": "panelorange55982.stepLevel",
"command": "stepLevel",
"arguments": [
{
"integer": -10
}
]
}
]
}
}
],
"sequence": {
"then": "Parallel",
"else": "Parallel"
}
}
}
]

