Issuing set level to 80% but level set is 1%

heres the device log:

[dev:376] 2018-05-19 14:41:10.262:infodW LN LI color temperature is 4000°K
[dev:376] 2018-05-19 14:41:10.262:debugevt- rawValue:250, value: 4000, descT: dW LN LI color temperature is 4000°K
[dev:376] 2018-05-19 14:41:10.261:infodW LN LI color is Moonlight
[dev:376] 2018-05-19 14:41:10.257:debugParse: read attr - raw: 61880103000C070021FA00, dni: 6188, endpoint: 01, cluster: 0300, size: 0C, attrId: 0007, encoding: 21, value: 00FA
[dev:376] 2018-05-19 14:41:10.123:infodW LN LI is 1%
[dev:376] 2018-05-19 14:41:10.122:debugevt- rawValue:2, value: 1, descT: dW LN LI is 1%
[dev:376] 2018-05-19 14:41:10.118:debugParse: read attr - raw: 61880100080A00002002, dni: 6188, endpoint: 01, cluster: 0008, size: 0A, attrId: 0000, encoding: 20, value: 02
[dev:376] 2018-05-19 14:41:10.059:infodW LN LI is on
[dev:376] 2018-05-19 14:41:10.058:debugevt- rawValue:1, value: on, descT: dW LN LI is on
[dev:376] 2018-05-19 14:41:10.054:debugParse: read attr - raw: 61880100060A00001001, dni: 6188, endpoint: 01, cluster: 0006, size: 0A, attrId: 0000, encoding: 10, value: 01

this is for the generic zigbee CT bulb (dev) driver.

thank you.

edit: if i change the driver type to generic zigbee bulb without any other changes the light level gets correctly set to 80%.

this looks like a log of refresh...
what happens when you do setLevel 80 from the driver UI?

not sure what you mean by log of refresh ... this was captured by turning on debug log in the device settings then having the app try to set level.

works fine.

well now I'm confused, you sent it a set level and it works?, and it does something weird from an app?, what app?
that's not the log output produced by issuing just a setLevel, that log output also includes the results of running a refresh, which you do not need for this driver.

If the refresh is issued before the setlevel completes you'll get inaccurate results due to the ramp time.

Left alone, IE not provoked mid transition these drivers don't report the final achieved level until the transition is complete.
so if you have a ramp of 5 seconds these drivers aren't going to report that until 5 seconds later.
This was done to follow the behavior of zwave devices which only report level changes at end of transition.

reproduced it. heres the relevant code:

    def colorTemperature = null
    def level = null
    thisRule.switchesOn.each      {
        it.on(); pauseIt()
        def itID = it.getId()
        if (thisRule.color && state.switchesHasColor[itID])     {
                it.setColor(thisRule.hue); pauseIt()
        }
        else if ((thisRule.colorTemperature || (thisRule.level == 'AL' && autoColorTemperature)) && state.switchesHasColorTemperature[itID])       {
            if (!colorTemperature)      {
                if (thisRule.level == 'AL' && autoColorTemperature)
                    colorTemperature = calculateLevelOrKelvin(true) as Integer
                else
                    colorTemperature = thisRule.colorTemperature as Integer
            }
            if (colorTemperature)
                it.setColorTemperature(colorTemperature); pauseIt()
        }
        if (thisRule.level && state.switchesHasLevel[itID])     {
            if (!level)     {
                if (thisRule.level == 'AL')
                    level = calculateLevelOrKelvin(false) as Integer
                else
                    level = thisRule.level as Integer
            }
            ifDebug("turnSwitchesOnAndOff: level: $level")
            if (level)
                it.setLevel(level); pauseIt()
        }
    }

when the setColorTemperature is issued followed by the pauseExecution then setLevel - then it fails. however if the setColorTemperature and the pauseExecution is not issued only the setLevel then it sets it to the right level.

i dont actually issue a refresh in the code ... that i know of. :slight_smile: so trying to figure why that is getting issued. i am wondering now if the pauseExecution in between does something to result in this behavior.

edit: nope. removed the pauseExecution that was being issued after the setColorTemperature that still results in the setLevel being set to 1% instead of 80%.

edit2: commented out the setColorTemperature entirely now setLevel works fine. also the refresh no longer shows up in the log.

[dev:376] 2018-05-19 16:24:54.383:infodW LN LI is 80%
[dev:376] 2018-05-19 16:24:54.383:debugevt- rawValue:204, value: 80, descT: dW LN LI is 80%
[dev:376] 2018-05-19 16:24:54.379:debugParse: read attr - raw: 61880100080A000020CC, dni: 6188, endpoint: 01, cluster: 0008, size: 0A, attrId: 0000, encoding: 20, value: CC
[dev:376] 2018-05-19 16:24:54.185:infodW LN LI is on
[dev:376] 2018-05-19 16:24:54.184:debugevt- rawValue:1, value: on, descT: dW LN LI is on
[dev:376] 2018-05-19 16:24:54.181:debugParse: read attr - raw: 61880100060A00001001, dni: 6188, endpoint: 01, cluster: 0006, size: 0A, attrId: 0000, encoding: 10, value: 01

Not sure what you're trying to do here but I think the set level is running before set ct completes, set ct also has a transition time which defaults to 1 second.
This obviously doesn't happen with the standard bulb driver since it doesn't support ct.
I doubt this can be overcome or is an issue with the driver, it's only going to do what you tell it to do.
You might look into the prestage options on these drivers, they allow you to set color and ct while the bulb is turned off, then a subsequent on or set level will use those presets vs the color and ct the bulb had previously.
All of these drivers report attribute values at the time they were requested (which is after command completion), so the bulb is saying 1%, then it's 1%

so i changed the setLevel to setLevel(level, 1) ... that works around the issue.

i think you are right this is what is going:

on the setColorTemperature can i specify transition in ms as in what is the lowest value for transition time i could use?

while on the topic does setColor also support a transition time?

thanks.

Transition time is currently integer seconds, ive considered making this a BigDecimal which would allow for 1.5 seconds ect..., just not a super priority atm.

Set ct and set color do not have optional ramp parameters like set level does, they use the value from the preference setting in the driver, backward compatibility sucks right?

1 Like

ok. when not specified does the transition time default to 1 sec in all cases? seems like for setColorTemperature it might be defaulting to 1 sec but for setLevel its defaulting to 0 sec.

The prestage options do not use any ramp rate, there's no need as the bulb is off...

on the preferences though it supports 500 ms ... how are you handling that without BigDecimal?

Set level is supposed to be an int, the zigbee cluster supports ms so I can do what I want internally.

1 Like

ok just the input parsing needs to change ... not a big change then. :slight_smile:

thank you.

2 Likes