Closed bonan closed 7 years ago
Interesting, how did you manage to pair a hue bulb to the Tradfri bridge?
When I implemented this line my compiler didn't warn me about this exception, that's pretty much why I forgot to check it :p
But I think a better approach than checking with startswith()
would be to catch the ArrayIndexOutOfBoundsException
.
You can pair a Hue bulb with a trådfri gateway in the same way you pair IKEA bulbs, with the remote. Just hold the remote up to 5cm away from a Hue bulb and follow the regular procedure. Bulb will start blinking and stop blinking once it's paired. You can then control it through the trådfri gateway. Though if you have the RGB bulbs the app and gateway have no way of controlling that and you won't be able to get updates for your bulb without the Hue gateway either.
As an aside, is what type of socket the bulb is useful information at all?
I think this patch doesn't work as intended, because socket.startsWith(" TRADFRI bulb ")
will never be true because of the leading space.
I would advise to check for a ArrayIndexOutOfBoundsException
, like I suggested earlier.
I've taken the leading space out of the test for now, I'll look at a better fix a little later in the week
Philips Hue lights identify their model with a simple string like
LWB004
orLWB010
, this causes the codeto throw a silent
ArrayIndexOutOfBoundsException
JSON response for my Hue light:
The patch modifies the above line to first check if the model starts with "TRADFRI bulb" before doing a split