Page 3 of 4

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

Posted: Wednesday 06 September 2017 19:16
by moroen
There's a new version of the IKEA-plugin available on the github page: https://github.com/moroen/IKEA-Tradfri-plugin.

The major change is support for groups. Groups defined in Ikea's app now appears to domoticz as regular switches, that supports turning on/off, dimming and observation of state changes.

There are to separate branches. The master branch corresponds to the current master branch/stable of domotics, the development branch is for the development branch of domoticz.

As always, comments, suggestions, fixes etc are most welcome!

Regards,
M

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

Posted: Thursday 07 September 2017 12:56
by guykes1
Since yesterdays update, the groups have now become visible in my domoticz setup :)
Thanks so much for developing this, I'm a happy user!

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

Posted: Sunday 10 September 2017 18:12
by andnyg
andi216 wrote:
Saturday 05 August 2017 19:26
moroen wrote:
There's definitely something wrong with your twisted install, you should be able to import twisted from interactive python... Try forcing an update?

$ pip3 install --upgrade twisted

Regards,
M

pi@pi:~/domoticz/plugins/IKEA-Tradfri $ sudo pip3 install --upgrade twisted
Requirement already up-to-date: twisted in /usr/local/lib/python3.4/dist-packages
Requirement already up-to-date: zope.interface>=4.0.2 in /usr/local/lib/python3.4/dist-packages (from twisted)
Requirement already up-to-date: constantly>=15.1 in /usr/local/lib/python3.4/dist-packages (from twisted)
Requirement already up-to-date: incremental>=16.10.1 in /usr/local/lib/python3.4/dist-packages (from twisted)
Requirement already up-to-date: Automat>=0.3.0 in /usr/local/lib/python3.4/dist-packages (from twisted)
Requirement already up-to-date: hyperlink>=17.1.1 in /usr/local/lib/python3.4/dist-packages (from twisted)
Downloading/unpacking setuptools from https://pypi.python.org/packages/f6/d0/ ... 627bbe57da (from zope.interface>=4.0.2->twisted)
Downloading setuptools-36.2.7-py2.py3-none-any.whl (477kB): 477kB downloaded
Installing collected packages: setuptools
Found existing installation: setuptools 5.5.1
Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
Successfully installed setuptools
Cleaning up...

pi@pi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
Traceback (most recent call last):
File "tradfri.tac", line 1, in <module>
from twisted.conch.telnet import TelnetTransport, TelnetProtocol
ImportError: No module named 'twisted'
Hi all,
Ill get that exact same fault as andi2160, and can not get pass this. Anyone that have any more ideas?

Thank you

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

Posted: Monday 11 September 2017 14:44
by moroen
andnyg wrote:
Sunday 10 September 2017 18:12
andi216 wrote:
Saturday 05 August 2017 19:26
moroen wrote:
There's definitely something wrong with your twisted install, you should be able to import twisted from interactive python... Try forcing an update?

$ pip3 install --upgrade twisted

Regards,
M
pi@pi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
Traceback (most recent call last):
File "tradfri.tac", line 1, in <module>
from twisted.conch.telnet import TelnetTransport, TelnetProtocol
ImportError: No module named 'twisted'
Hi all,
Ill get that exact same fault as andi2160, and can not get pass this. Anyone that have any more ideas?

Thank you
Just a quick question, which version of Python are you using? You should at least have Python 3.4.1.

Regards,
M

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

Posted: Monday 11 September 2017 18:29
by andnyg
Hello,

Im running 3.4.2

Thank you
/Andreas

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

