Skip to content

COAP endpoints on IKEA Trådfri

So, I’m talking to the Trådfri GW. It turns out that my initial research was correct. It is talking coaps. I used californium.tools/ to talk to it, requesting coaps://10.0.3.25/.well-known/core. It actually seems to implement the standard rather well 🙂 I had to use -psk and enter the security key, printed on a label under the gw itself.
UPDATE: Leave PSK identity blank.

==[ CoAP Response ]============================================
MID : 115
Token : 170a801bb0362002
Type : ACK
Status : 2.05
Options: {"Content-Format":"application/link-format"}
Payload: 560 Bytes
---------------------------------------------------------------
<//15001/65536>;ct=0;obs,<//15001/65538>;ct=0;obs,<//15001/65537>;ct=0;obs,<//15004/139121>;ct=0;obs,<//15005/139121>;ct=0;obs,<//15005/139121/203361>;ct=0;obs,<//15005/139121/221937>;ct=0;obs,<//15005/139121/217246>;ct=0;obs,<//15005/139121/202872>;ct=0;obs,<//15001>;ct=0;obs,<//15001/reset>;ct=0,<//status>;ct=0;obs,<//15005>;ct=0;obs,<//15004>;ct=0;obs,<//15004/add>;ct=0,<//15004/remove>;ct=0,<//15006>;ct=0;obs,<//15011/15012>;ct=0;obs,<//15011/9034>;ct=0,<//15011/9030>;ct=0,<//15011/9031>;ct=0,<//15011/9063>;ct=0,<//15011/9033>;ct=0,<//15010>;ct=0;obs
===============================================================
Time elapsed (ms): 1251

Querying each of the endpoints yielded the following:

/15001/65536


{"9054":0,"9001":"Remote","5750":0,"9002":1490983329,"9020":1490985746,"9003":65536,"15009":[{"9003":0}],"9019":0,"3":{"1":"TRADFRI remote control","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":3,"9":100}}

This is obviously the remote control unit.

/15001/65538

{"9054":0,"9001":"K","5750":2,"9002":1490992930,"9020":1491052948,"9003":65538,"9019":0,"3":{"1":"TRADFRI bulb E27 WS opal 980lm","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":1},"3311":[{"9003":0}]}

This is one of the bulbs. I believe it is the one named “K” in the IKEA app… 🙂

/15001/65537

{"9054":0,"9001":"LR","5750":2,"9002":1490983446,"9020":1491055861,"9003":65537,"9019":1,"3":{"1":"TRADFRI bulb E27 WS opal 980lm","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":1},"3311":[{"5850":1,"5851":254,"5707":0,"5708":0,"5709":33135,"5710":27211,"9003":0,"5711":0,"5706":"efd275"}]}

Another of the bulbs – I currently have two. This is obviously the one in the living room – LR. This is powered on, whilst the other one has main power removed. The powered on one (this) returns more data than the one that is powered down.

/15004/139121


{"9001":"TRADFRI group","9039":203361,"9002":1490983341,"9003":139121,"5850":0,"5851":0,"9018":{"15002":{"9003":[65536,65537,65538]}}}

I have defined one group, containing both bulbs. The 9003 array contains the devices in this group (remote control and two bulbs).

/15011/15012

This is information about ntp server.

{"9023":"pool.ntp.org","9059":1491062713,"9060":"2017-04-01T16:05:13.055176Z","9062":0,"9061":0,"9066":0,"9029":"1.0.0004","9054":0,"9055":0,"9069":0,"9071":1}

You can change to your own ntp-server by issuing a set request, with pool.ntp.org replaced by your own. Quite neat actually.

/139121/221937


{"9001":"RELAX","9002":1490983341,"9003":221937,"9057":1,"9068":1,"15013":[{"5850":1,"5851":25,"5707":0,"5708":0,"5709":33135,"5710":27211,"9003":65537,"5711":0,"5706":"efd275"},{"9003":65538}]}

This is one of the presets for mood lightning in the app. Reddish with low intensity.

Oookay, that’s enough about the endpoints. The rest is mostly a continuation. Let’s go back to the kitchen light, which I’ve now powered on, put to max level and bright white (highest color temperature). As expected it now replies with more data:

{"9054":0,"9001":"K","5750":2,"9002":1490992930,"9020":1491052948,"9003":65538,"9019":1,"3":{"1":"TRADFRI bulb E27 WS opal 980lm","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":1},"3311":[{"5850":1,"5851":254,"5707":0,"5708":0,"5709":24930,"5710":24694,"9003":0,"5711":250,"5706":"f5faf6"}]}

Dimmed to minimum:

{"9054":0,"9001":"K","5750":2,"9002":1490992930,"9020":1491052948,"9003":65538,"9019":1,"3":{"1":"TRADFRI bulb E27 WS opal 980lm","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":1},"3311":[{"5850":1,"5851":12,"5707":0,"5708":0,"5709":24930,"5710":24694,"9003":0,"5711":250,"5706":"f5faf6"}]}

Here, the parameter 5851 changed from 254 to 12. This is likely to be the light level output. Let’s try again, with the bulb set to 50%:

{"5850":1,"5851":127,"5707":0,"5708":0,"5709":24930,"5710":24694,"9003":0,"5711":250,"5706":"f5faf6"}

Yep, 5851 is the dimming level.

And now, repeat with different colour temperature (middle setting from app):

{"5850":1,"5851":127,"5707":0,"5708":0,"5709":30140,"5710":26909,"9003":0,"5711":0,"5706":"f1e0b5"}

The intensity is still 127, but three other parameters, 5709-5711. In addition 5706 changed – which it did not for the previous changes. Let’s try a put, changing the 127 to 254:

java -jar cf-client-1.1.0-APSHOT.jar -psk PUT coaps://10.0.3.25//15001/65538 '{"9054":0,"9001":"K","5750":2,"9002":1490992930,"9020":1491052948,"9003":65538,"9019":1,"3":{"1":"TRADFRI bulb E27 WS opal 980lm","0":"IKEA of Sweden","2":"","3":"1.1.1.1-5.7.2.0","6":1},"3311":[{"5850":1,"5851":254,"5707":0,"5708":0,"5709":30140,"5710":26909,"9003":0,"5711":0,"5706":"f1e0b5"}]}'
[...]
==[ CoAP Response ]============================================
MID : 190
Token : 4bde3ee89d815913
Type : ACK
Status : 2.04
Options: {}
Payload: 0 Bytes
===============================================================
Time elapsed (ms): 1487

Yup, promptly dimmed up. Sending only the 3311 did nothing – it appears I have to send the entire thing back to the bulb for some reason.

That’s it for now. Some pointers on how to talk to the lights.

Update: There’s some discussion at ha-bridge’s github about this topic. Also note the first comment – I didn’t include this information, but yes – the PSK identity should be left blank, and the key is the one printed on the label of the gw.

[Digg] [Reddit] [Google] [StumbleUpon]

{ 17 } Comments