ikea-tradfri-assortiment

Ikea TRÅDFRI for Domoticz

Step-by-step how-to guide install the Ikea Tradfri plugin on a Raspberry Pi, with the latest Raspberry Pi OS image and Domoticz.

Thank you everyone for the feedback!

This how-to is part of a bigger series of Domoticz how-to’s on sancla.com

This tutorial has been updated on March 5h, 2021
However, it’s theoretical and has not been verified in real world…
Based on previous tests with older version,
I assume this should work for you…

Prerequisites Ikea TRÅDFRI plugin

Previously tested with

  • Raspberry Pi 4 (2GB model with 16GB sd-card)
  • Raspberry Pi OS Lite 4.19 (release date 2020-05-27)
  • Domoticz Stable 2020.2 (compile date Apr 27 2020)
  • Ikea tradfri plugin v0.9.2

1. Install packages and requirements

Connect to your running Raspberry Pi with Raspbian with SSH.
Then execute these command (it’s easier to copy-paste them into your SSH session if your SSH client supports this -> PUTTY!):

sudo systemctl stop domoticz.service
sudo apt update -y && sudo apt upgrade -y
sudo apt install golang python3 python3-dev python3-pip -y
cd /home/pi/domoticz/plugins/
rm -rf IKEA-Tradfri/
git clone https://github.com/moroen/IKEA-Tradfri-plugin.git IKEA-Tradfri
cd IKEA-Tradfri
sudo -H pip3 install --upgrade pip
sudo -H pip3 install --upgrade setuptools
sudo -H pip3 install --upgrade py3coap
sudo -H pip3 install --upgrade tradfricoap
sudo systemctl start domoticz.service

2. Configure and test Tradfri COAP:

python3 plugin.py config IP KEY
python3 plugin.py list 
  • IP is the address of the gateway.
    A very easy way to find the IP address of your Ikea Tradfri gateway is to use the “Fing” app on your phone.
    Fing app for Android (LINK)
    Fing app for Apple iPhone (LINK)
    See the image below for an example result on the app.
  • Ikea Tradfri Security Key
    KEY is the security-key located on the bottom of the gateway
    (displayed at the orange bar in the picture below).
    WITHOUT THE “-” DASHES !
  • For example:
    python3 plugin.py config gw 192.168.0.123 gB2pK1YUFi5A2hMN
    or
    python3 plugin.py config gw 10.1.2.14 gB2pK1YUFi5A2hMN
  • For reference, this command was recently changed.
    With the old plugin, you needed to run this command:
    python3 tradfricoap.py config 10.1.2.14 gB2pK1YUFi5A2hMN
    This does not work anymore, please use previous mentioned command:
    python3 plugin.py config gw 10.1.2.14 gB2pK1YUFi5A2hMN

3. Restart Domoticz

sudo systemctl restart domoticz.service

4. Enable IKEA-Tradfri in Domoticz

Go to your Domoticz webinterface and then to hardware, to enable the new Ikea hardware device. Fill in the hardware configuration as follows (the screenshot is for indication and has other values!):

  • Enabled: Enabled
  • Name: IKEA Tradfri
  • Type: IKEA Tradfri Plugin – pycoap version
  • Data Timeout: Disabled
  • Add groups as devices: Yes (screenshot deviates!)
  • Observe changes: Yes
  • Polling interval (seconds): 30 (screenshot deviates!)
  • Transition time (tenth of a second): 10
  • Debug: False
Configure the hardware device in Domoticz
Configure the hardware device in Domoticz

Regarding the polling interval seconds:
To observe changes when switched using another method than domoticz (for an Ikea remote for example), enable “Observe changes” and specify a poll interval in seconds. The plugin uses this value to poll the state from the gateway. Thus it can take this amount of time for Domoticz to update the state of the Domoticz switches when you use the regular Ikea remotes.

The minimum poll interval is 5, and the interval should be a multiple of 5 seconds. Using a too short interval tends to freeze the Ikea gateway, requiring cycling the power of the gateway to restore communication. A polling interval of 30 seconds or greater seems to be fine and reduce the occurrence of freezes. Configuring this value lower could make Domoticz start to ‘hammer’ the Ikea Tradfri gateway asking it for the latest states…

If you use Domoticz to change the states of the Ikea devices, and not for example with the Ikea remotes, you can also consider to switch this off (set Observe changes to “No”).

5. Enable devices

