Page 7 of 48

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

Posted: Tuesday 17 October 2017 19:30
by moroen
mrblond18 wrote: Tuesday 10 October 2017 9:37 So it looks like if there is only one group it does not advertise it as a group.

Moroen can you have a look at "Unable to iterate groups" error and the "Error in annouce: 160628"?
Sorry for the late reply, the latest commit should address this, but an ongoing problem is maintaining a stable connection, as soon as a request times out, the plugin/adapter goes haywire... Working on a solution, but I fear that until the switch to aiocoap is done, this will continue to be a problem...

Regards,
M

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

Posted: Wednesday 18 October 2017 6:28
by Dnpwwo
@moroen,

I would recommend against the 'switch to aiocoap' because the Python Framework does not support asynchronous operations and libraries.

The framework is single threaded, does not enable Python threads in the interpreter, nor it does not use the Python Global Inter Lock. The code within Domoticz is thread safe only where it interacts with the Python garbage collector.

This is documented on the wiki page explicitly.

What problem are you trying to solve by using aiocoap?

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

Posted: Wednesday 18 October 2017 12:47
by moroen
Dnpwwo wrote: Wednesday 18 October 2017 6:28 @moroen,

I would recommend against the 'switch to aiocoap' because the Python Framework does not support asynchronous operations and libraries.

The framework is single threaded, does not enable Python threads in the interpreter, nor it does not use the Python Global Inter Lock. The code within Domoticz is thread safe only where it interacts with the Python garbage collector.

This is documented on the wiki page explicitly.

What problem are you trying to solve by using aiocoap?
Thanks for the input! :)

There is no async code in the plugin itself. In order to support COAP, the solution consists of two separate parts. The plugin (plugin.py) communicates with an "adapter" using telnet, so the plugin is single threaded and synchronous, without any external libraries. All the "heavy lifting" is done by onMessage and onCommand.

The adapter then uses COAP to talk to the IKEA-gateway, and send appropriate messages back to the plugin. I'm currently considering using aiocoap for the adapter, in order to mimmize the impact on the gateway when observing changes.

In time I would like to see the the plugin-system support COAPS as a communication protocol, but that's far beyond my expertice! :)

Regards,
M

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

Posted: Friday 20 October 2017 6:11
by Dnpwwo
@moroen,

The framework is designed to allow protocols to be added pretty easily (they are polymorphic so you can just drop a new one in that supports the required interface) without risking existing functionality. I looked up COAP and it looks like it would work well.

There is already a C++ library that does all the hard work: https://github.com/staropram/cantcoap (clearly written by someone with a sense of humour 8-) ) which is handy.

I could look at it next week if you were prepared to test it out, I don't have any COAP devices.

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

Posted: Friday 20 October 2017 9:40
by moroen
Dnpwwo wrote: Friday 20 October 2017 6:11 @moroen,

The framework is designed to allow protocols to be added pretty easily (they are polymorphic so you can just drop a new one in that supports the required interface) without risking existing functionality. I looked up COAP and it looks like it would work well.

There is already a C++ library that does all the hard work: https://github.com/staropram/cantcoap (clearly written by someone with a sense of humour 8-) ) which is handy.

I could look at it next week if you were prepared to test it out, I don't have any COAP devices.
That would be absolutely fantastic! I'm more than willing to test it out!

In order to use it with the IKEA-gateway, it needs to support secured COAP, COAPS. I took a quick glance at the library you linked to, and it appears not to support DTLS. There's a C-coap library that supports DTLS called libcoap: https://libcoap.net/, is this something you can use?
:D

Regards,
M

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

Posted: Saturday 21 October 2017 15:47
by mrblond18
moroen wrote: Tuesday 17 October 2017 19:30
Sorry for the late reply, the latest commit should address this, but an ongoing problem is maintaining a stable connection, as soon as a request times out, the plugin/adapter goes haywire... Working on a solution, but I fear that until the switch to aiocoap is done, this will continue to be a problem...

Regards,
M
I just updated to the latest git commit, all seems fine now (with two groups). Thanks!

Also polling works (after turning a light on with a remote, this also shows up in domoticz). Is it also possible to monitor an input device (e.g. a motion sensor)?

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

Posted: Monday 23 October 2017 12:07
by m0rph13
Did you get your hands on the RGB bulb yet? :)

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

Posted: Monday 23 October 2017 17:21
by moroen
m0rph13 wrote: Monday 23 October 2017 12:07 Did you get your hands on the RGB bulb yet? :)
Still not available on the web-pages, but I'm going to a Ikea-warehouse in Oslo someday this week, so I'll take a look!

Regards,
M

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

Posted: Saturday 28 October 2017 8:43
by toreandre
moroen wrote: Monday 23 October 2017 17:21
m0rph13 wrote: Monday 23 October 2017 12:07 Did you get your hands on the RGB bulb yet? :)
Still not available on the web-pages, but I'm going to a Ikea-warehouse in Oslo someday this week, so I'll take a look!

Regards,
M
RGBW ;)

http://www.ikea.com/no/no/catalog/products/70338951/

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

Posted: Saturday 28 October 2017 13:12
by moroen
toreandre wrote: Saturday 28 October 2017 8:43
RGBW ;)

http://www.ikea.com/no/no/catalog/products/70338951/
Found it on Ikea yesterday and bought a couple. Currently working on adding support. I have found a way to select the predefined colors, not sure if the bulb also supports full spectrum, but experimenting with pytradfri to find out!

