setLevel() with duration setLevel(value,duration)


#1

I’m using Inovelli dimmer switches and the device handler supports setLevel with an optional duration parameter. This is a hardware fade-over-time built in to the switch firmware and also appears to be a standard zwaveV2 command that supports it zwave.switchMultilevelV2.switchMultilevelSet(value,duration)

In Hubitat Rule Machine I can issue the device command for either setLevel(value) or setLevel(value,duration). In other words, Hubitat Rule Machine allows the device command to have either 1 or 2 parameters and accepts it either way. If only one value is sent, the dimmer gets immediately set to that level. If two values are sent, then the dimmer fades to the 1st value with a time duration based on the 2nd value.

In WebCore, it appears that the setLevel() command can only take 1 value. Is there a way to tell WebCore that setLevel() can accept two values? If not, what other method can I send this device command with two parameters?

Here are the two commands inside the device handler

def setLevel(value, duration) {
    if (infoEnable) log.info "${device.label?device.label:device.name}: setLevel($value, $duration)"
    state.lastRan = now()
    def dimmingDuration = duration < 128 ? duration : 128 + Math.round(duration / 60)
    commands([
        zwave.switchMultilevelV2.switchMultilevelSet(value: value < 100 ? value : 99, dimmingDuration: dimmingDuration)
    ])
}

def setLevel(value) {
    if (infoEnable) log.info "${device.label?device.label:device.name}: setLevel($value)"
    state.lastRan = now()
    commands([
        zwave.switchMultilevelV2.switchMultilevelSet(value: value < 100 ? value : 99)
    ])
}

And here are the setLevel() command options showing in WebCore (just one “level” parameter with no option to add additional parameters)


#2

I don’t have Inovelli switches. Do you have any other ‘Set level’ available tasks under Do? Normally webCoRe will present to you what the driver has available.


#3

As noted previously, the driver has two setLevel entries. There is a
def setLevel(value) -and-
def setLevel(value, duration)

I understand programming languages in general but I’m a novice with groovy and I’m wondering if these double def statements is throwing off Webcore? I tried changing the order of those two in the .groovy file but it didn’t seem to make any difference. Hubitat seems to accept both forms in either order, but Webcore is only showing just one setLevel command with a single (value) parameter.

Here are all the tasks that WebCore shows for the Inovelli dimmers.
There is a childSetLevel and componentSetLevel but those are used for setting the intensity of the indicator LEDs on the switch itself, not for the dimming level of the load terminal.


#4

That is an odd one. I guess it is possible that setLevel() once only had one parameter and webCoRE dates from that time, but even the old Classic documentation defines it as setLevel( level, rate ) so it has had the option of two for a very long time.

I’m not clear how webCoRE’s UI is put together but the webCoRE SmartApp clearly defines the setLevel() command with just the level parameter, though the actual piston code looks like it is already looking out for a second parameter, which it refers to as delay.


#5

Yeah, I think the ui is missing the input for the 2nd parameter. Probably an easy fix, but also probably requires a Webcore developer and a code update - which could take a while. :disappointed_relieved:

Until then, I’m thinking I could edit the device handler to add a Custom Command like SetLevelWithDuration that inputs two parameters and then calls the built-in setLevel(value,duration) device command. :thinking:

But I need some guidance on how to do that. I think its just a few simple groovy commands that I need to add to the device handler. But I don’t know the correct syntax and my google-foo is not finding good examples I can glean from. :blush:

Can somebody here give me some guidance on how to make this a Custom Command that I will then be able to use in a Webcore piston? :nerd_face:


#6

If the UI is derived from information in the SmartApp then you might be able to just patch your own copy. With what is the question. I don’t find the webCoRE code easy to interpret. I can see where it might usefully be patched but I don’t know the implications of it.

For the DTH, off the very top of my head add …

command "setLevelWithDuration", [ number, number ]

in the vicinity of other capability, attribute and command statements. Then somewhere else, like out of harms way at the bottom of the file, add:

def setLevelWithDuration( value, duration )
{
    setLevel( value, duration )
}

It is not the modern approach but fortunately you only want it to keep webCoRE happy.


#7

@orangebucket Thanks for the guidance I got it working :+1:

Yeah its a bit of a kludge having to put a custom wrapper around a command that should work natively. But I don’t know how else to get WebCore to allow me to input the 2nd parameter on the native setLevel() device command. That would be my preferred solution. But at least I have a work-around now. Thanks again! :call_me_hand:


#8

Let me make sure that I understand. I am currently using the baked-in Hubitat Type “Inovelli Bulb Multi-Color”. It sounds like I would need to:

  1. download the driver code from Inovelli,
  2. make the edits,
  3. then select the revised driver Type for the bulb.

Sound about right?

Technically, the LZW42 bulb is no longer officially supported for the C7 hub. It kind of works - slow to respond or update status - but I only change settings a few times per day. Being able to transition without emulated fade would be fantastic.


#9

I have released an update on hubitat to fix this


#10

Fabulous! I just updated the App and implemented the new variable within a piston. Greatly appreciated.


#11

Thanks for the quick fix, but it needs a few fixes for the fix :wink:
See my post on the Hubitat community for more details