Set Level - Duration of 0

Apologies if this is a duplicate request, but I've been unable to find a post about this in my searches. From what I can tell, if you set level (any value) and duration of 0, webcore doesn't pass the 0 value for duration. Without that parameter, my driver reverts to my default of 3 for duration.

Not being able to define duration 0 means I can't get my "halo" lights to turn on that require somewhat rapid on, off, on cycles to activate.

I tried looking in webcore code to see where the limits for this might be set, but I was WAY out of my depth and could only see opportunities to break things.

Is my assumption correct? Is it something that could be changed relatively easily?

Appreciate any help!

1 Like

Is this a custom driver? Why is it defaulting to 3? shouldn't it default to 0?

The HE docs state duration is optional

see switchLevel

if this is custom driver, post the link to the code?

I have posted a change to webcore to allow this.

HPM repair webcore to get it, and let me know if it resolves this.

2 Likes

Sorry for the slow reply, I had to search up HPM repair first. I have HPM installed, but it doesn't list webcore as an app/package. It also didn't pick up any updates for webcore the first time it ran, at least not that I can see in the logs.

Is there another way to tackle this? Or am I missing something obvious in HPM?

I'm using the built-in webcore app, is that the problem. I just moved to Hubitat from ST and still pretty green figuring this platform out. Is there another way to run webcore that allows customization/updates?

Have you tried the Match Up functionality in HPM? Does that detect it?

It doesn't seem to detect any apps, just drivers. Is that normal?

So if using the built-in, you need to wait for HE firmware updates to get webCoRE updates. This is as expected.

Some of this is described in:

1 Like

When I migrated to Hubitat last weekend, i didn't realize there was an alternate installation method for webcore. Having just completed the transition of all my pistons, and reselecting all my devices in them, I'm not dying to do that again! I'll just wait for the update to push to the built-in app.

Thank you for the assist on this, I appreciate it more than you know! Seems to be a great community here - looking forward to getting involved in it.

1 Like

So This change to webcore has been reverted, as it caused a lot of issues for other folks.

I suggest you have your driver default to what you want, as this change is too disruptive to others.

Thats unfortunate, the zwave drivers I work on I have setup to use the device default if no duration is sent. This really should be the proper way to code a driver IMO. The default on these devices can be configured with parameters, but someone might want a fade in/out when pressing the switch physically and by default when commanding from voice control, but for a specific rule they may want an instant change and want to set duration of 0.

Question, since I dont use webcore, is it possibly to call custom device commands from webcore? Like if the driver was edited to add a setLevelInstant(level) function would it be possible to call it? I am thinking it would be pretty easy to add this in @michicago if you want to post a link to the driver, unless you know how to yourself? I would just have that function then internally to the driver call the normal setLevel command with the 0 duration.

1 Like

In that context, optional means null which tells it to use the devices default duration which is device dependent and not necessarily 0. Passing a value of 0 (not null) forces the device to override its default duration and move to level instantly

Webcore should support the 2nd parameter (duration) as an optionally passed in parameter.

Not debating, just dealing with it is causing problems, so had to revert it until the problems are understood.

2 Likes

@nh.schottfam Can you call custom commands on a device driver from Webcore similar to RM? Sorry I have never used webcore but this convo interested me due to my driver development.

Yes, I do it all the time. It gets a little tricky if you've selected multiple devices and they don't all support the same commands. I think webCore only shows you the commands that are common to all devices you've selected.

Thanks for the info. In that case @michicago if I can get a copy of the driver code, adding a special command to set the level with a 0 duration would be easy to add if you are not sure how to do it yourself. Let me know!

Why are you using setLevel for that? Why not just use on-off-on?

1 Like

That's unfortunate, thank you for the effort, though.

Have to agree. All these devices have a default duration, and there's an option to send a custom duration for a given command. 0 isn't null and should be a valid, optional duration. Oh well.

Because on/off uses a 3-second duration, the default value for my switches. That duration isn't compatible with turning on the Halo feature of the lights - it just cycles the main light on and off slowly.

All my lighting scenes use a fade, I don't like the instant on-off like a manual switch. So I set one default in my driver (3 seconds) and set variations from that in all my automations. It looks like I'll have to redo my automations to input a duration for every on/off/fade command now.

That would be great, thanks! I'm using this driver as a base, but made the following mods. From what I can gather from the log files, I think the driver does pass the duration of 0 as a parameter, but when it hits webcore the 0 duration is dropped. Webcore only passes the duration value if it's 1-255 (again, I think)...

Driver:

Original section:
def on() {
if (logEnable) log.debug "Turn device ON"
if (logEnable) log.debug "state.level is $state.level"
if (state.level == 0 || state.level == "" || state.level == null) {state.level=99}
setLevel(state.level, 0)

}

def off() {
if (logEnable) log.debug "Turn device OFF"
setLevel(0, 0)
}

def setLevel(value) {
if (logEnable) log.debug "setLevel($value)"
setLevel(value, 0)
}

def setLevel(value, duration) {
if (logEnable) log.debug "setLevel($value, $duration)"
def result =
state.bin = -1
value = Math.max(Math.min(value.toInteger(), 99), 0)

if (value) {state.level = value}

if (logEnable) log.debug "setLevel(value, duration) >> value: $value, duration: $duration"

return delayBetween([
        secure(zwave.switchMultilevelV3.switchMultilevelSet(value: value, dimmingDuration: duration))
    ] , 250)

}

Edited Section:
def on() {
if (logEnable) log.debug "Turn device ON"
zwave.basicV1.basicSet(value: 0xFF).format()

}

def off() {
if (logEnable) log.debug "Turn device OFF"
zwave.basicV1.basicSet(value: 0x00).format()
}

def setLevel(value) {
if (logEnable) log.debug "setLevel($value)"
setLevel(value, 3)
}

def setLevel(value, duration) {
if (logEnable) log.debug "setLevel($value, $duration)"
def result =
state.bin = -1
value = Math.max(Math.min(value.toInteger(), 99), 0)

if (value) {state.level = value}

if (logEnable) log.debug "setLevel(value, duration) >> value: $value, duration: $duration"

return delayBetween([
        secure(zwave.switchMultilevelV3.switchMultilevelSet(value: value, dimmingDuration: duration))
    ] , 250)

}

Ok give this a try. I downloaded the original and I think I got your mods added in here. I loaded it up on my hub on a virtual device and it does not throw any errors at least!

I added a new command "setLevelInstant", use this from webcore instead of the normal setLevel to set the level, the 0 duration will be automatically applied by the driver.

If you click on the "Revisions" tab the way I posted it you can see the changes from the original driver to my modified version (including your modifications).

1 Like

Man, that's awesome! I don't know what to say...

I wanted to add a custom command like you did, but I kept getting errors when I tried to save the driver... I knew what I wanted to do but the syntax just eluded me.

I'll load this up and give it a try this evening - thanks again!! :beers: