Set Level - Duration of 0

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:

Potentially dumb question here - what would the proper way to call "setLevelInstant" be? I don't see it in the drop-down list in webCore... is it called by default if the duration is set to zero? I'm not home now to see light behavior and confirm if it's working or not...

Thanks!

I see the other two custom commands there (marked as custom), it should show just like those. First step would be to install the driver and make sure the command is showing on the device page. Then you need to get webcore to refresh the commands list for that device. I have no idea how to do that, I dont use webcore actually.

It's showing on webcore now - confirmed it was on the devices screen so I closed down and started a new instance of webcore and it was showing up.

I'll try it out this evening and let you know how it goes!

Cheers,
-Dan

Tested it as soon as I got home and it worked perfectly, thank you!!

I have posted an update to webCoRE that should allow to send the delay 0 (and hopefully not break things this time).

HPM repair to get it (user install of webcore)

2 Likes

Download the Hubitat app