[REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Python and python framework

Moderator: leecollings

Post Reply
Hedda
Posts: 49
Joined: Wednesday 06 July 2016 13:16
Target OS: Linux
Domoticz version:
Contact:

[REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by Hedda »

Ikea have just recently released an inexpensive app-controlled network-attached home automation hub which will serve as a Gateway to control its new "Trådfri" (Tradfri) series of affordable smart lights / lightbulbs, switches / remotes, and sensors, (endpoint devices/sensors in turn so far all uses ZigBee based protocols). These products was released on the 31st of March 2017 in selected countries around the world.

https://www.cnet.com/news/ikeas-rolling ... me-lineup/
http://www.ikea.com/gb/en/products/ligh ... -lighting/
http://www.ikea.com/us/en/catalog/categ ... ing/36812/

Anyway, some clever developers have already figued out how to comminicate with the gateway using encrypted CoAP (Constrained Application Protocol) with LwM2M IPSO provide common object model and have since developed this open source Python library to make implementations easier. Hopefully some interested Domoticz developers will be able to use this to create a Python plugin for Domoticz:

https://github.com/ggravlingen/pytradfri


PS: By the way, "Trådfri" means 'wireless' in Swedish, and Ikea have so far announced this very aggresivly low-priced network-attached (Ethernet) "Ikea Trådfri Gateway" home automation hub in their "Tradfri" series, as well as a wireless Motion Sensor Kit (that have integrated light sensor too), a wireless Dimmer Remote (which is accelerator-based), a wireless multi-switch remote, and several smart light bulbs of different formats and even a few unique panel lights. All these products will then be released in most other contries worldwide too as Ikea steps up manufacturing (and irons our the initial software bugs I guess).

http://www.ikea.com/ms/en_US/img/buying ... APRIL1.pdf

Also interesting is thaty it just so happens that the current firmware of Ikea Trådfri Gateway is also compatible with Philips Hue lightbulbs (which are also ZigBee based), and while not confirmed the Ikea Trådfri Gateway might also be compatible with other ZigBee Alliance certified products (such as example Samsung SmartThings, OSRAM Lightify, and Iris by Lowe's, and perhaps even non-certified ZigBee devices as those from Xiaomi), so this Ikea Trådfri Gateway has the potential of becoming a cheap ZigBee gateway/hub for some very cheap sensors and devices.

Ikea had already leaked news about this upcoming gateway/hub more than 6-months ago, during the summer or 2016, and at that time they also revealved that they will use ZigBee and keep validated access to the gateway/hub as open as possible, and aim to be compatible with other ZigBee Alliance certified products, as well as in the future officially provide an open API and/or SDK for the Ikea Trådfri Gatewat network-attached home automation hub.

Reason why I think that this being interested to many people is Ikea's aggresive pricing might them the first to make two-way communication home automation really affordable for almost everyone while still following all the electrical safety and wireless communications regulations in all countries, as they are today well known to have very low prices yet good manufacturing quality items.

Much more detailed development information regarding is available here:

https://github.com/bwssytems/ha-bridge/issues/570

PS: There is already a generic thread about Ikea "TRÅDFRI" smart lights series here but it discusses all general aspects and not specifically a Python script for the Gateway:

https://www.domoticz.com/forum/viewtopi ... 56&t=13882
visser
Posts: 5
Joined: Sunday 13 November 2016 10:11
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Brisbane, Australia
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by visser »

Very cool, I'll be following this as the product range is released in Australia (A/NZ)
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

I'm currently working on creating a plugin for IKEA Tradfri.

At the moment it's very basic, but supports controlling dimmable lights from Domoticz. It's not quite ready for testing yet, I'll post the link here when it's a little less rough...

M
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

I have uploaded the first alpha-version of the Ikea Tradfri-gateway Plulgin to github, at https://github.com/moroen/IKEA-Tradfri-plugin

It's quite basic, but allows controlling ON/OFF/LEVEL from Domoticz. Lights must be added to the gateway as per IKEA's instructions, using the official app.

Comments and suggestions are more than welcome!

M
guus_b
Posts: 8
Joined: Sunday 26 January 2014 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by guus_b »

Hi Moroen,

I own a Tradfri hub, a remote and three E27 WS opal 980lm bulbs, so I thought I'd give your plugin a try.
The Tradfri stuff is running fine on its own.
I am using an RPi B+ with Jessie and Domoticz 3.7431 beta.

I followed your instructions. After restarting Domoticz the IKEA Tradfri entry is showing up in de hardware section of Domoticz. IP and key can be inserted and saved. But the bulbs are not showing up in the devices section. The log is showing some errors:

Code: Select all

2017-05-07 20:54:48.968 Error: (IKEA-Tradfri) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/IKEA-tradfri/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-05-07 20:54:48.968 Error: (Tradfri) Module Import failed, exception: 'ImportError'
2017-05-07 20:54:48.969 Error: (Tradfri) Module Import failed: ' Name: pytradfri'
Did I make a mistake somewhere?
ivarka
Posts: 11
Joined: Sunday 17 April 2016 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by ivarka »

Thanks! Works for me!
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

@guus_b,

You need to copy ggravilgen's pytradfri-library into the same directory as the plugin, just the pytradfri directory downloaded from github, so you get the following dir-structure:

Code: Select all

xxx@yyy:/opt/domoticz/plugins/IKEA-Tradfri$ ls
plugin.py  __pycache__  pytradfri  README.md  tradfri.py
The plugin will give an error when shutting down domoticz, due to unfinished threads. I've thought about a few possible ways to solve this, but haven't yet decided which way to go. I'm also thinking about implementing some kind of client (aka. domoticz-plugin)/server (=actually controlling the gateway) in order to support device-state-change notifications into domoticz, due to the no-asynchronous nature of the plugins-system.

M
guus_b
Posts: 8
Joined: Sunday 26 January 2014 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by guus_b »

Hi Moroen,

Thanks for the reply. I guess I misread point 4 of your installation instruction. I did ../domoticz/plugins/pytradfri instead of ../domoticz/plugins/IKEA-tradfri/pytradfri. I moved pytradfri to the correct location and restarted Domoticz resulting in a new error message in the log.

Code: Select all

2017-05-08 08:26:41.404 PluginSystem: Entering work loop.
2017-05-08 08:26:41.848 (Tradfri) Initialized version 1.0.0, author 'moroen'
2017-05-08 08:26:41.860 (Tradfri) onStart called
2017-05-08 08:26:41.861 (Tradfri) xxx.xxx.xxx.xxx
2017-05-08 08:26:41.861 (Tradfri) xxxxxxxxxxxxxxxx
2017-05-08 08:26:41.861 Error: (Tradfri) 'onStart' failed 'AttributeError':''module' object has no attribute 'coap_cli''.
2017-05-08 08:26:41.861 Error: (Tradfri) ----> Line 142 in /home/pi/domoticz/plugins/IKEA-tradfri/plugin.py, function onStart
2017-05-08 08:26:41.861 Error: (Tradfri) ----> Line 39 in /home/pi/domoticz/plugins/IKEA-tradfri/plugin.py, function onStart
2017-05-08 08:26:51.390 (Tradfri) onHeartbeat called
2017-05-08 08:27:01.368 (Tradfri) onHeartbeat called
2017-05-08 08:27:11.400 (Tradfri) onHeartbeat called
2017-05-08 08:27:21.389 (Tradfri) onHeartbeat called
2017-05-08 08:27:31.371 (Tradfri) onHeartbeat called
2017-05-08 08:27:41.409 (Tradfri) onHeartbeat called
2017-05-08 08:27:51.387 (Tradfri) onHeartbeat called
2017-05-08 08:28:01.417 (Tradfri) onHeartbeat called
Any ideas?
guus_b
Posts: 8
Joined: Sunday 26 January 2014 15:07
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by guus_b »

I found it. My mistake, again :roll:

Only the subdirectory pytradfri inside the directory pytradfri on git by ggravlingen needs to be in ../domoticz/plugins/IKEA-tradfri/
It's working now.

Thanks for the support.
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?@

Post by moroen »

@guus_b,

Thank you for the feedback, I'll update the instructions to make that distinction a bit clearer!

M
User avatar
l0gic
Posts: 107
Joined: Tuesday 08 October 2013 9:35
Target OS: Linux
Domoticz version: Latest
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by l0gic »

Hi Moroen,
thought I'd grab some Ikea lamps and give your plugin a go.

I'm hitting an issue that I hope you can shine some light on.

Installed libcoap (to /opt/ikea/libcoap/ if it matters)
Added pytradfri and your scripts to /home/domoticz/plugins/IKEA-Tradfri/ (Running Debian Jessie on a non Pi box) /home/domoticz/ is the location of the domoticz install.
a Quick ls gives

Code: Select all

kevin@NVR:/home/domoticz/plugins/IKEA-Tradfri$ ls
plugin.py  __pycache__  pytradfri  tradfri.py
On running python3 -i -m pytradfri IP KEY I get

Code: Select all

kevin@NVR:/home/domoticz/plugins/IKEA-Tradfri$ python3 -i -m pytradfri 192.168.1.79 xx-key stuff-xx
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['status']
DEBUG:pytradfri.coap_cli:Received: {}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001']
DEBUG:pytradfri.coap_cli:Received: [65537,65538,65536,65539,65540]
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001', 65537]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Bedside 2","5750":2,"9020":1494490780,"9002":1494345426,"9003":65537,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E14 WS opal 400lm","2":"","3":"1.1.1.1-5.7.2.0","6":1},"9054":0,"9019":1,"3311":[{"9003":0,"5850":0,"5851":25,"5707":0,"5710":27211,"5709":33135,"5708":0,"5711":0,"5706":"efd275"}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001', 65538]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Bedside 1","5750":2,"9020":1494490695,"9002":1494345240,"9003":65538,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E14 WS opal 400lm","2":"","3":"1.1.1.1-5.7.2.0","6":1},"9054":0,"9019":1,"3311":[{"9003":0,"5850":0,"5851":25,"5707":0,"5710":27211,"5709":33135,"5708":0,"5711":0,"5706":"efd275"}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001', 65536]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Bedroom Remote","5750":0,"9020":1494490786,"9002":1494344895,"9003":65536,"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","3":"1.1.1.1-5.7.2.0","6":3,"9":87},"9054":0,"9019":1,"15009":[{"9003":0}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001', 65539]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Toilet Sensor","5750":4,"9020":1494489064,"9002":1494346818,"3300":[{"9003":0}],"9003":65539,"3":{"0":"IKEA of Sweden","1":"TRADFRI motion sensor","2":"","3":"1.1.1.1-5.7.2.0","6":3,"9":100},"9054":0,"9019":1}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15001', 65540]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Toilet bulb","5750":2,"9020":1494492044,"9002":1494346930,"9003":65540,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 opal 1000lm","2":"","3":"1.1.1.0-5.7.2.0","6":1},"9054":0,"9019":1,"3311":[{"9003":0,"5850":0,"5851":254}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15004']
DEBUG:pytradfri.coap_cli:Received: [140645,162824]
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15004', 140645]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Bedside Lamps","9002":1494344907,"5850":1,"9003":140645,"5851":0,"9039":204455,"9018":{"15002":{"9003":[65536,65538,65537]}}}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15004', 162824]
DEBUG:pytradfri.coap_cli:Received: {"9001":"Toilet","9002":1494346829,"5850":1,"9003":162824,"5851":0,"9039":196628,"9018":{"15002":{"9003":[65539,65540]}}}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15005']
DEBUG:pytradfri.coap_cli:Received: [140645,162824]
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15005', 140645]
DEBUG:pytradfri.coap_cli:Received: [204293,204455,210019]
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15005', 140645, 204293]
DEBUG:pytradfri.coap_cli:Received: {"9001":"EVERYDAY","9002":1494344907,"9003":204293,"9057":0,"9068":1,"15013":[{"9003":65538,"5850":1,"5851":203,"5707":0,"5710":26909,"5709":30140,"5708":0,"5711":0,"5706":"f1e0b5"},{"9003":65537,"5850":1,"5851":203,"5707":0,"5710":26909,"5709":30140,"5708":0,"5711":0,"5706":"f1e0b5"}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15005', 140645, 204455]
DEBUG:pytradfri.coap_cli:Received: {"9001":"RELAX","9002":1494344907,"9003":204455,"9057":1,"9068":1,"15013":[{"9003":65538,"5850":1,"5851":25,"5707":0,"5710":27211,"5709":33135,"5708":0,"5711":0,"5706":"efd275"},{"9003":65537,"5850":1,"5851":25,"5707":0,"5710":27211,"5709":33135,"5708":0,"5711":0,"5706":"efd275"}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15005', 140645, 210019]
DEBUG:pytradfri.coap_cli:Received: {"9001":"FOCUS","9002":1494344907,"9003":210019,"9057":2,"9068":1,"15013":[{"9003":65538,"5850":1,"5851":254,"5707":0,"5710":24694,"5709":24930,"5708":0,"5711":0,"5706":"f5faf6"},{"9003":65537,"5850":1,"5851":254,"5707":0,"5710":24694,"5709":24930,"5708":0,"5711":0,"5706":"f5faf6"}]}
DEBUG:pytradfri.coap_cli:Executing 192.168.1.79 get ['15010']
DEBUG:pytradfri.coap_cli:Received: []

Example commands:
> devices
> light.light_control.lights
> light.light_control.set_dimmer(10)
> light.light_control.set_dimmer(254)
> light.light_control.set_xy_color(254)
> lights[1].light_control.set_dimmer(20)
> tasks[0].repeat_days_list
> groups
> moods
> tasks
> dump_devices()
> dump_all()
So I'm guessing all is well for the pytradfri part.

I rebooted and found the Ikea hardware add in, configured it with IP & key. Same as used in the pytradfi example above.
However I hit errors in the log as shown below;

Code: Select all

2017-05-11 10:49:45.210 (Ikea System) Initialized version 1.0.0, author 'moroen'
2017-05-11 10:49:45.210 (Ikea System) onStart called
2017-05-11 10:49:45.210 (Ikea System) 192.168.1.79
2017-05-11 10:49:45.210 (Ikea System) xx-key stuff-xx
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':''DeviceID' is an invalid keyword argument for this function'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':'argument 8 must be str, not dict'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':''DeviceID' is an invalid keyword argument for this function'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':'argument 8 must be str, not dict'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':''DeviceID' is an invalid keyword argument for this function'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
2017-05-11 10:49:45.241 Error: Expected: myVar = Domoticz.Device(Name="myDevice", Unit=0, TypeName="", Type=0, Subtype=0, Switchtype=0, Image=0, Options="")
2017-05-11 10:49:45.241 Error: (Ikea System) 'CDevice_init' failed 'TypeError':'argument 8 must be str, not dict'.
2017-05-11 10:49:45.241 Error: Device creation failed, Device object is not associated with a plugin.
Any ideas at all?

TIA

Kevin
Non credus crepitus
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

@lOgic,

I'll take a closer look when I get home from work, but in the meantime:

Which version of domoticz beta with plugins-support are you using?
And I guess you're using the latest commit of pytradfri?

Does the tradfri.py script work from the command line? For ex: ./pytradfri.py --key XXXX --Gateway xxx.xxx.xxx.xxx list ?

M
User avatar
l0gic
Posts: 107
Joined: Tuesday 08 October 2013 9:35
Target OS: Linux
Domoticz version: Latest
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by l0gic »

Hi Moroen,
all sorted, your mention of beta was all it needed.
Wasn't aware I had to be on a beta build for it to work.

Changed to beta channel, updated and all sorted!

Sorry to have troubled you.
It's looking good, thanks for the plugin - much appreciated.
Off to add the items to my lua scripts now, one happy chappy.

All the best

Kevin
Non credus crepitus
User avatar
l0gic
Posts: 107
Joined: Tuesday 08 October 2013 9:35
Target OS: Linux
Domoticz version: Latest
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by l0gic »

Hi,
been playing with it and notice that the actual status is not reflected in Domoticz.
i.e. turn on via Domoticz but turn off via Tradfri control, Domoticz still thinks it is on.
Is this usual behaviour?

Don't mean to be picky, just asking. :)

Kevin
Non credus crepitus
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

@lOgic,

glad it worked out for you.

At the moment the plugin doesn't support notifications, it's next on the to-do-list. I have a prototype, but it doesn't play nice with the plugin-system, so I need to think about it some more...

M
User avatar
l0gic
Posts: 107
Joined: Tuesday 08 October 2013 9:35
Target OS: Linux
Domoticz version: Latest
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by l0gic »

@moroen
No problem.
Happy to assist with testing if required.
Currently have a few bulbs, motion detector and control disc.

All the best

Kevin
Non credus crepitus
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

@lOgic,

Developement has stalled a bit while waiting on the new changes being implemented in the framework. As soon as the latest changes are pushed to the beta-branch, I'll continue with the plugin.

Thanks for offering to do testing, I'll contact you when I have something ready for test! :)

M
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

After a lot of delays, I have committed a new version of the IKEA-tradfri plugin to the git repository. This version support the latest changes to the plugin-system, and thus requires the latest beta-version of domoticz. The plugin uses a separate service to enable notification of state changes and to keep within the constrains of plugins not to use threads or async calls. This service is also written in python, using twisted and is intended to be run from systemd.

The plugin is still quite rough, and I'm not good at writing instructions, so a certain amount of trouble should be expected, any feedback, suggestions, code changes etc. are most welcome!

Regards,
M
Hedda
Posts: 49
Joined: Wednesday 06 July 2016 13:16
Target OS: Linux
Domoticz version:
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by Hedda »

moroen wrote:After a lot of delays, I have committed a new version of the IKEA-tradfri plugin to the git repository. This version support the latest changes to the plugin-system, and thus requires the latest beta-version of domoticz. The plugin uses a separate service to enable notification of state changes and to keep within the constrains of plugins not to use threads or async calls. This service is also written in python, using twisted and is intended to be run from systemd.

The plugin is still quite rough, and I'm not good at writing instructions, so a certain amount of trouble should be expected, any feedback, suggestions, code changes etc. are most welcome!
Did you checkout the new aiocoap implementation option that they added to pytradfri?

Aiocoap experimentation => https://github.com/ggravlingen/pytradfri/pull/28

Also relatest to https://github.com/ggravlingen/pytradfri/issues/29 but not required?

Could you get around not using Twisted with that new aiocoap implementation option?

Cool regardless! 8-)
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen »

Hedda wrote: Did you checkout the new aiocoap implementation option that they added to pytradfri?

Aiocoap experimentation => https://github.com/ggravlingen/pytradfri/pull/28

Also relatest to https://github.com/ggravlingen/pytradfri/issues/29 but not required?

Could you get around not using Twisted with that new aiocoap implementation option?

Cool regardless! 8-)
Yes, I've checked it out, and considered making the COAP-adaptor using the aiocoap, but decided to stick with the plain pytradfri-module for now, since there are quite a lot of hoops to jump through to get aiocoap working at the moment.

As to get rid of the need for the adaptor, Dnpwwo has clearly stated that plugins doesn't support spinning off threads or using asynchronous calls. The adaptor takes care of the asynchronous communication with the gateway, which is needed to support notifications of state-changes.

I think it's possible to create a module that controls lights without depending on a external service, but not one that allows for observing state changes (which I think will be even more important down the way, in order to support the motion sensor etc). Until (if ever) plugins support coap+dtls as a native protocol, I fail to see how to support the plugin-system's methods for communication (onConnect, onMessage etc) without some kind of external service that asynchronously observe states and then sends the message about changes to the plugin. I might be completely wrong on that account, naturally... :lol:

Regards,
M
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest