[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 »

iTDB wrote: Friday 06 December 2019 10:51
moroen wrote: Friday 06 December 2019 1:09 I would recommend trying out the "new" plugin-version. It's easier to install and most importantly, doesn't require running a tradfri service.
So /moroen/IKEA-Tradfri-plugin is not the newest plugin? Where can I find the new one?
Thx
It's in the same repository, it's just in a separate branch. You'll find it here: https://github.com/moroen/IKEA-Tradfri- ... ree/pycoap

Just make sure that you checkout the pycoap branch after cloning the repo into the plugins-folder of domoticz!

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 »

If your starting a fresh install of the IKEA-tradfri plugin, I would recommend trying out the "new" plugin-version. It's easier to install
I was doing a fresh install (after getting weird problems with my previous 2.0 install) when I got errors with the config file. So when I saw your comment about easier install, I started again with the pycoap version.
However, first I had a decent struggle to install the necessary golang compiler (latest, version 1.13.5) with the correct PATH settings.

And now I am stuck at the command:

Code: Select all

python3 tradfricoap.py config IP KEY
because I am getting this error:

Code: Select all

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)
Any ideas how I can fix this?

Note: I am running an updated version of Raspbian on a Raspberry Pi, with my own account (not "pi" account).

Code: Select all

python --version --> Python 2.7.13

Code: Select all

python3 --version --> Python 3.5.3
I have Python 3.7 installed, but read that setting this as default for python3 will give problems running pip3 commands... :?
iTDB
Posts: 29
Joined: Friday 29 November 2019 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Gent
Contact:

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

Post by iTDB »

moroen wrote: Friday 06 December 2019 12:10 It's in the same repository, it's just in a separate branch. You'll find it here: https://github.com/moroen/IKEA-Tradfri- ... ree/pycoap
Also gives me errors:
pi@mydomoticz:~/domoticz/plugins/IKEA-Tradfri $ git checkout pycoap
Branch 'pycoap' set up to track remote branch 'pycoap' from 'origin'.
Switched to a new branch 'pycoap'
pi@mydomoticz:~/domoticz/plugins/IKEA-Tradfri $ pip3 install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: pip in /usr/local/lib/python3.7/dist-packages (19.3.1)
pi@mydomoticz:~/domoticz/plugins/IKEA-Tradfri $ pip3 install --upgrade setuptools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: setuptools in /usr/local/lib/python3.7/dist-packages (42.0.2)
pi@mydomoticz:~/domoticz/plugins/IKEA-Tradfri $ pip3 install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://test.pypi.org/simple/
Requirement already satisfied: appdirs in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 2)) (1.4.3)
Collecting pycoap
Using cached https://test-files.pythonhosted.org/pac ... 5.3.tar.gz
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-uh3lf4te/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uh3lf4te/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-qll_7prh --python-tag cp37
cwd: /tmp/pip-install-uh3lf4te/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/tmpt5d_7rjw 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-uh3lf4te/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uh3lf4te/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-5udpyb6c/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-uh3lf4te/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/tmpgetxj0aa 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-uh3lf4te/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uh3lf4te/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-5udpyb6c/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

pi@mydomoticz:~/domoticz/plugins/IKEA-Tradfri $
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 »

@iTDB:
I had the same error.

Code: Select all

No such file or directory: 'go': 'go'
Did you install the (recent version of the) Go compiler?
And if you did: is the install location of this Go compiler in your Path environment variable? To check :

Code: Select all

echo $PATH
What is the output if you enter:

Code: Select all

go version
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 06 December 2019 22:46 @iTDB:
I had the same error.

Code: Select all

No such file or directory: 'go': 'go'
Did you install the (recent version of the) Go compiler?
And if you did: is the install location of this Go compiler in your Path environment variable? To check :

Code: Select all

echo $PATH
What is the output if you enter:

Code: Select all

go version
It seems that it's not easy to build Arm compatible wheels using Azure. I'll dig up one of my Raspberries and try to build a wheel and upload to the pypi index, or at least make sure it's doable and update the readme with instructions for installing on a Raspberry... :shock:

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 »

It seems that it's not easy to build Arm compatible wheels using Azure. I'll dig up one of my Raspberries and try to build a wheel and upload to the pypi index, or at least make sure it's doable and update the readme with instructions for installing on a Raspberry... :shock:
As a .Net / C# / Windows developer all this is very new and strange for me :shock:
I am used to build and include all that is needed to run something. And not to 'force' users to download and compile things themselves, but I guess that is standard in Lunix world because of all the platforms and different versions?!

I'll keep an eye on this thread, as soon as you have something to test and try, just post a message here (or send me a pm).

Thanks for all your efforts moroen! :D

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: Saturday 07 December 2019 15:16
It seems that it's not easy to build Arm compatible wheels using Azure. I'll dig up one of my Raspberries and try to build a wheel and upload to the pypi index, or at least make sure it's doable and update the readme with instructions for installing on a Raspberry... :shock:
As a .Net / C# / Windows developer all this is very new and strange for me :shock:
I am used to build and include all that is needed to run something. And not to 'force' users to download and compile things themselves, but I guess that is standard in Lunix world because of all the platforms and different versions?!
Yes, even though there are quite a few different ways of creating setup/install systems for Linux, the wide variations of platforms and versions makes creating a "works everywhere" install system for linux somewhat difficult.

The build and include everything needed is arguably one positive thing about the monolithic approach of Windows, but once you get used to using package managers and compiling software from scratch, the amount of freedom and control is quite nice! And usually you don't end up with a system having a multitude of different versions of the same libraries, since all programs are more or less expected to use the same system libraries.

But then again, I've been using variants of Unix more or less since 1992, so I'm probably somewhat biased... :D

Anyway, I digress... :lol:
wvdweerd wrote: Saturday 07 December 2019 15:16
I'll keep an eye on this thread, as soon as you have something to test and try, just post a message here (or send me a pm).
I've not been able to quite figure out why using pip to install pycoap from the test pypi-index fails on Raspbian, but using latest raspbian (buster) image, it seems to work when using pip to install directly from the github-repo. Take a look at the readme for Raspberry (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md) for instructions. And btw, you don't need to install the latest golang compiler by hand, the version packaged with buster should do the trick nicely!

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: Sunday 08 December 2019 2:24 I've not been able to quite figure out why using pip to install pycoap from the test pypi-index fails on Raspbian, but using latest raspbian (buster) image, it seems to work when using pip to install directly from the github-repo. Take a look at the readme for Raspberry (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md) for instructions. And btw, you don't need to install the latest golang compiler by hand, the version packaged with buster should do the trick nicely!

Regards,
M
Unfortunately I am still using Stretch, and my Raspbian and Domotcz skills are not well enough to try to upgrade :?
(I had to Google just now what Buster and Stretch are exactly and how I could figure out which version I am using)

I deleted the pycoap stuff in my "/usr/local/lib/python3.5/dist-packages" and then I followed your new PI instructions.

Unfortunately I got the same error about "go" again:

Code: Select all

OUTPUT from: 
...$ sudo -H pip3 install -r requirements-pi.txt:

Requirement already satisfied: appdirs in /usr/local/lib/python3.5/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-cmt4thc8/pycoap
  Running command git clone -q git://github.com/moroen/pycoap.git /tmp/pip-install-cmt4thc8/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-cmt4thc8/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cmt4thc8/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-7ghd1u2o --python-tag cp35
       cwd: /tmp/pip-install-cmt4thc8/pycoap/
  Complete output (11 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-3.5
  creating build/lib.linux-armv7l-3.5/pycoap
  copying pycoap/pycoap.py -> build/lib.linux-armv7l-3.5/pycoap
  copying pycoap/__init__.py -> build/lib.linux-armv7l-3.5/pycoap
  running build_ext
  $ GOPATH=/tmp/tmpv5vq7s2m go get -d
  error: [Errno 2] No such file or directory: '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-cmt4thc8/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cmt4thc8/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-ps2bl1zg/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-cmt4thc8/pycoap/
    Complete output (11 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.5
    creating build/lib.linux-armv7l-3.5/pycoap
    copying pycoap/pycoap.py -> build/lib.linux-armv7l-3.5/pycoap
    copying pycoap/__init__.py -> build/lib.linux-armv7l-3.5/pycoap
    running build_ext
    $ GOPATH=/tmp/tmpbtibayo2 go get -d
    error: [Errno 2] No such file or directory: 'go'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cmt4thc8/pycoap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cmt4thc8/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-ps2bl1zg/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
But if I look at the PATH environment var there is a entry to the go compiler location, and getting the version also works?!

Code: Select all

...$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/usr/local/games:/usr/games
...$ go version
go version go1.13.5 linux/arm
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: Sunday 08 December 2019 13:50
moroen wrote: Sunday 08 December 2019 2:24 I've not been able to quite figure out why using pip to install pycoap from the test pypi-index fails on Raspbian, but using latest raspbian (buster) image, it seems to work when using pip to install directly from the github-repo. Take a look at the readme for Raspberry (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md) for instructions. And btw, you don't need to install the latest golang compiler by hand, the version packaged with buster should do the trick nicely!

Regards,
M
Unfortunately I am still using Stretch, and my Raspbian and Domotcz skills are not well enough to try to upgrade :?
(I had to Google just now what Buster and Stretch are exactly and how I could figure out which version I am using)

I deleted the pycoap stuff in my "/usr/local/lib/python3.5/dist-packages" and then I followed your new PI instructions.

Unfortunately I got the same error about "go" again:

Code: Select all

    $ GOPATH=/tmp/tmpbtibayo2 go get -d
    error: [Errno 2] No such file or directory: 'go'
But if I look at the PATH environment var there is a entry to the go compiler location, and getting the version also works?!

Code: Select all

...$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/usr/local/games:/usr/games
...$ go version
go version go1.13.5 linux/arm
Go is probably not in the path when using sudo. Try using the package version of GO:

Code: Select all

$ sudo apt install golang
It's version 1.7, I haven't tried it, but it's probably sufficient...

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: Sunday 08 December 2019 15:14
Go is probably not in the path when using sudo. Try using the package version of GO:

Code: Select all

$ sudo apt install golang
It's version 1.7, I haven't tried it, but it's probably sufficient...

Regards,
M
Super, this worked! :D

After installing golang, I now got no errors when running:

Code: Select all

sudo -H pip3 install -r requirements-pi.txt
And creating the config with "sudo python3 tradfricoap.py config IP KEY" worked (""INFO:root:config created").
I had to use "sudo su" to get "sudo python3 tradfricoap.py list" working, probably because the config was created at 'root' level?

But after rebooting my Raspberry Pi and enabling the IKEA-TRADFRI plugin in Domoticz all my devices are present again.
And I can control them again from within Domoticz.

For now I happy again, hopefully everthing keeps working, even if I add some timers for my lights :D

Thanks again for all your efforts and quick replies! :)
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 »

wvdweerd wrote: Sunday 08 December 2019 17:03 For now I happy again, hopefully everthing keeps working, even if I add some timers for my lights :D
Mmm, everything is still working (I can stil switch a light on and off), but in the log I see the following errors:

Code: Select all

2019-12-08 17:56:44.209 Error: (IKEA Tradfri) 'onHeartbeat' failed 'AttributeError':''device' object has no attribute 'device''.
2019-12-08 17:56:44.209 Error: (IKEA Tradfri) ----> Line 346 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 302 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 65 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function indexRegisteredDevices
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 83 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDevice
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 163 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Level
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 283 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Members 
So, something is not working correct?
:?: :?: :?:
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: Sunday 08 December 2019 18:40
wvdweerd wrote: Sunday 08 December 2019 17:03 For now I happy again, hopefully everthing keeps working, even if I add some timers for my lights :D
Mmm, everything is still working (I can stil switch a light on and off), but in the log I see the following errors:

Code: Select all

2019-12-08 17:56:44.209 Error: (IKEA Tradfri) 'onHeartbeat' failed 'AttributeError':''device' object has no attribute 'device''.
2019-12-08 17:56:44.209 Error: (IKEA Tradfri) ----> Line 346 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 302 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 65 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function indexRegisteredDevices
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 83 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDevice
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 163 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Level
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 283 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Members 
So, something is not working correct?
:?: :?: :?:
Glad it worked out so far... I need some more information, could you please enable debug for the plugin (from the IKEA Tradfri hardware page) and post the relevant parts of the log? It has something to with groups, do you have any groups without any member devices?

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 »

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
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?

Code: Select all

ModuleNotFoundError: No module named 'appdirs'
Version 3.5.x to Version 3.7.x is tested, support for version 3.8 is work in progress. You need to install all requirements, I recommend checking out the readme (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md), but the important part:

Code: Select all

$ sudo -H pip3 install -r requirements-pi.txt
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 »

moroen wrote: Sunday 08 December 2019 22:19
wvdweerd wrote: Sunday 08 December 2019 18:40
wvdweerd wrote: Sunday 08 December 2019 17:03 For now I happy again, hopefully everthing keeps working, even if I add some timers for my lights :D
Mmm, everything is still working (I can stil switch a light on and off), but in the log I see the following errors:

Code: Select all

2019-12-08 17:56:44.209 Error: (IKEA Tradfri) 'onHeartbeat' failed 'AttributeError':''device' object has no attribute 'device''.
2019-12-08 17:56:44.209 Error: (IKEA Tradfri) ----> Line 346 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 302 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 65 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function indexRegisteredDevices
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 83 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDevice
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 163 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Level
2019-12-08 17:56:44.210 Error: (IKEA Tradfri) ----> Line 283 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function Members 
So, something is not working correct?
:?: :?: :?:
Glad it worked out so far... I need some more information, could you please enable debug for the plugin (from the IKEA Tradfri hardware page) and post the relevant parts of the log? It has something to with groups, do you have any groups without any member devices?

Regards,
M
@wvdweerd, actually, it doesn't need to have anything to do with groups, it might be an unrecognised device? Do you have tradfri curtains installed?

I've pushed a new version to github, so if you be as kind as to pull it, enable debug and post the log? If you don't mind, would you also post the output of tradfricoap.py list?

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 »

moroen wrote: Monday 09 December 2019 0:19
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?

Code: Select all

ModuleNotFoundError: No module named 'appdirs'
Version 3.5.x to Version 3.7.x is tested, support for version 3.8 is work in progress. You need to install all requirements, I recommend checking out the readme (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md), but the important part:

Code: Select all

$ sudo -H pip3 install -r requirements-pi.txt
Regards,
M
That is the instructions that I followed and which resulted in the error.
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: Monday 09 December 2019 7:28
moroen wrote: Monday 09 December 2019 0:19
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?

Code: Select all

ModuleNotFoundError: No module named 'appdirs'
Version 3.5.x to Version 3.7.x is tested, support for version 3.8 is work in progress. You need to install all requirements, I recommend checking out the readme (https://github.com/moroen/IKEA-Tradfri- ... ADME-PI.md), but the important part:

Code: Select all

$ sudo -H pip3 install -r requirements-pi.txt
Regards,
M
That is the instructions that I followed and which resulted in the error.
Strange, appdirs should be installed when using the requirements-file. Could you post the output of "sudo -H pip3 install -r requirements-pi.txt"? And perhaps try to install appdirs by hand:

Code: Select all

$ sudo -H pip3 install appdirs
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, here is the output of "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)
Requirement already satisfied: pycoap from git+git://github.com/moroen/pycoap.git#egg=pycoap in /usr/local/lib/python3.7/dist-packages (from -r requirements-pi.txt (line 2)) (0.5.3)

and "sudo -H pip3 install appdirs" gives
root@raspberrypi:/home/pi/domoticz/plugins/IKEA-Tradfri# sudo -H pip3 install appdirs
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: appdirs in /usr/lib/python3/dist-packages (1.4.3)
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: Monday 09 December 2019 1:40
Glad it worked out so far... I need some more information, could you please enable debug for the plugin (from the IKEA Tradfri hardware page) and post the relevant parts of the log? It has something to with groups, do you have any groups without any member devices?
...
@wvdweerd, actually, it doesn't need to have anything to do with groups, it might be an unrecognised device? Do you have tradfri curtains installed?

I've pushed a new version to github, so if you be as kind as to pull it, enable debug and post the log? If you don't mind, would you also post the output of tradfricoap.py list?

Regards,
M
I don't have any groups.
Following your request I am now running the new version: 2019-12-09 21:27:43.342 Status: (IKEA Tradfri) Initialized version 0.4.2, author 'moroen'

Output of the list command:

Code: Select all

/home/pi/domoticz/plugins/IKEA-Tradfri$ python3 tradfricoap.py list
INFO:tradfri.config:Loading config
65536: Afst. bediening Wouter (None - None)
65553: Afstandsbediening Carin (None - None)
65549: Afstandsbediening slaapkamer (None - None)
65546: TRADFRI on/off switch (None - None)
65547: Buitenlamp voordeur (1 - None)
65548: Buitenlamp voorkant huis (1 - None)
65554: Lamp Carin (1 - efd275)
65550: Slaapkamer lamp 1 (bureau) (0 - efd275)
65552: Slaapkamer lamp 3 (kast) (0 - efd275)
65551: Slaapkamer lamp 2 (bed) (0 - efd275)
65537: Lamp Wouter boven (1 - f1e0b5)
65538: Lamp Wouter onder (1 - efd275)
Translation and IKEA article numbers :geek: :
Afstandsbediening = remote control - 304.431.24
On/off switch - wireless dimmer - 704.085.95
Buitenlamp = light bulb - 904.087.97
Lamp - GU10 lights - 904.086.03


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:

Code: Select all

2019-12-09 21:42:43.554 (IKEA Tradfri) Pushing 'onHeartbeatCallback' on to queue
2019-12-09 21:42:43.576 (IKEA Tradfri) Processing 'onHeartbeatCallback' message 
2019-12-09 21:42:43.576 (IKEA Tradfri) Calling message handler 'onHeartbeat'.
2019-12-09 21:42:43.598 (IKEA Tradfri - Buitenlamp voordeur) Updating device from 1:'58' to have values 1:'58'.
2019-12-09 21:42:43.630 (IKEA Tradfri - Buitenlamp voorkant huis) Updating device from 1:'58' to have values 1:'58'.
2019-12-09 21:42:43.659 (IKEA Tradfri - Lamp Carin) Updating device from 1:'5' to have values 1:'5'.
2019-12-09 21:42:43.695 (IKEA Tradfri - Lamp Carin - Color) Updating device from 1:'30' to have values 1:'30'.
2019-12-09 21:42:43.734 (IKEA Tradfri - Slaapkamer lamp 1 (bureau)) Updating device from 0:'89' to have values 0:'89'.
2019-12-09 21:42:43.756 (IKEA Tradfri - Slaapkamer lamp 1 (bureau) - Color) Updating device from 0:'30' to have values 0:'30'.
2019-12-09 21:42:43.777 (IKEA Tradfri - Slaapkamer lamp 3 (kast)) Updating device from 0:'82' to have values 0:'82'.
2019-12-09 21:42:43.798 (IKEA Tradfri - Slaapkamer lamp 3 (kast) - Color) Updating device from 0:'30' to have values 0:'30'.
2019-12-09 21:42:43.826 (IKEA Tradfri - Slaapkamer lamp 2 (bed)) Updating device from 0:'83' to have values 0:'83'.
2019-12-09 21:42:43.849 (IKEA Tradfri - Slaapkamer lamp 2 (bed) - Color) Updating device from 0:'30' to have values 0:'30'.
2019-12-09 21:42:43.875 (IKEA Tradfri - Lamp Wouter boven) Updating device from 1:'31' to have values 1:'31'.
2019-12-09 21:42:43.899 (IKEA Tradfri - Lamp Wouter boven - Color) Updating device from 1:'20' to have values 1:'20'.
2019-12-09 21:42:43.930 (IKEA Tradfri - Lamp Wouter onder) Updating device from 1:'31' to have values 1:'31'.
2019-12-09 21:42:43.953 (IKEA Tradfri - Lamp Wouter onder - Color) Updating device from 1:'30' to have values 1:'30'.
2019-12-09 21:42:53.556 (IKEA Tradfri) Pushing 'onHeartbeatCallback' on to queue
2019-12-09 21:42:53.578 (IKEA Tradfri) Processing 'onHeartbeatCallback' message 
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: 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest