COAP endpoints on IKEA Trådfri

Written by vidarlo on 20170401 in english and hardware and software with 18 comments.

So, I’m talking to the Trådfri GW. It turns out that my initial research was correct. It is talking coaps. I used to talk to it, requesting coaps:// 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
Time elapsed (ms): 1251

Querying each of the endpoints yielded the following:


{"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":"","6":3,"9":100}}

This is obviously the remote control unit.


{"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":"","6":1},"3311":[{"9003":0}]}

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


{"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":"","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.


{"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).


This is information about ntp server.


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



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":"","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":"","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%:


Yep, 5851 is the dimming level.

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


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:// '{"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":"","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.

18 Responses to “COAP endpoints on IKEA Trådfri

  1. Hi, great work, I was just about to get down to trying to work this out. I’d got as far noticing it was CoAP and DTLS but no further yet ( CoAP is new to me so finding out it’s somewhat self describing is really useful.

    I’m was trying to reproduce this and I was hitting a problem until I tried leaving the PSK identity empty, so just thought I’d leave a note for anybody else who finds this.


  2. Hi, great work, I tried following your steps but I’m not sure how to use the cf-client.

    I tried following command.
    java -jar cf-client-1.0.1.jar -psk DISCOVER coaps://MY.TRADFRI.IP/.well-known/core

    I’m sure the tool should ask for IDENTITY and SECRET but I after a minute I only get “Request timed out”.
    The IP I enter is definitely correct so I’m doing something wrong but what?

  3. It does indeed sound as Ikea if have choosen to base their implementation on OMA (Open Mobile Alliance) and Eclipse recommended standard of those three logical components; LwM2M (Lightweight M2M) protocol stack with CoAP and DTLS layers .

    “Lightweight M2M (LWM2M) is a system standard in the Open Mobile Alliance. It includes DTLS, CoAP, Block, Observe, SenML and Resource Directory and weaves them into a device-server interface along with an Object structure.”

    The Wakaama project (from Eclipse) covers the LWM2M Protocol, CoAP, and DTLS layers of the LwM2M protocol stack for all three logical components. Wakaama is not a library but files to be built with an application. The Eclipse Wakaama project provides a C portable framework for building LWM2M clients and/or servers. The source code of Wakaama is available from the project webpage. It is written in C and designed to be portable on POSIX compliant systems.


    You can also build the “dtls” branch of libcoap from:

    Californium is another CoAP client from Eclipse (programmed in Java) which also supports DTLS

    And the Eclipse Leshan project provides a Java implementation of LwM2M, allowing to build LwM2M servers and clients. The source code of Leshan is available from the project webpage.

  4. Btw – if needed, it is pretty easy to decrypt the traffic from the ikea app to the bridge using wireshark…

    Preferences -> Protocols -> DTLS -> preshared key (This must be entered as hex) also: im using wireshark 2.3.0~rc0


    pautomate from the Home Assistant community put together a very simple implementation for his Raspberry Pi. (“Taking no credit of all the hard work others have put in and just put my code here if you want to play around”):

    First installed the libcoap-library as such:

    apt-get install libtool

    git clone –recursive
    cd libcoap
    git checkout dtls
    git submodule update –init –recursive
    ./configure –disable-documentation –disable-shared
    sudo make install

    pautomate put together a very simple Python-script that execute by running shell_commands:

    You then run the code by invoking:

    python “65537” “100” “Yellow”

    Or, from within Home assistant as a shell command:

    ikealight_off: ‘/usr/bin/python3 /home/homeassistant/.homeassistant/extraconfig/python_code/ “65537” “0” “Yellow”‘

  6. FYI, looks like ha-bridge issue 570 have become a collective point for links and notes about progress around different integrations and implementations

    Some of the new links to code implementations in different programming languages include:

    r41d found an intersting class in the Android App, after decompliling with apktool, it is located in


    Here’s his upload:

  7. Home Assistant developers ( ggravlingen / pautomate, balloob & turbokongen ) looks to be making great progress with their collaberation on a Python class to communicate with the Ikea Trådfri Gateway, and also extracted that code from the platform into a standalone Python library

    More discussion on that in the Home Assistant Community forum

  8. Jaime Jiménez (from the company Ericsson) who is an active member of the IPSO Alliance’s working group, especially the Semantic WG that published the IPSO Smart Object Guidelines, posted this great teardown of the Ikea Trådfri implementation:

    He also shared a couple of links to related articles he posted earlier:

    Also checkout the IoTSI Workshop as a reference:

    Interestingly enough Michael Koster (who is the main author of these IPSO Objects) posted a comment to Jaime’s post staying: “Great move on IKEA’s part here. Too bad we hadn’t published the IPSO lighting objects yet. Maybe we can talk them into registering the new identifiers with OMNA.”.

    He referenses another that good framework written by Michael Koster (the main author of the data models and IPSO Objects that Ikea Trådfri uses):

  9. Any clue what incantation Java is missing when it goes “ certs/trustStore.jks” ? Been ages since I messed with the crypto-stuff in Java.

  10. Thank you very much for your word!

    Today (oh no, it’s after midnight already… So it was yesterday) I found the new Tradfri RGB-Bulb in an IKEA-Store in Heerlen (Netherlands). I got this information:

    {“9001″:”TRADFRI bulb E27 CWS opal 600lm”,”9002″:1503174416,”9020″:1503174416,”9003″:65541,”9054″:0,”5750″:2,”9019″:1,”3″:{“0″:”IKEA of Sweden”,”1″:”TRADFRI bulb E27 CWS opal 600lm”,”2″:””,”3″:”1.3.002″,”6″:1}

    The colours that can be choosen by the remote control are very limited (only 8 different colours available?!?), so I treid to set the colours by command line. And I did it:

    Parameter 5709 defines the colorX-value, Parameter 5710 the colorY-value within the CIE 1931 Color Space, where colorX is given by x * 65536 within the range 0 to 65279 (colorY the same way). Some examples:

    coap-client -m put -u “Client_identity” -k “” -e ‘{ “3311”: [{“5850″:1,”5851″:100,”5708″:0,”5707″:0,”5709″:19055,”5710″:38666,”5711″:0,”9003”:0}] }’ “coaps://”

    coap-client -m put -u “Client_identity” -k “” -e ‘{ “3311”: [{“5850″:1,”5851″:100,”5708″:0,”5707″:0,”5709″:45875,”5710″:18350,”5711″:0,”9003”:0}] }’ “coaps://”

    coap-client -m put -u “Client_identity” -k “” -e ‘{ “3311”: [{“5850″:1,”5851″:100,”5708″:0,”5707″:0,”5709″:36045,”5710″:32768,”5711″:0,”9003”:0}] }’ “coaps://”

    Hope that helps as soon as the RGB-Bulbs are available!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.