If everything is correctly installed and configured, you should now see a list of Ikea devices:

Example of Ikea devices in Domoticz
Example of Ikea devices in Domoticz

Sources & credits

36 Comments

  1. Hafi
    February 3, 2020

    Mooie plugin werkte op een Raspberry Pi 2B+ met Buster direct op een Raspberry Pi 3B+ is het niet te installeren omdat het een bestand mist.

    • SANCLA
      February 4, 2020

      Dag Hafi,

      Kan je aangeven welk bestand je mist?

      Daarnaast, ik weet dat de developer Moroen de plugin nog volop aan het ontwikkelen is en recent nog bugs is moeten oplossen.

      Wat je eens zou kunnen doen is voor de actuele status het Domoticz forum en zijn Github checken:
      https://www.domoticz.com/forum/viewtopic.php?f=47&t=27678
      https://github.com/moroen/IKEA-Tradfri-plugin/blob/master/README.md
      https://github.com/moroen/IKEA-Tradfri-plugin/

      Mocht ik nog iets voor je kunnen beteken laat maar weten.
      Je kan mij ook altijd bereiken per email (zie contact informatie).

    • v480es
      August 10, 2020

      mooie plugin, ik ga um zeker proberen.
      Allen werk ik met Domoticz op windows 10.
      Heeft iemand daar ervaring mee?
      zou het stappen plan hier ook voor werken?

      • SANCLA
        August 10, 2020

        Dag Hafi,
        Dat kan ik niet met zekerheid op voorhand zeggen nog kan ik dit voor je testen.
        Maar ik verwacht, zeker gezien er voor Python ook voor Windows installaties beschikbaar zijn, je hier met enige voorkennis wel een draai aan kan geven.

  2. Rob Camphorst
    February 27, 2020

    Alle stappen werken prima met alleen een kleine wijzing voor stap 2 2. Configure and test Tradfri COAP:

    python3 tradfricoap.py config IP KEY werkte bij mij met python3 plugin.py config IP KEY
    En idem voor python3 tradfricoap.py list werkt bij mij met python3 plugin.py list

    Mogelijk dat dit in de tussentijd veranderd is? Maar verder helemaal blij met je uitleg 🙂

    Thanks

    Rob

    • SANCLA
      February 28, 2020

      Dag Rob,

      Gelukkig heb je het werkend gekregen en dank je wel voor de feedback. Ik zal op korte termijn deze how-to reviewen, het kan dus inderdaad zo zijn dat door de ontwikkelingen van de IKEA plugin de stappen niet helemaal meer knoppen. Maar met Corona heb ik daar binnenkort misschien wel tijd voor ;-).

  3. Jan
    March 3, 2020

    Mooi stappenplan. Maar hier werkt het niet. Alhoewel ik wel de plugin te zien krijg in Domoticz.
    Ik krijg echter een foutmelding tijdens het stappen plan 2 Configureren en testen.

    Ik krijg bij beide commando’s (python3 tradfricoap.py config IP KEY
    python3 tradfricoap.py list) de volgens foutmelding :

    python3: can’t open file ‘tradfricoap.py’: [Errno 2] No such file or directory

    • Jurgen Boerboom
      June 8, 2020

      Jan,
      Het python script heet geen ‘tradfricoap.py’ zoals vermeld in de documentatie, maar ‘plugin.py’. Het staat in dezelfde directory.
      Ik ben benieuwd of het bij jouw wel werkt want ik krijg zelf continue een ‘connection timeout’ error. (op een PiZero).

  4. Mark Diesel
    March 5, 2020

    Op mijn Domoticz installatie werkte de plugin eerst niet ,
    ‘connection timed out’

    na het installeren van de coapcmd
    – bash /home/pi/domoticz/plugins/IKEA-Tradrfri/install_coapcmd.sh
    en het omzetten van de api
    – python3 plugin.py api coapcmd #use coapcmd

    Testen met:
    python3 plugin.py config IP KEY #geeft status info
    python3 plugin.py list # geeft device info

    In Domoticz heet de plugin nu IKEA Tradfri 0.91 ipv IKEA Tradfru plugin coap-version
    Deze kiezen in Hardware, daarna apparaten toevoegen via Devices/Apparaten

    Hardware:
    Raspberry Pi ZeroW – Buster-

    • Jurgen Boerboom
      June 8, 2020

      Hi Mark,
      Ik heb ook een connection timeout problem bij het uitvoeren van python3 plugin.py config 192.168.1.101 op PiZero met Buster. Het overschakelen naar coapcmd gaat goed maar heeft het probleem echter niet opgelost want ook daar krijg ik een connection timeout error. Met ping krijg ik een response van de gateway…. De plugin is nu versie 0.92.
      Heb jij nog iets anders gedaan om het aan de praat te krijgen ?

      • SANCLA
        June 8, 2020

        Dag Jurgen,

        Er zit een fout in the py3coap. Daarom zullen de navolgende stappen ook niet lekker lopen.
        Als het probleem is gefixt loop ik de hele handleiding nog eens na. De betreffende developer wil nog wel eens wat kleine dingen wijzigen in zijn plugin ;-).

        Voor het py3coap probleem is een issue aangemaakt bij de Github van de developer:
        https://github.com/moroen/IKEA-Tradfri-plugin/issues/104

        • SANCLA
          June 10, 2020

          Hoi Mark,

          Het probleem is opgelost door de developer, probleem zat in het py3coap library na een recent update. Als je de stappen vanaf het onderstaande pycoap commando opnieuw uitvoert zou het goed moeten gaan.
          sudo -H pip3 install -U py3coap

  5. SANCLA
    March 5, 2020

    Thanks Rob Camphorst and Mark Diesel for the feedback!
    The guide has been updated accordingly to reflect the latest changes by the developer…

  6. Rien
    March 31, 2020

    Nice plugin. The first one that really works.

    Do you have adding light color planned for ikea lights that are able to change the white light color?. I use three ikea led panels in the living room and it would be great if its also possible to change the color temperature of them

    • SANCLA
      March 31, 2020

      Hey Rien,

      Thanks for leaving me a message!
      First, the developer of this plugin is moroen, he’s a lot better at coding then me.
      As a trade off I seem to be better at writing tutorials, documentation, etc.

      I personally have the colored light bulb from Ikea (this one) and a few white only bulbs that can change to warm white and dim.
      This works and integrates very well in Domoticz.
      I do not know if the panels are (already) supported with this plugin.

      However, I know that the developer is constantly developing this plugin further and further.
      You can always send his a message on the Domoticz forum or with Github (Github link is at the beginning of this tutorial).

  7. Marke
    May 11, 2020

    Thanks for the walkthrough. Helped a lot setting everything up. Toughest part was finding the IP address of the gateway!

    • SANCLA
      May 11, 2020

      Hi Marke,

      Thank you for the kind feedback!
      I adjusted the tutorial so it includes a better way to find the IP address of the Tradfri gateway.

  8. Rico
    July 7, 2020

    Handleiding 100%. Dank je wel.

  9. MBSupport
    August 3, 2020

    Werkt perfect op een Raspberry Pi 4 8GB.
    Bedankt voor de handleiding!!

  10. G.
    October 22, 2020

    Hallo,
    tot de stap: python3 plugin.py config IP KEY gaat alles goed. als ik deze stap wil uitvoeren krijg ik:
    File “plugin.py”, line 69, in
    CONF = get_config(CONFIGFILE)
    File “/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/config.py”, line 74, in get_config
    global_conf = host_config(configfile)
    File “/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/config.py”, line 29, in __init__
    self.load()
    File “/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/config.py”, line 34, in load
    with open(self._configFile) as json_data_file:
    PermissionError: [Errno 13] Permission denied: ‘/home/pi/domoticz/plugins/IKEA-Tradfri/config.json’
    hier loop ik op vast. iemand een idee om dit te fixen?
    groetjes.

    • SANCLA
      October 22, 2020

      Try this:

      chmod -R 775 /home/pi/Domoticz/plugins/IKEA-Tradfri

  11. Guido
    November 8, 2020

    Beste,

    Nu ben ik een tweede sd kaart aan het maken om tests op te draaien, de vorige keer was het gelukt om de tradfri te koppelen met domoticz, echter krijg ik nu bij python3 plugin.py config een foutmelding: module ‘tradfricoap’ not found alsof hij de module via het netwerk niet kan vinden. Echter heb ik weldegelijk het juiste ip en beveiligingscode ingevoerd. Wat zou hier aan de hand kunnen zijn? ik heb de router herstart.

    Alvast bedankt voor de hulp!

  12. Guido
    November 8, 2020

    Beste,

    ik zie dat de github is geupdate. hierdoor is er een wijziging in de installatie gekomen.
    pip3 install -U tradfricoap moet tegenwoordig ook geinstaleerd worden.
    echter lukt het mij dan om met python3 plugin.py list alle apparaten te zien. helaas verschijnen ze dan nog niet bij de apparaten in domoticz nadat de hardware is aangemaakt.

    pi@raspberrypi:~ $ cd domoticz/plugins/
    pi@raspberrypi:~/domoticz/plugins $ cd IKEA-Tradfri
    pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py list
    Lights:
    65537: lamp groot (State: 1 – Level: 108 – Hex: f1e0b5)
    65542: lamp trap (State: 1 – Level: 112 – Hex: f1e0b5)
    65543: lamp hoek (State: 1 – Level: 108 – Hex: f1e0b5)

    Groups:
    131073: woonkamer

    Others:
    65541: TRADFRI remote control (State: None – Level: None – Hex: None)

    Batteries:
    65541: TRADFRI remote control – 34

    Daar loop ik nu vast helaas. in de log geeft domoticz aan: unable to find tradfricoap. dit heb ik helaas nog niet opgelost en kom ik helaas niet verder.

    Hopelijk heeft u een idee?

  13. Bengt
    January 10, 2021

    Awesome instructions! I got it to work on the first try. What an amazing plugin to Domoticz!

    • SANCLA
      January 20, 2021

      Thanks!

  14. Frank van Seters
    January 19, 2021

    Ik krijg de volgende foutmelding als ik de plugin probeer te configureren:

    pi@Domaticz:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py config 192.168.1.100 **********
    Module ‘tradfricoap’ not found

    Heeft iemand een idee wat hier fout gaat?

    • SANCLA
      January 20, 2021

      Ik heb de handleiding aangepast.
      Je miste de tradfricoap module, deze kan je zo installeren:
      sudo -H pip3 install –upgrade tradfricoap
      Daarna het commando nog eens uitvoeren…

      • Frank van Seters
        January 23, 2021

        Oke, bedankt. Nu gebeurt er al meer. Ik kan nu ook de lampen toevoegen, alleen mijn multicolor lamp reageert niet op domoticz. Ik krijg trouwens bij het toevoegen van de plugin niet “pycoap version” maar “version 0.10.5”. Klopt dat?

        • iamadmin
          February 28, 2021

          Dat kan kloppen, de developer blijft deze plugin door ontwikkelen. Overigens zijn nog niet alle IKEA producten compatibel met deze plugin…

      • Guus
        March 4, 2021

        Beste Sancla,
        Ook ik kreeg deze foutmelding. Het vreemde is echter dat de tadfricoap module wel is geinstalleerd. Ook na het verwijderen en opnieuw installeren blijf ik deze fout krijgen. Enig idee waar het mis gaat? btw ik draai domoticz op de raspberry pi.
        Thanks!
        Guus

  15. Mathias van Veen
    January 23, 2021

    Ik krijg de volgende foutmelding bij de config:

    python3 plugin.py config 10.0.0.136, ******
    usage: plugin.py config [-h] {gw,api} …
    plugin.py config: error: argument config: invalid choice: ‘10.0.0.136,’ (choose from ‘gw’, ‘api’)

    • Bisha
      March 5, 2021

      Hi Mathias, do you solved your problem? I have de same error message

  16. dickey
    February 5, 2021

    Hallo, Ik heb de installatie geheel volgens de handleiding uitgevoerd, maar blijf steeds de timeout error ontvangen. Het interne ip adres en de code zijn beide correct. Enig idee wat ik mis?

  17. iamadmin
    March 5, 2021

    Hey guys, so based on your feedback, I did some researching.
    It seems that the command to connect to Ikea Tradfri has changed (step 2).

    OLD:
    python3 tradfricoap.py config 10.1.2.14 gB2pK1YUFi5A2hMN
    NEW:
    python3 plugin.py config gw 10.1.2.14 gB2pK1YUFi5A2hMN

    Let me know if this helps fixing the errors you are getting…

  18. casper
    December 12, 2021

    Hi,

    I’ve added the plugin to my Domoticz, and added the gateway, but it does not show up in Hardware – any idea where I can look for more information ?

    • iamadmin
      December 24, 2021

      Check the GitHub page, that’s where you can find the latest changes and ask questions

Add a Comment