Page 3 of 4
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Wednesday 26 April 2017 22:39
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:
- Set up the script following pytradfri and moroen's instructions and confirm it's working.
- 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/
- 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).
- Create virtual selector switches for each of your bulbs.
- Go into their settings and change their type to dimmer.*
- 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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Thursday 08 June 2017 22:33
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.
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Monday 12 June 2017 20:04
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"
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Tuesday 13 June 2017 10:41
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Wednesday 14 June 2017 8:06
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:
- Set up the script following pytradfri and moroen's instructions and confirm it's working.
- 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/
- 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).
- Create virtual selector switches for each of your bulbs.
- Go into their settings and change their type to dimmer.*
- 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 ?
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Wednesday 14 June 2017 8:45
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Wednesday 14 June 2017 10:20
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.
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Wednesday 14 June 2017 12:00
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 !
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Sunday 18 June 2017 13:37
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Saturday 24 June 2017 8:48
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!
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Monday 26 June 2017 12:59
by thorbj
Never mind, I got it.
Just needed to install libcoap, and than create moroens script.
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Saturday 29 July 2017 18:30
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Sunday 30 July 2017 19:59
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):

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Friday 11 August 2017 12:44
by vti5
For me it is not possible to get it working. I am beginner in linux...

Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Friday 11 August 2017 12:48
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.
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Friday 11 August 2017 13:01
by vti5
I think later they recall this news as a mistake. They plan to implement this later this year. (not 100% sure)
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Monday 14 August 2017 21:29
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Tuesday 15 August 2017 23:37
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
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Friday 18 August 2017 1:18
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.
Re: Ikea "TRÅDFRI" Gateway and smart lights series for ZigBee Light Link (ZLL) lighting
Posted: Monday 21 August 2017 16:17
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