Controlling Ikea Trådfri lights, take two
2018-Feb-23, Friday 02:30 pmI wrote about playing with Ikea Trådfri before, but, Ikea pushed an update back in October that changed the process. Basically you need to get a personal/device key first, instead of just using the security code on the gateway.
You can send a discovery request, and get back all the valid end-points, without getting a psk;
But for most things you need that psk. Send the request;
And it will reply with your psk, like;
Now if you want to query the list of devices;
To query the state of a device/bulb;
There are more settings in "3311" now.
"5850" controls on/off and takes 0 or 1.
"5851" controls brightness, and takes values between 0 and 255.
"5709" and "5710" seem to work together to control the colour temperature.
"5706" is clearly a colour hex code.
"9003" is a mystery.
"5717" and "5711" are specific to the white bulbs.
"5707" and "5708" are specific to the white/colour bulbs.
Yes, I picked up a colour bulb. You can set a colour like;
I indexed the colour options; there are 9 reachable from the remote, and 20 from the app colour picker (11 in addition to the remotes 9). But. It seems like only certain colour hex codes are valid. Setting an invalid one returns the bulb to base colour (neutral yellow, which is known as 'Everyday').
Shades of white;
Valid colours;
And there's no option to fade from one colour to the next, nor a colour cycle option. I can script changing colour values, but the valid ones are so distinct that the change is too jarring. The investigation continues.
You can send a discovery request, and get back all the valid end-points, without getting a psk;
coap-client -m get -u "Client_identity" -k "your_security_code" "coaps://192.168.0.20/.well-known/core"
But for most things you need that psk. Send the request;
coap-client -m post -u "Client_identity" -k "your_security_code" -e '{"9090":"your_device_id"}' "coaps://192.168.0.20:5684/15011/9063"
And it will reply with your psk, like;
{"9091":"abc1D2eFghiJKLMn","9029":"1.3.0014"}
Now if you want to query the list of devices;
coap-client -m get -u "your_device_id" -k "your_psk" "coaps://192.168.0.20:5684/15001"
To query the state of a device/bulb;
coap-client -m get -u "your_device_id" -k "your_psk" "coaps://192.168.0.20:5684/15001/65540"
There are more settings in "3311" now.
"5850" controls on/off and takes 0 or 1.
"5851" controls brightness, and takes values between 0 and 255.
"5709" and "5710" seem to work together to control the colour temperature.
"5706" is clearly a colour hex code.
"9003" is a mystery.
"5717" and "5711" are specific to the white bulbs.
"5707" and "5708" are specific to the white/colour bulbs.
Yes, I picked up a colour bulb. You can set a colour like;
coap-client -m put -u "your_device_id" -k "your_psk" -e '{ "3311" : [{ "5706":"d6e44b" }] }' "coaps://192.168.0.20:5684/15001/65540"
I indexed the colour options; there are 9 reachable from the remote, and 20 from the app colour picker (11 in addition to the remotes 9). But. It seems like only certain colour hex codes are valid. Setting an invalid one returns the bulb to base colour (neutral yellow, which is known as 'Everyday').
Shades of white;
"5707":2681, "5708":4360, "5709":21109, "5710":21738, "5706":"dcf0f8" "5707":5989, "5708":12964, "5709":22584, "5710":23272, "5706":"eaf6fb" "5707":5800, "5708":24394, "5709":25022, "5710":24884, "5706":"f5faf6" "5707":5129, "5708":40781, "5709":29713, "5710":26431, "5706":"f2eccf" "5707":5427, "5708":42596, "5709":30015, "5710":26870, "5706":"f1e0b5"
Valid colours;
"5707":5309, "5708":52400, "5709":32886, "5710":27217, "5706":"efd275" "5707":4980, "5708":62974, "5709":35848, "5710":26214, "5706":"ebb63e" "5707":4137, "5708":65279, "5709":38011, "5710":24904, "5706":"e78834" "5707":1662, "5708":53420, "5709":38011, "5710":22938, "5706":"e57345" "5707":1490, "5708":61206, "5709":40632, "5710":22282, "5706":"da5d41" "5707":0, "5708":65279, "5709":42926, "5710":21299, "5706":"dc4b31" "5707":62148, "5708":49198, "5709":32768, "5710":18350, "5706":"e491af" "5707":62007, "5708":41158, "5709":29491, "5710":18350, "5706":"e8bedd" "5707":59789, "5708":65279, "5709":32768, "5710":15729, "5706":"d9337c" "5707":55784, "5708":44554, "5709":22282, "5710":12452, "5706":"c984bb" "5707":53953, "5708":65279, "5709":20316, "5710":8520, "5706":"8f2686" "5707":47822, "5708":65279, "5709":11469, "5710":3277, "5706":"4a418a" "5707":47324, "5708":51774, "5709":13107, "5710":6554, "5706":"6c83ba" "5707":11383, "5708":65279, "5709":26870, "5710":33423, "5706":"a9d62b" "5707":8572, "5708":55985, "5709":29491, "5710":30802, "5706":"d6e44b"
And there's no option to fade from one colour to the next, nor a colour cycle option. I can script changing colour values, but the valid ones are so distinct that the change is too jarring. The investigation continues.