vchlum / hue-lights

Gnome Shell extension for Philips Hue compatible lights controlled by the Philips Hue Bridge and for controlling Philips Hue HDMI sync box.
https://extensions.gnome.org/extension/3737/hue-lights/
MIT License
196 stars 14 forks source link

IKEA bulb reporting wrong colormode (preventing menu from loading) #61

Closed titix12 closed 1 year ago

titix12 commented 2 years ago

Hello,

My setup contains a mix of Signify products (lamps, sensors) and a few third party products, among them two TradFri Bulbs : Color Temperature Light (TRADFRI bulb E27 WS opal 980lm)

Bridge association was quite simple and everything worked "out of the box", but suddendly stopped working, on a fresh session clicking the menu showed nothing

Errors were found in the logs :

journalctl /usr/bin/gnome-shell -f -o cat

JS ERROR: TypeError: this.bridesData[bridgeid].lights[lightid].state.xy is undefined
_getGroupColor@/home/dk/.local/share/gnome-shell/extensions/hue-lights@chlumskyvaclav.gmail.com/extensionmenu.js:258:1

What the source code says :

 switch (this.bridesData[bridgeid]["lights"][lightid]["state"]["colormode"]) {
                case "xy":
                       [tmpR, tmpG, tmpB] = Utils.XYBriToColor(
                               this.bridesData[bridgeid]["lights"][lightid]["state"]["xy"][0],

A dump of the Ikea Tradfri bulb object :

{"state":{"on":true,"bri":130,"ct":250,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"swupdate":{"state":"notupdatable","lastinstall":"2021-11-10T18:34:35"},"type":"Color temperature light","name":"Color temperature light 1","modelid":"TRADFRI bulb E27 WS opal 980lm","manufacturername":"IKEA of Sweden","productname":"Color temperature light","capabilities":{"certified":false,"control":{"ct":{"min":250,"max":454}},"streaming":{"renderer":false,"proxy":false}},"config":{"archetype":"classicbulb","function":"functional","direction":"omnidirectional"},"uniqueid":"d0:cf:5e:ff:fe:1f:05:7f-01","swversion":"1.2.217"}

Althought colormode is set to "xy", ...["state"]["xy"] is undefined and ["state"]["ct"] is

At this point I chose to ignore Ikea equipements and the menu showed up

       if (this.bridesData[bridgeid]["lights"][lightid]["manufacturername"] === "IKEA of Sweden")
                {
                        Utils.logDebug("Found an IKEA bulb");
                        Utils.logDebug(this.bridesData[bridgeid]["lights"][lightid]["name"]);
                        continue;
                }

But there are many occurences of this check, and I'm not comfortable enough with JS to provide a decent patch

grep -n  '\["state"\]\["xy"\] === undefined' extensionmenu.js
246:            if (this.bridesData[bridgeid]["lights"][lightid]["state"]["xy"] === undefined &&
353:                if (data["lights"][id]["state"]["xy"] === undefined) {
1512:            this.bridesData[bridgeid]["lights"][lightid]["state"]["xy"] === undefined &&
1567:            this.bridesData[bridgeid]["lights"][lightid]["state"]["xy"] === undefined &&

Any help on this ?

vchlum commented 2 years ago

Hi @titix12 ! Thank you for a great report. I will look into it. I suppose this is a bug of the Ikea bulbs. It is really confusing that your bulb says "colormode":"xy" but it is not actually true:-) I will prepare a fix for Ikea bulbs and ask you for a test, ok? Can not say when... I hope within two weeks.

titix12 commented 2 years ago

No problems, I'll be happy to help !

vchlum commented 1 year ago

I'm so sorry @titix12 for log waiting... I believe I fixed your issue. You can try it if you wish.

titix12 commented 1 year ago

Thanks @vchlum !

I'm running Debian Bullseye, shipped with Gnome 3.38 which is incompatible with this extension since version 25 :'(

I tried manual installation with latest commit but ended up with a segfault as soon as i click the Settings menu. [136938.576076] gjs[303819]: segfault at 100000019 ip 00007f5cbe8c3319 sp 00007fff74f402b8 error 4 in libc-2.31.so[7f5cbe787000+15a000]

( Debian bookworm is on its way, hopefully i'll be able to test soon )

vchlum commented 1 year ago

Bookworm is out. I hope it works. From now on, due to upstream changes, the new versions will be only for Gnome 45. I am closing this.