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

Python and python framework

Moderator: leecollings

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 »

Nopea wrote: Sunday 08 December 2019 22:57 Running a fresh install of Buster on a Raspberry Pi 3 and following the guidelines in this thread I get the following. Any suggestions how to proceed? What version of python should one be using?
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python -V
Python 3.8.0
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python tradfricoap.py config xxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyy
Traceback (most recent call last):
File "tradfricoap.py", line 5, in <module>
from tradfri.config import get_config, host_config
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/config.py", line 1, in <module>
import appdirs, logging, os, json
ModuleNotFoundError: No module named 'appdirs'

root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 -V
Python 3.7.3
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py config xxxxxxxxxxxxx yyyyyyyyyyyyyyyyy
2019/12/08 21:53:57 COAP DTLS Error: Handshake timeout
Traceback (most recent call last):
File "tradfricoap.py", line 357, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/gw.py", line 17, in create_ident
uri, payload=payload, method=pycoap.POST, ident="Client_identity", key=key
File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
Sorry, looking at this again, it appears I might have led you out on somewhat of a wild goose-chase... :oops:

You actually have two separate issues here, due to having two different python interpreters. I see that when using python (i.e. 3.8.0 on you system) the Modules are not installed, I would guess that your pip3 is using the python3 interpreter (3.7.3).

The second, and more pertinent issue is the "COAP DTLS Error: Handshake timeout" - error. That shows that the modules are installed and that tradfricoap.py tries to connect to your gateway, but fails to establish a connection. Check the ip and gateway key!

A bit of friendly advice, and I really don't want to come across as a "besserwisser" here, but unless it's by design, you really should fix your python installation! Having two (or more) separate version 3.x interpreters installed in the system path is asking for trouble...

Installing modules using pip might become a nightmare and more importantly, you need to determine which python interpreter domoticz is actually using, and make sure that the needed modules are installed for that interpreter. You might end up in a situation where tradfricoap.py works from the command line, but still fails from domoticz, because the command line is using one interpreter and domoticz another!