Regards,
M

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

Posted: Sunday 29 October 2017 11:12
by m0rph13
moroen wrote: Saturday 28 October 2017 13:12 Found it on Ikea yesterday and bought a couple. Currently working on adding support. I have found a way to select the predefined colors, not sure if the bulb also supports full spectrum, but experimenting with pytradfri to find out!
Excellent news!
You have probably already found the various operations available in pytradri for setting RGB and stuff. Looking forward to see what you come up with :)

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

Posted: Sunday 29 October 2017 23:52
by moroen
m0rph13 wrote: Sunday 29 October 2017 11:12
moroen wrote: Saturday 28 October 2017 13:12 Found it on Ikea yesterday and bought a couple. Currently working on adding support. I have found a way to select the predefined colors, not sure if the bulb also supports full spectrum, but experimenting with pytradfri to find out!
Excellent news!
You have probably already found the various operations available in pytradri for setting RGB and stuff. Looking forward to see what you come up with :)
I'm struggling with making sense of the color-picker, the values returned to the plugin when selecting a color doesn't make sense to me. I would guess HSV, but the HUE-value is always -1? Using RBG it appears that the bulb is somewhat full spectrum, just need to get some kind of usable color-information out of the picker.

For now I can implement support for the "predefined" colors, as they are implemented in the official tradfri app from IKEA, but until I figure out the picker, full color support is out of my reach...

Regards,
M

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

Posted: Tuesday 31 October 2017 20:35
by moroen
Just a small heads up: According to https://github.com/ggravlingen/pytradfri/issues/90, a new firmware version of the Ikea Gateway will render the current implementation of pytradfri, and thus this domoticz plugin unoperative until pytradfri is updated with support for a change in the way the gateway handles DTLS...

Regards,
M

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

Posted: Sunday 05 November 2017 18:04
by moroen
The latest commit to the plugin on github supports the new IDENT/PSK credentials of the latest IKEA gateway firmware, and supports/requires pytradfri version 4.0.2 or greater.

Support for color-bulbs are on it's way, I hope to push a new commit with this feature in the next couple of days!

Regards,
M

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

Posted: Tuesday 07 November 2017 13:07
by moroen
Basic support for color-bulbs implemented. I'v been unable to make sense of the color-picker, so full RGB support is still lacking.

Thinking about implementing some kind of "custom" levels, where it would be possible to specify the desired colors using RGB rather than the predefined ones found in the IKEA Tradfri app.

Regards,
M

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

Posted: Friday 17 November 2017 10:53
by spiri439
Hello,
I have domoticz with tradfri plugin up and running, i set devices as groups, but I cannot use the buttons in domoticz, I want them to use them so I can do things with them through domoticz, will that be possible?

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

Posted: Friday 17 November 2017 15:36
by moroen
spiri439 wrote: Friday 17 November 2017 10:53 Hello,
I have domoticz with tradfri plugin up and running, i set devices as groups, but I cannot use the buttons in domoticz, I want them to use them so I can do things with them through domoticz, will that be possible?
Switching groups on/off should be possible, could you specify some more? Any output in the logs when trying to switch a group?`

Regards,
M

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

Posted: Friday 17 November 2017 17:15
by Yossarian
Hello,

UPDATE : just rechecked how i set up everything and i notice that it is said to Clone IKEA-tradfri plugin into domoticz plugins-directory ~/$ cd /opt/domoticz/plugins/
but my domoticz directory is /home/pi/domoticz. So I had to change every command starting with /opt/... by /pi/...
Guess this mustn't help...



I've set up this plugin following instructions but I'm stuck at this stage :
coap-client -m post -u "Client_identity" -k "GATEWAY-KEY" -e '{"9090":"IDENT"}' "coaps://IP:5684/15011/9063"

I must miss something really obvious but still, I need help :

GATEWAY-KEY = security code from the back of the gateway

IDENT = ??? I read in github "IDENT is the desired identifikation-name" ... so i've tried something like "Ikea"

Client identity = ???

So i've tried the following :
coap-client -m post -u "Client_identity" -k "xxxxxxxxx" -e '{"9090":"ikea"}' "coaps://192.168.1.95:9063" and just get v:1 t:CON c:POST i:6697 {} [ ] nothing more.
I've tried with the three port (5684, 15011 and 9063) same results except one difference :
coap-client -m post -u "Client_identity" -k "xxxxxxxxx" -e '{"9090":"ikea"}' "coaps://192.168.1.95:5684"
v:1 t:CON c:POST i:cb0e {} [ ]
4.05 Method Not Allowed

So can you point me to the right direction
Thanks in advance for help

Regards

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

Posted: Friday 17 November 2017 21:19
by moroen
Yossarian wrote: Friday 17 November 2017 17:15 4.05 Method Not Allowed

So can you point me to the right direction
Thanks in advance for help
That coap-client line should work, I copied it from your post and substituted my own values, and it correctly returns a new PSK.

- Are you sure the gateway is running the latest firmware?
- What's the version of chap-client?

Regards,
M

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

Posted: Friday 17 November 2017 21:19
by moroen
Yossarian wrote: Friday 17 November 2017 17:15 4.05 Method Not Allowed

So can you point me to the right direction
Thanks in advance for help
That coap-client line should work, I copied it from your post and substituted my own values, and it correctly returns a new PSK.

- Are you sure the gateway is running the latest firmware?
- What's the version of coap-client?

Regards,
M