Posted: Monday 11 September 2017 19:45
by andi216
I have reinstalled domoticz (RPi B+, with stable Version 3.8153)
Python 3.4.5
Now there is another type of error

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
Traceback (most recent call last):
  File "tradfri.tac", line 2, in <module>
    from twisted.internet import protocol, task, reactor, endpoints
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/reactor.py", line 38, in <module>
    from twisted.internet import default
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/default.py", line 56, in <module>
    install = _getInstallFunction(platform)
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/default.py", line 44, in _getInstallFunction
    from twisted.internet.epollreactor import install
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/epollreactor.py", line 24, in <module>
    from twisted.internet import posixbase
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/posixbase.py", line 18, in <module>
    from twisted.internet import error, udp, tcp
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/tcp.py", line 28, in <module>
    from twisted.internet._newtls import (
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/_newtls.py", line 21, in <module>
    from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
  File "/usr/local/lib/python3.4/dist-packages/twisted/protocols/tls.py", line 63, in <module>
    from twisted.internet._sslverify import _setAcceptableProtocols
  File "/usr/local/lib/python3.4/dist-packages/twisted/internet/_sslverify.py", line 38, in <module>
    TLSVersion.TLSv1_1: SSL.OP_NO_TLSv1_1,
AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'


Log

2017-09-11 20:37:57.278 (ikea) Initialized version 1.0.0, author 'moroen'
2017-09-11 20:37:57.346 (ikea) Debug log level set to: 'true'.
2017-09-11 20:37:57.347 (ikea) Heartbeat interval set to: 2.
2017-09-11 20:37:57.347 (ikea) Protocol set to: 'JSON'.
2017-09-11 20:37:57.347 (ikea) Transport set to: 'TCP/IP', 127.0.0.1:1234.
2017-09-11 20:37:57.349 PluginSystem: Starting I/O service thread.
2017-09-11 20:37:57.349 (ikea) Connect directive received, action initiated successfully.
2017-09-11 20:37:57.399 (ikea) Calling message handler 'onConnect'.
2017-09-11 20:37:57.400 (ikea) Failed to connect to IKEA tradfri COAP-adapter! Status: 111 Description: Connection refused
2017-09-11 20:37:57.701 (Batt zwave) Calling message handler 'onHeartbeat'.
2017-09-11 20:38:06.782 (ikea) Calling message handler 'onHeartbeat'.
2017-09-11 20:38:06.782 (ikea) Not connected - nextConnect: 3
2017-09-11 20:38:07.685 (Batt zwave) Calling message handler 'onHeartbeat'.
2017-09-11 20:38:08.790 (ikea) Calling message handler 'onHeartbeat'.
2017-09-11 20:38:08.790 (ikea) Not connected - nextConnect: 2
2017-09-11 20:38:10.797 (ikea) Calling message handler 'onHeartbeat'.
2017-09-11 20:38:10.797 (ikea) Not connected - nextConnect: 1

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

Posted: Tuesday 12 September 2017 20:02
by moroen
andi216 wrote:
Monday 11 September 2017 19:45
I have reinstalled domoticz (RPi B+, with stable Version 3.8153)
Python 3.4.5
Now there is another type of error

Code: Select all

AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'
There might be a problem with openssl, could you try to upgrade to latest openssl and latest openssl-libs?

And this might help as well:

Code: Select all

pip install --upgrade pyopenssl
Regards,
M

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

Posted: Tuesday 12 September 2017 22:10
by andi216
I tried - upgrade. No change.

pi@raspberrypi:~ $ openssl version
OpenSSL 1.0.1t 3 May 2016
And this might help as well:

pip install --upgrade pyopenssl

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

Posted: Wednesday 13 September 2017 0:32
by moroen
Strange... I'm pretty sure this is a twisted/openssl issue, and not the plugin as such. You should at least be able to import twisted from interactive python, if that fails, there must be an issue with twisted on your setup.

Another try:

Code: Select all

pip3 install -U twisted[tls]
You might find some info at https://github.com/django/daphne/issues/83 or https://twistedmatrix.com/trac/ticket/9121

(those are for python 2.x, but I think it's relevant for python3 as well)

Regards,
M

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

Posted: Wednesday 13 September 2017 17:20
by andi216
@moroen

Thank very much you for your advice. A step forward for me.
But...
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.3 started (command line)!
Waiting for connection
Connected from IPv4Address(TCP, '127.0.0.1', 56914)
Data received: b'{"key": "blablablabla", "action": "setConfig", "observe": "True", "gateway": "192.168.1.111"}'
Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/local/lib/python3.4/dist-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/local/lib/python3.4/dist-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python3.4/dist-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/usr/local/lib/python3.4/dist-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
File "/usr/local/lib/python3.4/dist-packages/twisted/internet/tcp.py", line 208, in doRead
return self._dataReceived(data)
File "/usr/local/lib/python3.4/dist-packages/twisted/internet/tcp.py", line 214, in _dataReceived
rval = self.protocol.dataReceived(data)
File "tradfri.tac", line 51, in dataReceived
self.factory.initGateway(self, command['gateway'], command['key'], command['observe'])
File "tradfri.tac", line 231, in initGateway
for group in self.groups:
builtins.TypeError: 'Group' object is not iterable

Disconnected


Log
2017-09-13 18:23:30.105 (ikea) Calling message handler 'onHeartbeat'.
2017-09-13 18:23:30.256 (ikea) Calling message handler 'onHeartbeat'.
2017-09-13 18:23:32.263 (ikea) Calling message handler 'onHeartbeat'.

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

Posted: Wednesday 13 September 2017 17:34
by moroen
andi216 wrote:
Wednesday 13 September 2017 17:20
@moroen

Thank very much you for your advice. A step forward for me.
But...

Code: Select all

builtins.TypeError: 'Group' object is not iterable

Disconnected
Glad it worked out!

It seems you have discovered a bug in the coap-adapter, it looks like you might not have any groups defined? I'll fix it as soon as I can, and commit it to github!

Thanks for your interest in the plugin and thanks for the bug-report! :)

Regards,
M

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

Posted: Wednesday 13 September 2017 18:06
by andi216
it looks like you might not have any groups defined?
I have a single group with 2 bulbs.

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

Posted: Wednesday 13 September 2017 20:02
by moroen
Ok, so not the error I imagined then... Would you mind providing me with the output of:

Code: Select all

coap-client -k key-goes-here coaps://192.168.x.x/15004/
Regards,
M

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

Posted: Wednesday 13 September 2017 20:15
by andi216
Would you mind providing me with the output of: coap-client -k key-goes-here coaps://192.168.x.x/15004/
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ coap-client -k key-goes-here coaps://192.168.1.111/15004/
v:1 t:CON c:GET i:4b5d {} [ ]
Sep 13 21:10:28 ALRT 20 invalidate peer
Sep 13 21:10:28 WARN received alert, peer has been invalidated

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

Posted: Wednesday 13 September 2017 20:45
by moroen
Hm, no group information at all?

Ok, what about:

Code: Select all

coap-client -k key-goes-here coaps://192.168.x.x/.well-known/core
If you still get the same
Sep 13 21:10:28 ALRT 20 invalidate peer
Sep 13 21:10:28 WARN received alert, peer has been invalidated

there's something wrong with libcoap and coap-client, the plugin uses coap-client to talk to the gateway

Regards,
M

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

Posted: Wednesday 13 September 2017 20:56
by andi216
Ok, what about:
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ coap-client -k key-goes-here coaps://192.168.1.111/.well-known/core
v:1 t:CON c:GET i:1a65 {} [ ]
Sep 13 21:54:41 ALRT 20 invalidate peer
Sep 13 21:54:41 WARN received alert, peer has been invalidated[/quote]

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

Posted: Thursday 14 September 2017 0:11
by moroen
[/quote]
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ coap-client -k key-goes-here coaps://192.168.1.111/.well-known/core
v:1 t:CON c:GET i:1a65 {} [ ]
Sep 13 21:54:41 ALRT 20 invalidate peer
Sep 13 21:54:41 WARN received alert, peer has been invalidated
[/quote]

I've reproduced this error by specifying the wrong key, are you sure the key your using is correct?

Regards,
M

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

Posted: Friday 15 September 2017 19:17
by andi216
I've reproduced this error by specifying the wrong key, are you sure the key your using is correct?
key is correct !
I checked with the next order $ python3 -i -m pytradfri IP KEY (and it works)

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

Posted: Sunday 17 September 2017 18:35
by Lars65
When I try to install this, I get :

error while loading shared libraries usr/local/bin/python3.5


I don't know how many times I tried this, seems impossible.
I run domoticz beta latest
Raspberry Pi 3
raspbian Jessie

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

Posted: Sunday 17 September 2017 18:49
by moroen
andi216 wrote:
Friday 15 September 2017 19:17
I've reproduced this error by specifying the wrong key, are you sure the key your using is correct?
key is correct !
I checked with the next order $ python3 -i -m pytradfri IP KEY (and it works)
Hm, I'm running out of ideas... coap-client must work from the command line, but since pytradfri works, I guess it somehow does... I'll think some more...

Regards,
M