Traditionally python refers to a version 2.x interpreter and python3 to a 3.x, and thus pip is used for installing modules for the 2.x interpreter and pip3 for the 3.x version. Now, this might change when python 2x. reach end of life 01.01.2020... If you actually need to have more than one version 3.x interpreter available on your system, take a look at pyenv (https://github.com/pyenv/pyenv)!

Unless you really need the latest python, I would stick to the python3 version available as a package in raspbian, on buster that is 3.7.3 which works for tradfri and most other python3 applications...

Regards,
M
Nopea
Posts: 8
Joined: Sunday 08 December 2019 16:28
Target OS: -
Domoticz version:
Contact:

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

Post by Nopea »

I did a clean install of Buster on a Raspberry Pi and followed the guidelines in https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md. Got up to a point, with some issues along the way, as follows.

First issue:
pi@raspberrypi:~ $ sudo apt install golang python3 python3-dev python3 pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package pip
Second issue:

pi@raspberrypi:~/domoticz/IKEA-Tradfri $ sudo -H pip3 install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pip
Downloading https://files.pythonhosted.org/packages ... ne-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 91kB/s
Installing collected packages: pip
Found existing installation: pip 18.1
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-19.3.1


Third iusse:
pi@raspberrypi:~/domoticz/IKEA-Tradfri $ sudo -H pip3 install -r requirements-pi.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: appdirs in /usr/lib/python3/dist-packages (from -r requirements-pi.txt (line 1)) (1.4.3)
Collecting pycoap
Cloning git://github.com/moroen/pycoap.git to /tmp/pip-install-105jy0k1/pycoap
Running command git clone -q git://github.com/moroen/pycoap.git /tmp/pip-install-105jy0k1/pycoap
Building wheels for collected packages: pycoap
Building wheel for pycoap (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-nxmmmh7m --python-tag cp37
cwd: /tmp/pip-install-105jy0k1/pycoap/
Complete output (11 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.7
creating build/lib.linux-armv7l-3.7/pycoap
copying pycoap/pycoap.py -> build/lib.linux-armv7l-3.7/pycoap
copying pycoap/__init__.py -> build/lib.linux-armv7l-3.7/pycoap
running build_ext
$ GOPATH=/tmp/tmpxit9tnd_ go get -d
error: [Errno 2] No such file or directory: 'go': 'go'
----------------------------------------
ERROR: Failed building wheel for pycoap
Running setup.py clean for pycoap
Failed to build pycoap
Installing collected packages: pycoap
Running setup.py install for pycoap ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xdal169_/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-105jy0k1/pycoap/
Complete output (11 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.7
creating build/lib.linux-armv7l-3.7/pycoap
copying pycoap/pycoap.py -> build/lib.linux-armv7l-3.7/pycoap
copying pycoap/__init__.py -> build/lib.linux-armv7l-3.7/pycoap
running build_ext
$ GOPATH=/tmp/tmpfgn3lz0g go get -d
error: [Errno 2] No such file or directory: 'go': 'go'
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-105jy0k1/pycoap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('
Nopea
Posts: 8
Joined: Sunday 08 December 2019 16:28
Target OS: -
Domoticz version:
Contact:

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

Post by Nopea »

Tried installing go following the instructions in https://golang.org/doc/install#install, did not help.
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 »

Nopea wrote: Tuesday 10 December 2019 7:58 Tried installing go following the instructions in https://golang.org/doc/install#install, did not help.
There's a error in the instructions, I have updated the readme, the correct line for dependencies are (note python3-pip):

Code: Select all

$ sudo apt install golang python3 python3-dev python3-pip
That should take care of the first and second issue. The third issue shows that python3 can't find the go compiler. What's the output of:

Code: Select all

$ sudo apt install golang
$ go version
Regards,
M
Nopea
Posts: 8
Joined: Sunday 08 December 2019 16:28
Target OS: -
Domoticz version:
Contact:

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

Post by Nopea »

As requested:
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# go version
go version go1.11.6 linux/arm
With the revised instruction I get up to this point, with no prior error messages:
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py config 192.168.x.x AABBCCDDEEFFGGHH
Traceback (most recent call last):
File "tradfricoap.py", line 369, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/gw.py", line 17, in create_ident
uri, payload=payload, method=pycoap.POST, ident="Client_identity", key=key
File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
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 »

Nopea wrote: Tuesday 10 December 2019 17:44 As requested:
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# go version
go version go1.11.6 linux/arm
With the revised instruction I get up to this point, with no prior error messages:
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py config 192.168.x.x AABBCCDDEEFFGGHH
Traceback (most recent call last):
File "tradfricoap.py", line 369, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/gw.py", line 17, in create_ident
uri, payload=payload, method=pycoap.POST, ident="Client_identity", key=key
File "/usr/lib/python3.7/json/__init__.py", line 341, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
The plugin is unable to get any data from the gateway. If you pull the latest version and enable debug:

Code: Select all

$ cd IKEA-Tradfri
$ git pull
$ python3 tradfricoap.py --debug config IP KEY
Regards,
M
Nopea
Posts: 8
Joined: Sunday 08 December 2019 16:28
Target OS: -
Domoticz version:
Contact:

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

Post by Nopea »

Now it works, many thanks!

Image

The motion sensor is listed, but not enabled in Domotiz (yet), as stated in the documentation.

Code: Select all

root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py list
INFO:tradfri.config:Loading config
65536: TRADFRI motion sensor (None - None)
65538: TRADFRI outlet (0 - None)
65537: TRADFRI bulb (0 - 0)
Given the low cost of IKEA components, it would be much appreciated to have support for other components as well.

Is my understanding correct that the only way to connect a light bulb to the controller is to pair it with a remote or a motion sensor, as I did? My original plan was not to acquire any IKEA remote, but an IKEA remote is needed even if one is not planning to use it. In other words, a bulb cannot be connected to a gateway using the gateway only or the app only.
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 »

Nopea wrote: Tuesday 10 December 2019 21:11 Now it works, many thanks!

Image

The motion sensor is listed, but not enabled in Domotiz (yet), as stated in the documentation.

Code: Select all

root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# python3 tradfricoap.py list
INFO:tradfri.config:Loading config
65536: TRADFRI motion sensor (None - None)
65538: TRADFRI outlet (0 - None)
65537: TRADFRI bulb (0 - 0)
Given the low cost of IKEA components, it would be much appreciated to have support for other components as well.

Is my understanding correct that the only way to connect a light bulb to the controller is to pair it with a remote or a motion sensor, as I did? My original plan was not to acquire any IKEA remote, but an IKEA remote is needed even if one is not planning to use it. In other words, a bulb cannot be connected to a gateway using the gateway only or the app only.
Great! :)

Currently bulbs, sockets, led-drivers and floalt-panels are supported. I plan to add support for other components as soon as I can get my hands on them. The next on the list is support for the curtains, but due to unforeseen factors, I haven't had the gotten round to buying some yet, and it's quite difficult to add support for a component without having the actual hardware! Support for the motion sensors are somewhat far of, as it requires proper COAP observations, and with all the different approaches and coap libraries I have tried, stable observations has eluded me...

And yes, as far as I know, you need to use a remote to include a component into the gateway, it can't be done without!

Regards,
M
wvdweerd
Posts: 22
Joined: Saturday 20 October 2018 18:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: The Netherlands
Contact:

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

Post by wvdweerd »

moroen wrote: Tuesday 10 December 2019 0:11
wvdweerd wrote: Monday 09 December 2019 21:48
Now I think about it: I recently bought and installed an "on/off switch": 65546: TRADFRI on/off switch (None - None)
Could this be the cause of the problems?

PS: the last 15 minutes no errors in the debug log yet. Just a lot of messages like the following:
That actually makes sense. I've spent some time trying to trace and reproduce the error, but failed to achieve either... Then it suddenly dawned upon me, that I had forgotten to ask you one crucial piece of information, if the error was consistent (i.e. on every updateDevice) or intermittent.

I don't think it has something to do with the on/off switch, it's should (at the moment at least) just be ignored by the plugin. If the error is intermittent, as it appears from your latest post, I believe it is a timeout-issue, and as far as I can tell, just throws an error and then happily chugs along, until the next update is called... Doesn't mean that I won't fix it, though, but at least it sort of makes sense and I know what to fix... :o

The verbose log is expected when enabling debug, so you can just turn debug back off! :D

Regards,
M
Sorry for my late reply...

Yes, the errors are intermittent.
After switching off the debug I still get the same bunch of errors in the log.
Yesterday at 03:16u, 05:51u, 07:26u, 07:36u, 07:41u, 10:26u, 18:06u, 22:46u, 00:26, 07:21u.
There does not seem to be a logical pattern when these errors occur?!

PS: I now also think that the same thing happened when I still used the aiocoap version 2.0 of your plugin. Starting some month ago the plugin would just work, but then at some random time I could not use the plugin anymore to switch my lights on or off. But without seeing any errors in the Domoticz log!
And switching the log to debug for your plugin would fill the log very quickly with all the "heartbeat" log lines, so I would switch back to non-debug log after an hour or so. And then the plugin would work again (because it was restarted) for some limited time... :shock:
So I think your new pycoap version is a bit more fault tolerant than the aiocoap version, so that after an erorr it "then happily chugs along, until the next update is called" ;)

Would be nice if you could find the cause of the error :geek:

Regards,
Wouter
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 »

wvdweerd wrote: Friday 13 December 2019 8:57
moroen wrote: Tuesday 10 December 2019 0:11
wvdweerd wrote: Monday 09 December 2019 21:48
Now I think about it: I recently bought and installed an "on/off switch": 65546: TRADFRI on/off switch (None - None)
Could this be the cause of the problems?

PS: the last 15 minutes no errors in the debug log yet. Just a lot of messages like the following:
That actually makes sense. I've spent some time trying to trace and reproduce the error, but failed to achieve either... Then it suddenly dawned upon me, that I had forgotten to ask you one crucial piece of information, if the error was consistent (i.e. on every updateDevice) or intermittent.

I don't think it has something to do with the on/off switch, it's should (at the moment at least) just be ignored by the plugin. If the error is intermittent, as it appears from your latest post, I believe it is a timeout-issue, and as far as I can tell, just throws an error and then happily chugs along, until the next update is called... Doesn't mean that I won't fix it, though, but at least it sort of makes sense and I know what to fix... :o

The verbose log is expected when enabling debug, so you can just turn debug back off! :D

Regards,
M
Sorry for my late reply...

Yes, the errors are intermittent.
After switching off the debug I still get the same bunch of errors in the log.
Yesterday at 03:16u, 05:51u, 07:26u, 07:36u, 07:41u, 10:26u, 18:06u, 22:46u, 00:26, 07:21u.
There does not seem to be a logical pattern when these errors occur?!

PS: I now also think that the same thing happened when I still used the aiocoap version 2.0 of your plugin. Starting some month ago the plugin would just work, but then at some random time I could not use the plugin anymore to switch my lights on or off. But without seeing any errors in the Domoticz log!
And switching the log to debug for your plugin would fill the log very quickly with all the "heartbeat" log lines, so I would switch back to non-debug log after an hour or so. And then the plugin would work again (because it was restarted) for some limited time... :shock:
So I think your new pycoap version is a bit more fault tolerant than the aiocoap version, so that after an erorr it "then happily chugs along, until the next update is called" ;)

Would be nice if you could find the cause of the error :geek:

Regards,
Wouter
Thank's!

I'm pretty confident that the error is due to intermittent timeouts when the plugin requests an updated state from the gateway. The lack of a logical pattern to when the errors occur, support that theory. Glad it is, as you say, a bit more faulterant! I'm currently working on handling timeouts better, but it also requires changes to the underlying pycoap library, so it takes some time... I'll let you know when an updated version is available! :)

Regards,
M

P.S: And you're probably right that the same problem happened with the old plugin, but that the old solution handled it even worse. If the new version works out as hoped, the old version will be retired, and any new features only added to the new plugin...
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

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

Post by dressie »

Trying to install this plugin according the latest readme file. So far so good, but when I try to enter the IP and CODE I get this error:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py --debug config xxxx xxxx
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $
Anyone?
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 »

dressie wrote: Friday 13 December 2019 12:50 Trying to install this plugin according the latest readme file. So far so good, but when I try to enter the IP and CODE I get this error:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py --debug config xxxx xxxx
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $
Anyone?
The pycoap module is probably not installed correctly, I would guess something like missing the go compiler?

Could you please post the output of the following, and perhaps it's possible to narrow this down further:

Code: Select all

sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Regards,
M
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

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

Post by dressie »

moroen wrote: Friday 13 December 2019 13:32
dressie wrote: Friday 13 December 2019 12:50 Trying to install this plugin according the latest readme file. So far so good, but when I try to enter the IP and CODE I get this error:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py --debug config xxxx xxxx
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $
Anyone?
The pycoap module is probably not installed correctly, I would guess something like missing the go compiler?

Could you please post the output of the following, and perhaps it's possible to narrow this down further:

Code: Select all

sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
This is the output, and thank you for helping!
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Requirement already satisfied: pycoap in /usr/local/lib/python3.5/dist-packages (0.5.3)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $


Regards,
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 »

dressie wrote: Friday 13 December 2019 13:39
moroen wrote: Friday 13 December 2019 13:32
dressie wrote: Friday 13 December 2019 12:50 Trying to install this plugin according the latest readme file. So far so good, but when I try to enter the IP and CODE I get this error:



Anyone?
The pycoap module is probably not installed correctly, I would guess something like missing the go compiler?

Could you please post the output of the following, and perhaps it's possible to narrow this down further:

Code: Select all

sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
This is the output, and thank you for helping!
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Requirement already satisfied: pycoap in /usr/local/lib/python3.5/dist-packages (0.5.3)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $


Regards,
M
I would guess it still doesn't work? I forgot that you need to remove the module before trying to install it again... :oops:

Code: Select all

$ sudo -H pip3 uninstall pycoap
$ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
So if you try it again, and post the output?

Regards,
M
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

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

Post by dressie »

I did the folowing:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 uninstall pycoap
Uninstalling pycoap-0.5.3:
Would remove:
/usr/local/lib/python3.5/dist-packages/_pycoap.cpython-35m-arm-linux-gnueabihf.h
/usr/local/lib/python3.5/dist-packages/_pycoap.cpython-35m-arm-linux-gnueabihf.so
/usr/local/lib/python3.5/dist-packages/pycoap-0.5.3.dist-info/*
/usr/local/lib/python3.5/dist-packages/pycoap/*
Proceed (y/n)? y
Successfully uninstalled pycoap-0.5.3
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Processing /root/.cache/pip/wheels/12/b4/6a/6a9def856599c85c4426a81be65e987f5405a6469779b79d5e/pycoap-0.5.3-cp35-cp35m-linux_armv7l.whl
Installing collected packages: pycoap
Successfully installed pycoap-0.5.3
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py config XXXXX XXXX(privacy)
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Requirement already satisfied: pycoap in /usr/local/lib/python3.5/dist-packages (0.5.3)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $
Thanks for your help!
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 »

dressie wrote: Friday 13 December 2019 14:21 I did the folowing:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 uninstall pycoap
Uninstalling pycoap-0.5.3:
Would remove:
/usr/local/lib/python3.5/dist-packages/_pycoap.cpython-35m-arm-linux-gnueabihf.h
/usr/local/lib/python3.5/dist-packages/_pycoap.cpython-35m-arm-linux-gnueabihf.so
/usr/local/lib/python3.5/dist-packages/pycoap-0.5.3.dist-info/*
/usr/local/lib/python3.5/dist-packages/pycoap/*
Proceed (y/n)? y
Successfully uninstalled pycoap-0.5.3
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Processing /root/.cache/pip/wheels/12/b4/6a/6a9def856599c85c4426a81be65e987f5405a6469779b79d5e/pycoap-0.5.3-cp35-cp35m-linux_armv7l.whl
Installing collected packages: pycoap
Successfully installed pycoap-0.5.3
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py config XXXXX XXXX(privacy)
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ sudo -H pip3 install -i https://test.pypi.org/simple/ pycoap
Looking in indexes: https://test.pypi.org/simple/, https://www.piwheels.org/simple
Requirement already satisfied: pycoap in /usr/local/lib/python3.5/dist-packages (0.5.3)
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $
Thanks for your help!
It still doesn't try to compile the module again, so it's status quo... Here we go again:

Code: Select all

$ sudo -H pip3 uninstall pycoap
$ sudo -H pip3 install --no-cache-dir -U -i https://test.pypi.org/simple/ pycoap
Regards,
M
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

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

Post by dressie »

moroen wrote: Friday 13 December 2019 14:27
It still doesn't try to compile the module again, so it's status quo... Here we go again:

Code: Select all

$ sudo -H pip3 uninstall pycoap
$ sudo -H pip3 install --no-cache-dir -U -i https://test.pypi.org/simple/ pycoap
Regards,
M
[/quote]

I tried but I keep getting the same error. Even did a reboot, but Ik keep getting this:
Spoiler: show
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
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 »

dressie wrote: Friday 13 December 2019 14:41
moroen wrote: Friday 13 December 2019 14:27
It still doesn't try to compile the module again, so it's status quo... Here we go again:

Code: Select all

$ sudo -H pip3 uninstall pycoap
$ sudo -H pip3 install --no-cache-dir -U -i https://test.pypi.org/simple/ pycoap
Regards,
M
I tried but I keep getting the same error. Even did a reboot, but Ik keep getting this:
Spoiler: show
Traceback (most recent call last):
File "tradfricoap.py", line 11, in <module>
import pycoap
File "/usr/local/lib/python3.5/dist-packages/pycoap/__init__.py", line 1, in <module>
from .pycoap import Request, setDebugLevel, GET, PUT, POST
File "/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py", line 1, in <module>
import _pycoap
ImportError: dynamic module does not define module export function (PyInit__pycoap)
Ok, let's try another approach! If you try to install pycoap manually, you'll find instructions in the readme: https://github.com/moroen/pycoap/blob/master/README.md

Just clone the repro somewhere in the pi-directory, and post the output!

Regards,
M
dressie
Posts: 156
Joined: Monday 25 May 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version: V2020.2
Location: Netherlands
Contact:

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

Post by dressie »

That seems to work! This is the outcome when I checked the connection:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py list
INFO:tradfri.config:Loading config
65540: TRADFRI bulb 3 (0 - f1e0b5)
65541: TRADFRI bulb 4 (0 - f1e0b5)
65537: TRADFRI bulb (0 - efd275)
65539: TRADFRI bulb 2 (0 - f1e0b5)
65538: TRADFRI remote control (None - None)
65536: TRADFRI on/off switch (None - None)
After this a reboot of Domoticz, enable hardware but it's not making devices. Log doesn't show anything either.
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 »

dressie wrote: Friday 13 December 2019 15:33 That seems to work! This is the outcome when I checked the connection:
pi@DomoticzCV:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfricoap.py list
INFO:tradfri.config:Loading config
65540: TRADFRI bulb 3 (0 - f1e0b5)
65541: TRADFRI bulb 4 (0 - f1e0b5)
65537: TRADFRI bulb (0 - efd275)
65539: TRADFRI bulb 2 (0 - f1e0b5)
65538: TRADFRI remote control (None - None)
65536: TRADFRI on/off switch (None - None)
After this a reboot of Domoticz, enable hardware but it's not making devices. Log doesn't show anything either.
Well, then at least the hard part should be done... :?

The plugin is shown in the hardware page, and you can enable it, but no devices? If you try to start domoticz from the command line, and PM me the log, I'll take a look! :)

Regards,
M
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest