Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

DarkFoxDK
Posts: 26
Joined: Saturday 02 January 2016 2:22
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by DarkFoxDK »

As a workaround until the official implementation shows up, I've created a lua script to control the bulb level using moroen's script.

Edit: Be sure to restart your gateway after adding your bulbs and before setting this up, as it will reorder them alphabetically at reboot.
Edit 2: Updated to match updated python script. It now uses the device ID, instead of list order.

Steps:
  1. Set up the script following pytradfri and moroen's instructions and confirm it's working.
  2. Copy pytradfri into the root python folder, otherwise it wont import it correctly:

    Code: Select all

    sudo cp -r /usr/local/lib/python3.4/site-packages/pytradfri /usr/lib/python3.4/
  3. Create a new Lua Device script under events and copy the script below into it (correct the python script path if you've placed it somewhere else).
  4. Create virtual selector switches for each of your bulbs.
  5. Go into their settings and change their type to dimmer.*
  6. Insert the switch names and ids into the hash at the top of the script.
* This gets you a dimmer switch that has the full 0-100 steps.

Script:

Code: Select all

local lights = {
  ['Badeværelse'] = {id = 65538},
  ['Depot'] = {id = 65537},
  ['Køkken'] = {id = 65539},
  ['Kontor Spot 1'] = {id = 65540},
  ['Kontor Spot 2'] = {id = 65542},
  ['Kontor Spot 3'] = {id = 65541}
}

function setlight (id, command, val)
    --print("tradfri.py "..id.." "..command.." "..val)
    os.execute("/home/pi/domoticz/scripts/python/tradfri.py "..id.." "..command.." "..val.." &")
end

function mapvalue(inputValue)
    inputValue = tonumber(inputValue)
    normalizedCurVal  =  (inputValue - 1.0) / 99.0
    rangedValue =  (normalizedCurVal * 255.0) + 1.0

    return math.ceil(rangedValue)    
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            setlight(lights[deviceName]["id"], 'off', '')
        elseif (deviceValue == 'On') then
            setlight(lights[deviceName]["id"], 'on', '')
        else
            dvalue = mapvalue(otherdevices_svalues[deviceName])
            setlight(lights[deviceName]["id"], 'level', dvalue)
        end
    end
end

return commandArray
I've also added selector switches for setting the temperature, though that's easy enough as you can just call the script for each level like this:

Code: Select all

script:///home/pi/domoticz/scripts/python/tradfri.py 65538 whitetemp cold
Letalis
Posts: 9
Joined: Monday 28 November 2016 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by Letalis »

Are you "talking" to the Trådfri Gateway via Zigbee controller or another way?
If controller, which one?
I have a RPI3 with RaZberry2 EU gen5 and would like to add IKEA TrådFRI to this.
prijt
Posts: 16
Joined: Thursday 09 March 2017 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by prijt »

In the text: "A general ZigBee gateway would definitely be nice, but in the meantime, it's quite easy to get support for the Ikea Trådløs gateway from domotics, using a python module created by ggravlingen as part of the home-assistant project"
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by deennoo »

prijt wrote:In the text: "A general ZigBee gateway would definitely be nice, but in the meantime, it's quite easy to get support for the Ikea Trådløs gateway from domotics, using a python module created by ggravlingen as part of the home-assistant project"
a general zigbee gateway is on the way , this is call ZiGate : https://www.kickstarter.com/projects/13 ... me?lang=fr

That USB dongle who act as a zwave one, or a RFlink, this send information to serial port, this need a dev on domoticz to be add
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by deennoo »

DarkFoxDK wrote:As a workaround until the official implementation shows up, I've created a lua script to control the bulb level using moroen's script.

Edit: Be sure to restart your gateway after adding your bulbs and before setting this up, as it will reorder them alphabetically at reboot.
Edit 2: Updated to match updated python script. It now uses the device ID, instead of list order.

Steps:
  1. Set up the script following pytradfri and moroen's instructions and confirm it's working.
  2. Copy pytradfri into the root python folder, otherwise it wont import it correctly:

    Code: Select all

    sudo cp -r /usr/local/lib/python3.4/site-packages/pytradfri /usr/lib/python3.4/
  3. Create a new Lua Device script under events and copy the script below into it (correct the python script path if you've placed it somewhere else).
  4. Create virtual selector switches for each of your bulbs.
  5. Go into their settings and change their type to dimmer.*
  6. Insert the switch names and ids into the hash at the top of the script.
* This gets you a dimmer switch that has the full 0-100 steps.

Script:

Code: Select all

local lights = {
  ['Badeværelse'] = {id = 65538},
  ['Depot'] = {id = 65537},
  ['Køkken'] = {id = 65539},
  ['Kontor Spot 1'] = {id = 65540},
  ['Kontor Spot 2'] = {id = 65542},
  ['Kontor Spot 3'] = {id = 65541}
}

function setlight (id, command, val)
    --print("tradfri.py "..id.." "..command.." "..val)
    os.execute("/home/pi/domoticz/scripts/python/tradfri.py "..id.." "..command.." "..val.." &")
end

function mapvalue(inputValue)
    inputValue = tonumber(inputValue)
    normalizedCurVal  =  (inputValue - 1.0) / 99.0
    rangedValue =  (normalizedCurVal * 255.0) + 1.0

    return math.ceil(rangedValue)    
end

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (lights[deviceName]) then
        if (deviceValue == 'Off') then
            setlight(lights[deviceName]["id"], 'off', '')
        elseif (deviceValue == 'On') then
            setlight(lights[deviceName]["id"], 'on', '')
        else
            dvalue = mapvalue(otherdevices_svalues[deviceName])
            setlight(lights[deviceName]["id"], 'level', dvalue)
        end
    end
end

return commandArray
I've also added selector switches for setting the temperature, though that's easy enough as you can just call the script for each level like this:

Code: Select all

script:///home/pi/domoticz/scripts/python/tradfri.py 65538 whitetemp cold
Thanks for your how to, i'm on Moroen's part, i don't see to put Ip and Key, his script refer to a config file, have any idea ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by moroen »

Thanks for your how to, i'm on Moroen's part, i don't see to put Ip and Key, his script refer to a config file, have any idea ?
If you run the script from the command-line, you can specify the IP and key with the --gateway and --key parameters. This is only needed once, after that the key and ip will be read from the ini-file...

Regards,
M
prijt
Posts: 16
Joined: Thursday 09 March 2017 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by prijt »

Just a small hint: change the directories in the script (I also added the full directory to the .ini file), if you do not use the /home/pi directory.

I have 2 questions though:

1. I can add my lights and control them through the mobile app (so the gateway knows their ID numbers), but if I run "$ python3 -i -m pytradfri IP KEY" and then "lights", it lists only one device (4 are missing). Any clue to have that is possible and solved? The one device i can control fine from Domoticz, but I can't add others without their ID numbers.

2. Has anybody "enhanced" the antenna of the Trådfri gateway? It does not really cover my whole house... I have successfully done this for the raZberry etc.
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by deennoo »

moroen wrote:
Thanks for your how to, i'm on Moroen's part, i don't see to put Ip and Key, his script refer to a config file, have any idea ?
If you run the script from the command-line, you can specify the IP and key with the --gateway and --key parameters. This is only needed once, after that the key and ip will be read from the ini-file...

Regards,
M
ok done thank you ! the hardest part is to includ bulb to the gateway ! what a mess !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
prijt
Posts: 16
Joined: Thursday 09 March 2017 22:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Finland
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by prijt »

To answer my own question; this is what I did to enhance the range of the gateway: http://www.domoticz.com/forum/viewtopic ... 38#p138638
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by thorbj »

Hi, I'm trying to set up pytradfri on my Pi.
I've downloaded libcoap using the script provided by ggravlingen, and I've installed python3 using sudo apt-get install python3-pip.

Now, how do I install and use the script? I tried copy the pytradfri folder to domoticz\plugins\IKEA-Tradfri\ as suggested in another post. But when running python3 -i -m pytradfri IP KEY I get an error:

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 151, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/usr/lib/python3.4/runpy.py", line 112, in _get_module_details
    raise ImportError("No module named %s" % mod_name)
ImportError: No module named pytradfri

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 165, in _run_module_as_main
    sys.exit(msg)
SystemExit: /usr/bin/python3: No module named pytradfri
>>>  exit
  File "<stdin>", line 1
    exit
    ^
IndentationError: unexpected indent
>>>
I'm sorry being so noob, but how do I do this?

- Thanks!
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
thorbj
Posts: 113
Joined: Thursday 20 November 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Norway
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by thorbj »

Never mind, I got it.

Just needed to install libcoap, and than create moroens script.
2xRaspberry Pi Model 2 w/RaZberry z-wave chip (master/slave)|Fibaro Wall Plug|Fibaro Universal Dimmer 500W|Aeon Labs Multisensor|RFXtrx433E|Nexa WMR-1000|Nexa Pe-3|Nexa Remote|Nexa LGDR3500|Lightify Gateway|Lightify RGBW bulb
martijnm
Posts: 26
Joined: Thursday 04 February 2016 13:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.530
Location: Emmen, Drenthe
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by martijnm »

Thanks for the great plugin, but I can't get it to work in Domoticz. I've followed the instructions to install moroen's Tradfri plugin.

The ikea-tradfri.service is running in the background as pi (I have also tried running it as root).

I've added the plugin IKEA Tradfri into Domoticz, and entering the gateway IP address and key. Then when going to the Devices list, the list is empty and I get an error message: "Problem retrieving devices!" and my Domoticz setup has been cleared.

Thank heavens a quick reboot resets Domoticz and everything is back in place, but I can't get the IKEA Tradfri plugin to work.

From the cli I can run pytradfri and set values myself, this is working fine.

Screenshot of the error message: tradfri-error.png
mcduarte2000
Posts: 24
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by mcduarte2000 »

Just as an info, in case useful for someone else, I have been using with success this python script:

https://github.com/sandyjmacdonald/ikea-smartlight

Using this tutorial:

https://learn.pimoroni.com/tutorial/san ... om-your-pi

I have four lights in my corridor and created a simple bash script:

Code: Select all

#!/bin/bash
cd /home/pi/domoticz/scripts/python/ikea-smartlight/
python tradfri-groups.py -a power -g 174716 -v $1
python tradfri-groups.py -a brightness -g 174716 -v $2
python tradfri-lights.py -a color -l 65537 -v $3
python tradfri-lights.py -a color -l 65538 -v $3
python tradfri-lights.py -a color -l 65539 -v $3
python tradfri-lights.py -a color -l 65540 -v $3
Which I am calling using a virtual switch (and with some simple timers depending on the hour of the day):

Image

Image
Attachments
Screen Shot 2017-07-30 at 18.56.23.png
Screen Shot 2017-07-30 at 18.56.23.png (27.17 KiB) Viewed 6616 times
Screen Shot 2017-07-30 at 18.56.39.png
Screen Shot 2017-07-30 at 18.56.39.png (111.82 KiB) Viewed 6616 times
vti5
Posts: 2
Joined: Friday 11 August 2017 12:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by vti5 »

For me it is not possible to get it working. I am beginner in linux... :-(
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by deennoo »

Today Ikea made à step :
All bulbs are now compatible with Philips Hue Bridge 2.

Just à bulb firmware update is needed.

Ikea annonce that Ikea bridge will be compatible with Alexa / Home / Siri this automne.

Driving à bulb is great, using pir, remote, switch to drive scène on domoticz is better.
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
vti5
Posts: 2
Joined: Friday 11 August 2017 12:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by vti5 »

I think later they recall this news as a mistake. They plan to implement this later this year. (not 100% sure)
Emtec
Posts: 5
Joined: Sunday 04 June 2017 13:21
Target OS: Linux
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by Emtec »

vti5 wrote:I think later they recall this news as a mistake. They plan to implement this later this year. (not 100% sure)
There is something here but not precise given date for new firmware release.
https://www.wired.com/story/ikea-smart-home/amp


Sent from my iPhone using Tapatalk
MatsL
Posts: 7
Joined: Monday 24 February 2014 19:11
Target OS: Linux
Domoticz version:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by MatsL »

It works to pair the ikea lights and panels with the hue bridge 2 now
Unfortunately it does not work to pair a ikea dimmer or remote with hue bridge
And each light only seem to support one controller, so you cant use a ikea remote and the hue bridge at the same time

To pair the ikea lights with hue they must be on the latest firmware, and they are updated through the ikea tradfri gateway.
Reset the ikea lights by turning them on and off 6 times, the next time you turn the light on it flickers quickly and has lost the connections to the ikea controller, then the ikea light is reset.
It should be searchable through the ordinary hue app after that, but I had to physically move around the hue hub (some it had to be really close) for it to find the ikea lights

Link to Ikea firmware change-log:
https://ww8.ikea.com/ikeahomesmart/rele ... notes.html
mcduarte2000
Posts: 24
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by mcduarte2000 »

MatsL wrote: Tuesday 15 August 2017 23:37 It should be searchable through the ordinary hue app after that, but I had to physically move around the hue hub (some it had to be really close) for it to find the ikea lights
Or take the lights to near the Hue Hub. :) But yes, is the only way. Actually, the IKEA way is more practical, as you can take the controller (which is battery operated) to near the lights.

I've seen reports which say the other way around also works. Adding Hue Ligths to the Trådfri controller.
MatsL
Posts: 7
Joined: Monday 24 February 2014 19:11
Target OS: Linux
Domoticz version:

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting

Post by MatsL »

Another problem with connecting the ikea lights with a hue hub is that they wont get the firmware updates automatically.
So if there is some new feature release that you really need, like pairing a bulb with several controllers
You then have to reset the bulbs, reinclude them to the ikea gateway to update, and the reset/pair them back to the hue hub again.
That would take some hours of work i guess

So good built in domoticz support through the ikea gateway would definatly be the best.
Let´s hope it arrives down the road, perhaps when, (or if? :|) , ikea creates a api for controlling the gateway


Regards /Mats
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest