How do you create virtual dimmers with fixed stages, like 4 steps or 10 steps?

I want to create a virtual dimmer that has a fixed number of levels. For example, my fan has 0%, 25%, 50%, 75%, and 100%. But the light has it in 10% increments. I would like this so I could tie my Dyson to HomeKit. I have the Dyson integration, but it doesn’t expose any controls to HomeKit. So I need virtual devices that match. Any one know how to create this type of control?

I used a virtual dimmer to select one of four choices. So, those 4 choices should be at 12.5, 37.5, 62.5, & 87.5.

Therefore, if I changed the dimmer to anything between 0-25, change to 12.5
anything between 25-50, change to 37.5
anything between 50-75, change to 62.5
anything between 75-100, change to 87.5.

Yours would be longer so that if you picked a value between 5-15, set to 10; between 15-25, set to 20; between 25-35, set to 30; etc.

I used Node Red for the automation but Rule Machine can do the logic also.

There is probably a better way but this worked fine for me.

As stated you could create rules to correct the level of it is not at the right spot. Other option would be to create your own virtual dimmer driver with groovy code.

Thanks. I was afraid it was something like this. I was hoping someone had a custom one where you’d pick the number of steps and it would create it ready made. But I guess that’s why Hubitat is a hobby, rather than a consumer friendly system. Thank you for confirming.

Sounds like what you are looking for is the ceiling fan controller. (Driver: Leviton ZW4SF Fan Controller) If nothing else, that driver may make a good template for what you need.

1 Like

I don’t think I could write my own from scratch. But perhaps I could make a copy of the existing fan Virtual Fan Controller and modify it to have the steps I want. It behaves like I want, but just has the wrong steps.

Any idea where I’d get ahold of the Groovy code for the Virtual Fan Controller? The problem I’m having is they have hard wired Low, Medium Low, Medium, Medium High, and High. That’s fine if you want to map five or fewer speed/brightness levels. You can maps those. But I want 10.

Here is a virtual fan controller you can peek at. It has the functionality of a dimmer and fan controller. You could remove the "Fan Control" capability to hide those commands.

On this when you set the level it looks like it will set whatever you specify but then will also convert that to a speed and set the speed, when the speed is set it will adjust the level to the proper values and set the level again.

That could be simplified for a dimmer only, to just be in the setLevel command, and to adjust the level before it sets it. Eliminate the setSpeed stuff.

Hubitat Enhanced Virtual Fan Controller · GitHub

They all seem to be based upon the idea that a fan controller should have five speeds max. You’re always mapping to low, medium-low, medium, medium-high, high, off, on, auto. You can map to fewer levels with this, but the max is 5.

I added code to add the option for 10 speeds, and the "Set Number of Speeds Supported” menu on Preferences reflects that change. But when you look at the “Set Speed” menu on Commands, it still only lists the five default speeds and off, on, auto.

Where does it get the low, medium-low, medium, medium-high, high, off, on, auto properties, and can they be changed?

Or maybe as you say, they aren’t relevant. Seems odd that Hubitat would assume all Fan switches would have a maximum of five speed settings.

Thanks.

It is part of the command definition which is included with the capability.

You could re-define the command in the driver and it will override the one from the capability. The options cannot be dynamic so its just a fixed string in the code.

1 Like

I used RM (In this case, I did it on the old version) for color temperature. The same concept works for Dim. This way, you can have as many steps as you want. In my case, there are two sets of lights with differing max values on Color Temp, so I had to use a variable to limit one set of lights to 4000 prior to activation. I also only wanted it to do anything on lights that were already on. For a Dimmer, you probably don't care about that.

Increasing

Decreasing

1 Like