Tradfri LED RGB bulb

QC also spotty. I have had to return a few with radios that were DOA.

TL;DR
I hacked puzzle-star handler/driver I got something to work. Modified driver can be found @ Hubitat IKEA Tradfri RGB bulb driver · GitHub

I took puzzle-star's ST handler/driver, changed the import to import com.hubitat.zigbee.DataType and I managed to successfully save the driver.

When using the device I can turn it on and off and change the brightness - so far so good. However when I try to make a color action, let's say onBlue nothing happens. In the logs I get the following line

error java.lang.NullPointerException: Cannot invoke method div() on null object on line 521 (onBlue)

What's weird is that nowhere in the source I see a call to div() and onBlue is on line 494 and looks like this:

def onBlue() {
  def rgb = getCurrentRGB()
  if(state.lastBlue) setColor(rgb.red, rgb.green, state.lastBlue)
}

Can I get the whole exception stack somewhere?

Edit:
Even when I use other commands, I see the exact same error description, e.g.
error java.lang.NullPointerException: Cannot invoke method div() on null object on line 521 (offRed)
error java.lang.NullPointerException: Cannot invoke method div() on null object on line 521 (onRed)

So I guess that div() call on line 521 is a reference to some place in Hubitat's source code.

Edit2:
I tried testing setting the color from the color wheel, and I got the following error

error java.lang.NullPointerException: Cannot invoke method rgbToHex() on null object on line 415 (setColor)

I imported import hubitat.helper.ColorUtils and changed colorUtil.rgbToHex and colorUtil.hexToRgb to ColorUtils.rgbToHEX and ColorUtils.hexToRGB and made some progress. Now the error I get is:

groovy.lang.MissingMethodException: No signature of method: static com.hubitat.zigbee.DataType.pack() is applicable for argument types: (java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [24455, 33, 1]

Edit 3:
I looked a bit around the docs and found zigbee.convertToHexString method. I manually swapped the bytes to encode and replaced usages of DataType.pack() with zigbee.convertToHexString() and it's working!

Well, different actions like onBlue, offBlue, setBlue are still failing because div() is called somewhere on a null object, but setColor is working and bulb is changing color. There is a message received after color is set, and there is a warning:

warn DID NOT PARSE MESSAGE for description : catchall: 0104 0300 01 01 0040 00 7FDC 00 00 0000 0B 01 0700

So it's hacky and dirty, but hey, it's somewhat working. Code is @ Hubitat IKEA Tradfri RGB bulb driver · GitHub

2 Likes

Great attempt mate but way too many errors unfortunately. Hopefully one day they release this with some colours albeit even if the green isn't perfect.

1 Like

New revision is up. Everything seems to be working now.

2 Likes

Nice one I will try it out tonight and let you know how I get on.

There's 2 issues with the Ikea bulbs, there is no green so marketing these as rgb is a cruel joke, secondly they only report color in xy, they do not support hue and saturation.
Rgb -> xy and rgb <-> hsv work well, however I've not seen any xy -> rgb formulas that can survive rgb -> xy -> rgb with any level of accuracy, so I've given up any attempt to support these at this time.

1 Like

But the Hue bridge supports them. Is there a chance to get support through the Hue Integration driver? I’m with you 100% on the crappy color, and where I wanted a splash of color, I’ve replaced it with a Hue bulb. But now I’m using the TRÅDFRI in my hallway for a white light during the day, and dimmed burnt orange late at night so it doesn’t shock us out of sleep when we get up to use the bathroom.

I’m having to use a trick with Google Assistant Relay to have HE change the lights from white to orange, and back again. Since that’s cloud dependent, it doesn’t always work. For this simple use case, direct control over the bulb via the Hue Bridge from HE would be a very welcome improvement.

Can't, for the same reason, they only report xy to hue, so that puts the xy conversion back on our end.
xy -> hsl is possible of course, it's just beyond my tiny brain, and what I've tried off the internet was too inaccurate in my opinion.

1 Like

Still plenty of errors in the logs though so I had to revert back. I am seeing a ton of the following:

dev:7132019-10-22 06:32:39.963 pm warnDID NOT PARSE MESSAGE for description : catchall: 0000 8021 00 00 0040 00 91A5 00 00 0000 00 00 8E00

dev:7132019-10-22 06:32:37.974 pm errorgroovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.math.BigDecimal#multiply. Cannot resolve which method to invoke for [null] due to overlapping prototypes between:

Encouraging :popcorn::face_with_hand_over_mouth:

Someone with more zigbee experience will have to step in here and decipher this message, but I think this is not important. Device is sending something but for me everything works without it.

As for the error, it seems that state.colorX is null and multiplication fails. Can you confirm that from device details page? If you can give me exact repro steps I can look into it. Have you tried hitting configure and/or refresh.
I saw an issue where X gets updated and calculation to RGB takes place, and Y is not defined so it errors out. However next event updates Y, but state.X is null for some reason, although it should have gotten set by a previous event.

In any case, if you can get me your whole state, and repro steps, I can try and help.

1 Like

Fair enough. It seems anytime anything is selected it drops in this message so if anyone can get rid of this that would be great!

When selecting things like off blue, on blue, off red, on red etc are all a little messed up and are the ones that lead to those errors. It might be worth just removing those options completely then? I find that using set color by name and next color works well anyways albeit with that zigbee error.

for devices such as this you should drop any frames that start with catchall in parse...
These are ZDO messages and aren't normally used in drivers.

An example of this can be found on line 64 of the rgbw example driver in our public repo

2 Likes

Just wanted to give a HUUUGEEEEEE thank you for this!

Using SharpTools things work absolutely perfect.

2 Likes

Thanks mate that additional code (shown below) resolved the errors. I still couldn't get it to go to 100% when dimming only 99% but hey that's alright I can live with that.

if (description.startsWith("catchall")) return
2 Likes

I tested your driver with a "E26 CWS opal 600lm" but I can't even turn it on/off (I can at least do that with generic "hueBridgeBulb" driver).
Any clue why?

Try sending configure or refresh commands first. Is there anything in the log ouptut?

I guess you mean line 90 as of August 2020 version.

Using Pedro Garcia’s driver I am able to control the IKEA Tradfri “RGB” bulbs.

Through “Device” I am able to dim and change colors (within its capabilities) as well as though Dashboards. Dashboards only allow to close the color window with the bulb “off”, but otherwise is fully functional.

Through Apps (I.e. Rule Machine) I can toggle them as a switch, but not as a bulb. Neither can I adjust the sim level, or the color.

Is there a way in Rule Machine to send a ColorName command to the bulb, as I can through “Device”?

It would appear that yes, you can [Edit: Sorry wrong screenshot. Reposted]