[ST Edge] Virtual Dimmer Device Driver

It is recommended to use this new driver


I have made a driver that implements Virtual Dimmer.
This Virtual Dimmer is normal Dimmer and it includes also Step Level function.

This Virtual Dimmer can be used with Zigbee Lights and Matter Lights.

Virtual Dimmer Device’s Settings:

Using Setting Minumum Level when using Step Level is possible to adjust minimum Dimmer Level. The setting only affects Step Level operation. Using the dimmer function, it is possible to set lower dimming levels.

By using the On Off Mode setting, is possible choose whether the Step Level function (setting step level) affects the device’s status (Switch On).
Default setting is that the Step Level function affects the device’s status.

@mocelet has made some driver testing.

I have used Ikea Rodret Dimmer driver

for testing this Virtual Dimmer.

Channel enrollment and driver installation

Enroll your hub into my SmartThings channel
Invitation Link
and install the Edge Driver called Virtual Dimmer StepLevel Tx.

Step Level function can be controlled using SmartThings App routines and Rodret buttons.

Virtual Dimmer Devices works with the Smart Lighting switch sync.
@mocelet has made also the Smart Lighting testing.

I have not used the Smart Lighting function and so I cannot advise its use.

Using these Rules API rules Virtual Dimmer operates as master Light and
every time Master Light is operated rules copies the master light state to slave Light(s).

Using AWA for adding Rules API rules.

Copy and paste Device IDs from AWA Devices to template rule

Keep quotation marks at the beginning and end of Device ID

Paste new rule json to yellow marked area in Add a Rule.

Rule: Virtual Dimmer Level Changes or On > Copy Level

	   {
		 "if": {
		  "or": [
		  {
			  "changes": {
				"operand": {
				  "device": {
					"devices": [
					  "-- ID Virtual Dimmer Device --"
					],
					"component": "main",
					"capability": "switchLevel",
					"attribute": "level",
					"trigger": "Always"
				  }
				}
			  }
		  },
		  {
			  "equals": {
				 "left": {
					"device": {
						"devices": [
							"-- ID Virtual Dimmer Device --"
						],
						"component": "main",
						"capability": "switch",
						"attribute": "switch",
						"trigger": "Always"
					},
				 },
				 "right": {
					"string": "on",
				 }
			   }
           }
		  ],
		   "then": [
			  {
				"command": {
				  "devices": [
					"-- ID Real Lamp Dimmer Device --"
				  ],
				  "commands": [
					{
					  "component": "main",
					  "capability": "switchLevel",
					  "command": "setLevel",
					  "arguments": [
						{
						  "device": {
							"devices": [
							  "-- ID Virtual Dimmer Device --"
							],
							"component": "main",
							"capability": "switchLevel",
							"attribute": "level"
						  }
						}
					  ]
					}					
				  ]
				}
			  }
			]
		}
	   }

Rule: Virtual Dimmer Off > Real Lamp Off

        {
            "if": {
				"equals": {
					"left": {
						"device": {
							"devices": [
								"-- ID Virtual Dimmer Device --"
							],
							"component": "main",
							"capability": "switch",
							"attribute": "switch",
						    "trigger": "Always"
						}
					},
					"right": {
						"string": "off"
					}
                },
                "then": [
				{
					"command": {
						"devices": [
							"-- ID Real Lamp Dimmer Device --"
						],
						"commands": [
							{
								"component": "main",
								"capability": "switch",
								"command": "off"
							}
						]
					}
				}
                ]
            }
        }


To devices list is possible to add multiple Lights IDs (comma separated).

Great driver that can theoretically work with any light since for SmartThings it’s a dimmer and it does not depend on the light’s driver.

I believe so far it’s the best generic workaround to the notoriously missing relative dimming action in SmartThings (really, why is that not a stock feature when even Zigbee and Matter have native step commands??).

Gonna try it as soon as possible. This way I could get rid of about 30 routines.

I’m not at home right now but I could point a camera at one of my lights to test the driver. Such a shame that I forgot to attach two fingerbots to the STYRBAR…

For testing you can use manual routine

I know. It was a joke.

Since people were asking about Smart Lighting, if I recall correctly it has to be enabled first in the routines tab, clicking the discover icon and then scrolling to the end. I found a post with the screenshots so I’ll just link it:

In regions where it’s not available, the workaround is creating the Rules to sync the light and the dimmer as per the second comment of this post.

By the way, even though my button driver is mentioned, it’s not really needed, any smart button will do of course. However, if you happen to use my button driver, there’s an auto-repeat Held feature that you can use for steps so the brightness keeps increasing/decreasing while you keep the button held.

This replaces @mocelet awesome Scene Switcher in my case.

Routines needed for two lights and 20% steps:

Now down to two routines per light (group).

I just hope that the Smart Lighting doesn’t disappear like it happened in the past. I had to re-add it two times.

Great work, @TapioX !

Upon request, a picture of the buttons to understand what kind of devices this driver is intended to be used with:

Thanks for recommending this. It does the job for toggling light brightness.

@mocelet, I noticed that there’s a significant delay between input and execution. Is there something that can be done to minimise time taken between pressing/holding the button > displaying the appropriate result?

E.g: Holding down the 5 button remote is only executed after fully letting go of the button and waiting it to increase/decrease from 0-100/100-0

Let’s go step by step :slight_smile:

Does the dimmer change the brightness of the lights when you manually change it from the app?

How did you set the routines for the buttons? If it’s like in the example of the first post, with the Pressed event, a single “click” is a step. If you want to step two times you’ll have to click it twice.

I have also tested Virtual Dimmer Device and Wiz Lamps.
Wiz Lamps are connected using Cloud to Cloud connection to SmartThings.
Wiz Lamps also support the use of the Matter protocol, but I haven’t taken it yet in use.

I have used 4 Button Device to control Virtual Dimmer Device.

Airam Remote

The top Button is controlling Virtual Dimmer On / Off switching.
The second Button is controlling dimming (for example -15%).
The third Button is controlling dimming (for example +15%).

4 ST APP routines implement Virtual Dimmer control using Button Device.

2 Rules API rules implement Wiz lamps control from Virtual Dimmer.
Rules API rules are operating in cloud, because Wiz Lamps are connected using Cloud to Cloud connection to SmartThings.

The control speed of Wiz lamps is surprisingly good.
According to my estimate, it takes a little over a second from pressing the button until the lamps light up or change dimming level.

Even if I were able to fall asleep, I’d wake up in the middle of the night, connect them via Matter and finally sleep like a baby afterwards.

Talking about WiZ, I measured the WiZmote and its dimming capabilities. For those who don’t know, that’s the native remote for WiZ that communicates directly with the light using the ESP-NOW protocol, it’s great as a manual backup since it works even if the hub or the router dies.

The numbers:

  • Steps are 10% and, since it has dedicated on/off buttons, the minimum brightness is 10% and won’t go to 0%. The step has a beautiful gradual transition.
  • When you hold the brightness buttons it will brighten or dim continuosly but it’s actually the same 10% steps, just repeated until you release the button. The transitions are so seamless that it feels continuous. I don’t know if the remote protocol has a start/stop, it probably just repeats the same step command.
  • The time to go from 100% to 10% while holding the dim button is around 3 seconds, that would be an auto-repeat interval of around 350-400 milliseconds between steps.

Just writing it down so I don’t forget :sweat_smile:

hey

dumb question. I installed the virtual switch and i can see it in smartthings. Now how can i make it control a specific light?

Now comes the potentially cumbersome part :slight_smile:

In SmartThings app, Routines tab, click on Discover, scroll to the end, is there a Smart lighting feature? If yes, go there, tap + and create an action to “sync with switch” that should look like the screenshot in the first post.

If you’re in a country where there’s no Smart lighting you’ll have to follow the instructions for the Rules in the second post so the dimmer switch controls the lights you want.

When the virtual dimmer and the light are linked so to speak you can create the automation in the button, like in the screenshots.

What is the recommended way to use this virtual dimmer to brighten and dim a light while a button is held down? I’m trying to automate LIFX (Matter) lights using gradual dimming, in this case, step up or down 10% on button press (got that done already), or step up or down 10% every XXX ms while the button is held down, and stop when it’s not held down.

Basically, it seems that you need to execute a routine of Step Dim +/- 10 repeatedly, while a button is in held down state, and stop the repeated execution when the button is released. I’m not using any IKEA buttons. I’m using Zigbee (Philips Hue Dimmer Switch), Z-Wave (Minoston, Zooz), and Matter (LIFX Switch over Wi-Fi) buttons.

The LIFX Switch natively does gradual dimming and brightening (both button press and held down for continuous dimming), but it uses the LIFX Cloud, so when internet goes down so does your ability to dim or toggle the lights.

That’s hard to do in SmartThings. For starters, you need a button that sends the release event and a custom driver that handles it because stock drivers won’t. Even then, you can’t easily create routines to start / stop a loop with sub-second delay, you’d need more virtual devices.

With my custom drivers for IKEA buttons like the RODRET or the STYRBAR it’s piece of cake since they do all the work in the background. Just enable the auto-repeat Held setting, adjust the repeat interval and assign the step to the Held action.

@mocelet, can you explain a little further? Specifically, I’m going to interrogate my button devices (listed above) today and see which of them send a release event. Some have custom drivers and some have stock drivers.

My current thought–without more programming–is that I can use the held down event to start Auto-Cycle on the Scene Switcher virtual device, which just cycles between two scenes: 1 and 2. I think I can get away with one routine, that says that if the scene number changes (1 OR 2) then execute the Step function on the virtual dimmer switch. When the release event occurs, Auto-Cycle stops.

That resolves the general functionality, but I don’t know how to resolve the sub-second delay that you mention, i.e., how to shorten the time or if there are hard-coded execution limits on the SmartThings hub.

Would it speed things up if your Virtual Dimmer Device Driver exposes an action to “Start Step Dimming,” which automatically steps up (+) or down (-) a specified increment every X ms (specified in the routine action string, such as “-10,200” for -10% step every 200ms, until it hits 0% or 100%? Basically you could build the loop into the Virtual Dimmer Device Driver, instead of into the button driver. You still need the button to expose the Release event, which would cause a routine to execute the action “Stop Step Dimming In Progress” on on the Virtual Dimmer Device Driver.

I don’t think it’s worth the trouble, but…

… yeah, if your button has held / release you can use my scene switcher to repeat one action with sub-second intervals, you’ll need one switcher for the step +10% and another for the step -10%. The settings you need to change are:

  • Number of scenes: 1
  • Switching delay: 500 ms
  • Circular max loops: 10

That way, you can start / stop the stepping with held / release if your button supports it.

I limited the time to 500 ms to avoid performance issues, especially if misconfigured. Also, if it’s too fast, by the time you release the button the lights will be in another level and not in the one you wanted.

Do you adjust the brightness so many times? I believe a better strategy is automating the brightness for the time of the day so you just need subtle adjustments, which would mean just one or two button presses so no need for repeating anything.

Thank you. I will try it with the scene switcher and 500ms. First thing is to find out which of my buttons support a “release” action.