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

Python and python framework

Moderator: leecollings

User avatar
sancla
Posts: 105
Joined: Wednesday 01 January 2020 23:01
Target OS: -
Domoticz version:
Contact:

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

Post by sancla »

Just updated the guide on my site (sancla.com), seems to be working again as expected.
Has been tested and verified with a clean new raspberry pi installation.
However, the plugin was unstable just after creating a new Ikea hardware device in Domoticz.
The Domoticz service needed a restart, then it stabilized.
Check these howto's: https://sancla.com
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

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

Post by jeroenkl »

moroen wrote: Tuesday 14 January 2020 1:23 There's a new version of the plugin available in the master branch, version 0.7.0.

Most notable changes:
- Support for Tradfri Curtains
- Less noise in the logs, including changed priority of "Connection Timeout Errors" to debug, and state changes written to the individual device logs only when state actually has changed, not on every poll.
- (Hopefully) fix for a rare occurrence where all the groups contained the same devices
- (Hopefully) fix where domoticz just dies when encountering a read or write timeout from the gateway (pycoap)

Please note that a updated version of pycoap is needed (0.7.0), upgrade with:

Code: Select all

$ sudo -H pip3 install -U -r requirements.txt
Regards,
M
I've got the same problem after the update as mentioned above:

Code: Select all

2020-01-14 22:40:53.308 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:09:14.733 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:33:37.293 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:36:20.420 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:40:31.298 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:51:56.649 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:10.266 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:20.119 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:01:22.683 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:08:06.354 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:33:17.575 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:46:27.772 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:53:34.681 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 00:53:34.681 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 01:03:44.468 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:21:06.614 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:39:11.066 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:52:30.699 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:06:29.882 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:11:23.118 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:23.179 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:33.156 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:32:31.722 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:45:15.098 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:52:19.111 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:02:02.373 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:13:28.360 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:16:24.249 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:47:46.108 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:51:17.410 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 03:52:00.022 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:52:10.180 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:00:46.306 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:06:56.764 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:08:28.842 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:22.880 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:35.935 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:11:10.514 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:12:37.975 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:08.231 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:18.385 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:28.563 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:01:53.685 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:14.260 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:47.341 Error: (Ikea) Connection to gateway timed out
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 »

jeroenkl wrote: Wednesday 15 January 2020 6:00
moroen wrote: Tuesday 14 January 2020 1:23 There's a new version of the plugin available in the master branch, version 0.7.0.

Most notable changes:
- Support for Tradfri Curtains
- Less noise in the logs, including changed priority of "Connection Timeout Errors" to debug, and state changes written to the individual device logs only when state actually has changed, not on every poll.
- (Hopefully) fix for a rare occurrence where all the groups contained the same devices
- (Hopefully) fix where domoticz just dies when encountering a read or write timeout from the gateway (pycoap)

Please note that a updated version of pycoap is needed (0.7.0), upgrade with:

Code: Select all

$ sudo -H pip3 install -U -r requirements.txt
Regards,
M
I've got the same problem after the update as mentioned above:

Code: Select all

2020-01-14 22:40:53.308 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:09:14.733 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:33:37.293 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:36:20.420 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:40:31.298 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:51:56.649 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:10.266 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:20.119 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:01:22.683 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:08:06.354 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:33:17.575 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:46:27.772 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:53:34.681 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 00:53:34.681 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 01:03:44.468 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:21:06.614 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:39:11.066 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:52:30.699 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:06:29.882 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:11:23.118 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:23.179 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:33.156 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:32:31.722 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:45:15.098 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:52:19.111 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:02:02.373 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:13:28.360 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:16:24.249 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:47:46.108 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:51:17.410 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 03:52:00.022 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:52:10.180 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:00:46.306 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:06:56.764 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:08:28.842 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:22.880 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:35.935 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:11:10.514 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:12:37.975 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:08.231 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:18.385 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:28.563 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:01:53.685 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:14.260 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:47.341 Error: (Ikea) Connection to gateway timed out
Shuld be fixed in 0.7.1, just commited to github. No need to update pycoap

Regards,
M
trusky77
Posts: 18
Joined: Tuesday 24 December 2019 12:44
Target OS: -
Domoticz version:

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

Post by trusky77 »

moroen wrote: Tuesday 14 January 2020 21:08
trusky77 wrote: Tuesday 14 January 2020 14:59
moroen wrote: Tuesday 14 January 2020 1:14

Well, that should pretty much cover it, though I would recommend using something else than a Raspberry for domoticz. Just about any model NUC with some kind of SSD would be vastly superior... :ugeek:

Regards,
M

Good morning, the first test that was with another raspberry and another ssd, continues to do the same. I sign up about the Nuc that I have one at home to try. I have seen that you have made an update. I'm a rookie with Linux ... First I update Pycoap and then how should I update your plugin?
The easiest way to update is:

Code: Select all

$ sudo systemctl stop domoticz.service # if service is running
$ cd domoticz/plugins/IKEA-Tradfri
$ git pull
$ sudo -H pip3 install -U -r requirements.txt
$ sudo systemctl start domoticz.service
Then you get both the latest version of the plugin (with git pull) and latest version of pycoap (with sudo -H pip3...).

Actually, I recommend starting domoticz from the command line the first time after a upgrade, and after verifying that the new version works, restart the domoticz.service...

Regards,
M
Thank you very much for your plugin and for your help. I have it already updated and I will try again to see if it is finally solved. Thank you!!
ZatarraNL
Posts: 28
Joined: Saturday 16 September 2017 9:02
Target OS: Linux
Domoticz version: 4.10717
Location: Netherlands
Contact:

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

Post by ZatarraNL »

ZatarraNL wrote: Tuesday 14 January 2020 16:17
ZatarraNL wrote: Sunday 12 January 2020 13:10
trusky77 wrote: Saturday 04 January 2020 15:31 ....
...
I installed the new version. I now have pycoap-0.7.0 installed. Unfortunately the error in the domoticz-log remains after restarting.
Any help is very appreciated.
I have finally solved my problem with the plugin. Don't really know what the problem was, but for future references:

In the early stages of installation of the Tradfri plugin, I got an error with the usage of the pip-package. I got:

Code: Select all

File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable
After some googling, this seemed a known error since an pip update for debian9. I tried some solutions I found on google. One of which was: adjust the file /usr/bin/pip3. This one seemed to work. After some work around and a few hours of searching I managed to successfully use the pip3 command and install all the requirements. It seemed the plugin was installed, but I got the errors in the domoticz-log.

One remarkable thing:

Code: Select all

sudo -H pip3 install -U -r requirements.txt
never worked for me. But

Code: Select all

pip3 install --user -U -r requirements.txt
did. At least, so I thought...

After multiple uninstallations and installations of various versions of pip which all resulted in the same sys.exit-error of pip (which I could evade using the --user command), and also not succeeding with removing the domoticz-log error, I came to the idea to try to change /usr/bin/pip3 to its original state. After this action suddenly the command

Code: Select all

sudo -H pip3 install -U -r requirements.txt
worked. And with a restart of domoticz I no longer have the error, and my Ikea devices appear suddenly in the device-section of domoticz.
My conclusions is: somehow pycoap was installed, but not correctly. But that's just a big guess.

Moroen, thanks for al the work. Hope my findings will help some future users.
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 »

ZatarraNL wrote: Wednesday 15 January 2020 16:55
ZatarraNL wrote: Tuesday 14 January 2020 16:17
ZatarraNL wrote: Sunday 12 January 2020 13:10

...
I installed the new version. I now have pycoap-0.7.0 installed. Unfortunately the error in the domoticz-log remains after restarting.
Any help is very appreciated.
I have finally solved my problem with the plugin. Don't really know what the problem was, but for future references:

In the early stages of installation of the Tradfri plugin, I got an error with the usage of the pip-package. I got:

Code: Select all

File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable
After some googling, this seemed a known error since an pip update for debian9. I tried some solutions I found on google. One of which was: adjust the file /usr/bin/pip3. This one seemed to work. After some work around and a few hours of searching I managed to successfully use the pip3 command and install all the requirements. It seemed the plugin was installed, but I got the errors in the domoticz-log.

One remarkable thing:

Code: Select all

sudo -H pip3 install -U -r requirements.txt
never worked for me. But

Code: Select all

pip3 install --user -U -r requirements.txt
did. At least, so I thought...

After multiple uninstallations and installations of various versions of pip which all resulted in the same sys.exit-error of pip (which I could evade using the --user command), and also not succeeding with removing the domoticz-log error, I came to the idea to try to change /usr/bin/pip3 to its original state. After this action suddenly the command

Code: Select all

sudo -H pip3 install -U -r requirements.txt
worked. And with a restart of domoticz I no longer have the error, and my Ikea devices appear suddenly in the device-section of domoticz.
My conclusions is: somehow pycoap was installed, but not correctly. But that's just a big guess.

Moroen, thanks for al the work. Hope my findings will help some future users.
The underlying problem has all to do with python version management, in my opinion perhaps the worst thing about python. As long as you have only ONE version of python installed, everything usually is all dandy and fine. Usually upgrading python to a newer version works as long as you're using the package manager of your distro, but as soon as you try to install a newer version manually, all sorts of bad things might happen...

pip is not a command in it self, it is a module for the python interpreter, and it's quite easy to get into a situation where the pip3 command uses one python interpreter, and the python3 command starts another. And then add to the confusion it's not always easy to know WHICH python interpreter domoticz uses, and the ball starts rolling from there... So you might end up with a pip command that points to an illegal python interpreter (probably the reason for your first error) or a pip command that points to another python interpreter that domoticz uses... In that case, using python3 tradfricoap.py ... on the command line works, but domoticz can't find pycoap, because domoticz uses another interpreter than the one used on the command line...

Code: Select all

$ pip3 install --user ...
works if you'r running the pip3 command as the same user as domoticz, but still requires that the interpreter pip3 and domoticz uses are the same.

So the take home message is: Always have only ONE python interpreter installed systemwide, use a python version management tool (like pyenv) if you need to have more than one version of python installed, and if you install a systemwide python version manually, make sure that you completely remove the preinstalled version first, preferably using the distro package manager, but removing the python version installed by a package mangement system, will more than likely break the rest of your system in novel and uexpected ways... :evil:

I have some vague plans to take a look at getting domoticz to support virtual python environments, which will solve all of the above in regard to python, but since I generally do not enjoy writing C++, it's not high on the list of priorities...

Regards,
M
Creaky
Posts: 20
Joined: Monday 12 December 2016 15:45
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by Creaky »

If the whole pip, pip3 situation is too confusing, or isn't available on you platform, just use the coapcmd option under step 3b of the Tradfri plugin instructions. That will probably work fine on most Linux based platforms.

@Moroen: I hope you don't mind me posting the necessary GO and GIT installation instructions here, before you can add them to your README.md?
These instructions are writen for an installation on a Synology NAS, but are actually pretty generic and should work for any Linux distro.

To install the coapcmd option of the Tradfri plugin you need to follow these preliminary steps:

These instructions assume that you already have SSH access to your System/Synology NAS. To enable SSH access to your System/Synology NAS do a Google search, there are many instructions regarding this subject.

1. Make sure that you have installed Python3 on your System/Synology NAS. You can find the Python3 package in the DSM Package Manager
2. Make sure that you have installed Git on your System/Synology NAS. You can find the Git package in the ‘Community’ section of the DSM Package Manager
3. Open a SSH connection to your System/Synology NAS and execute the following command on the command line: uname -m
Make a note of the result, in my case the result was ‘armv7l’. This value indicates what type of architecture the CPU in your System/Synology NAS uses, we need this value to find the correct ‘Go’ version for your System/NAS
4. Go to https://golang.org/dl/ and download the correct Go version for your CPU architecture, save it in an easy to find location on your System/NAS. I recommend using the DSM ‘File Station’ application to upload it to your Synology home folder.
If you can’t find the exact version for your CPU architecture, a lower version will probably work to. ARMv6, for instance, works fine for my ARMv7l CPU
5. On the System/NAS command line go to your home directory by executing this command: cd $HOME
Use the command ‘ll’ (double l) to see a list of files in your home folder, the Go installation file should be in the file list
6. Follow the Go installation instructions here: https://golang.org/doc/install
7. When Go is successfully installed, go to step 1 of the IKEA-Tradfri plugin installation instructions, skip step 2 (you don’t need PIP) and then proceed to step 3b and follow the rest of the instructions
8. Restart Domoticz through the DSM Package Manager (Stop it, then start it)

You should now see the Tradfri plugin in the Hardware section of Domoticz, where you can add it and configure it.
Greetz,

·´¯`·.¸¸.·´¯`·. ( Creaky ) .·´¯`·.¸¸.·´¯ `·
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 »

Creaky wrote: Thursday 16 January 2020 9:21 If the whole pip, pip3 situation is too confusing, or isn't available on you platform, just use the coapcmd option under step 3b of the Tradfri plugin instructions. That will probably work fine on most Linux based platforms.

@Moroen: I hope you don't mind me posting the necessary GO and GIT installation instructions here, before you can add them to your README.md?
These instructions are writen for an installation on a Synology NAS, but are actually pretty generic and should work for any Linux distro.
Excellent, thanks! I'll update the readme with your instructions as soon as possible! ;)

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 »

Spoiler: show
Creaky wrote: Thursday 16 January 2020 9:21 If the whole pip, pip3 situation is too confusing, or isn't available on you platform, just use the coapcmd option under step 3b of the Tradfri plugin instructions. That will probably work fine on most Linux based platforms.

@Moroen: I hope you don't mind me posting the necessary GO and GIT installation instructions here, before you can add them to your README.md?
These instructions are writen for an installation on a Synology NAS, but are actually pretty generic and should work for any Linux distro.

To install the coapcmd option of the Tradfri plugin you need to follow these preliminary steps:

These instructions assume that you already have SSH access to your System/Synology NAS. To enable SSH access to your System/Synology NAS do a Google search, there are many instructions regarding this subject.

1. Make sure that you have installed Python3 on your System/Synology NAS. You can find the Python3 package in the DSM Package Manager
2. Make sure that you have installed Git on your System/Synology NAS. You can find the Git package in the ‘Community’ section of the DSM Package Manager
3. Open a SSH connection to your System/Synology NAS and execute the following command on the command line: uname -m
Make a note of the result, in my case the result was ‘armv7l’. This value indicates what type of architecture the CPU in your System/Synology NAS uses, we need this value to find the correct ‘Go’ version for your System/NAS
4. Go to https://golang.org/dl/ and download the correct Go version for your CPU architecture, save it in an easy to find location on your System/NAS. I recommend using the DSM ‘File Station’ application to upload it to your Synology home folder.
If you can’t find the exact version for your CPU architecture, a lower version will probably work to. ARMv6, for instance, works fine for my ARMv7l CPU
5. On the System/NAS command line go to your home directory by executing this command: cd $HOME
Use the command ‘ll’ (double l) to see a list of files in your home folder, the Go installation file should be in the file list
6. Follow the Go installation instructions here: https://golang.org/doc/install
7. When Go is successfully installed, go to step 1 of the IKEA-Tradfri plugin installation instructions, skip step 2 (you don’t need PIP) and then proceed to step 3b and follow the rest of the instructions
8. Restart Domoticz through the DSM Package Manager (Stop it, then start it)

You should now see the Tradfri plugin in the Hardware section of Domoticz, where you can add it and configure it.
Nice walkthrough, thanks for that!
I followed all the steps, got no error's but yet the IKEA plugin doesn't appear in de hardware list under the setup tab. Even did a restart of my SYNOLOGY NAS without any result. Reinstalled Domoticz to make sure I installed the Python3 version, but without result.
Any ideas?
Creaky
Posts: 20
Joined: Monday 12 December 2016 15:45
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by Creaky »

Let me start off with mentioning that I'm not very linux savvy :)
I get around, but I am no expert...

The first thing I can think of is the correct plugins directory, did you install the plugin here?

Code: Select all

/usr/local/domoticz/var/plugins/
The second thing is the owner, is the user 'domoticz' owner of the directory and all the files/dirs in it?
If not change the owner to domoticz with this command:

Code: Select all

sudo chown -R domoticz IKEA-Tradfri-plugin
The third thing is permissions, does the domoticz user have read and execute rights in the directory and the files/dirs in it?
If not change the permissions with this command:

Code: Select all

sudo chmod 755 -R IKEA-Tradfri-plugin
Then restart Domoticz again and see if the plugin shows up.
Greetz,

·´¯`·.¸¸.·´¯`·. ( Creaky ) .·´¯`·.¸¸.·´¯ `·
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 »

Creaky wrote: Thursday 16 January 2020 13:46 Let me start off with mentioning that I'm not very linux savvy :)
I get around, but I am no expert...

The first thing I can think of is the correct plugins directory, did you install the plugin here?

Code: Select all

/usr/local/domoticz/var/plugins/
The second thing is the owner, is the user 'domoticz' owner of the directory and all the files/dirs in it?
If not change the owner to domoticz with this command:

Code: Select all

sudo chown -R domoticz IKEA-Tradfri-plugin
The third thing is permissions, does the domoticz user have read and execute rights in the directory and the files/dirs in it?
If not change the permissions with this command:

Code: Select all

sudo chmod 755 -R IKEA-Tradfri-plugin
Then restart Domoticz again and see if the plugin shows up.
Silly me, so used to Pi that I didn't think about the plugin folder, it's under /var. It's working now! Thanks! :D
Creaky
Posts: 20
Joined: Monday 12 December 2016 15:45
Target OS: NAS (Synology & others)
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by Creaky »

Excellent! :D

And now we wait for more of Moroens delightfull magic ;)
Greetz,

·´¯`·.¸¸.·´¯`·. ( Creaky ) .·´¯`·.¸¸.·´¯ `·
trusky77
Posts: 18
Joined: Tuesday 24 December 2019 12:44
Target OS: -
Domoticz version:

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

Post by trusky77 »

moroen wrote: Tuesday 14 January 2020 21:08
trusky77 wrote: Tuesday 14 January 2020 14:59
moroen wrote: Tuesday 14 January 2020 1:14

Well, that should pretty much cover it, though I would recommend using something else than a Raspberry for domoticz. Just about any model NUC with some kind of SSD would be vastly superior... :ugeek:

Regards,
M

Good morning, the first test that was with another raspberry and another ssd, continues to do the same. I sign up about the Nuc that I have one at home to try. I have seen that you have made an update. I'm a rookie with Linux ... First I update Pycoap and then how should I update your plugin?
The easiest way to update is:

Code: Select all

$ sudo systemctl stop domoticz.service # if service is running
$ cd domoticz/plugins/IKEA-Tradfri
$ git pull
$ sudo -H pip3 install -U -r requirements.txt
$ sudo systemctl start domoticz.service
Then you get both the latest version of the plugin (with git pull) and latest version of pycoap (with sudo -H pip3...).

Actually, I recommend starting domoticz from the command line the first time after a upgrade, and after verifying that the new version works, restart the domoticz.service...

Regards,
M
It works perfectly. After 24H installed, there was no error in the log. BRAVO!!
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

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

Post by jeroenkl »

moroen wrote: Wednesday 15 January 2020 11:15
jeroenkl wrote: Wednesday 15 January 2020 6:00
moroen wrote: Tuesday 14 January 2020 1:23 There's a new version of the plugin available in the master branch, version 0.7.0.

Most notable changes:
- Support for Tradfri Curtains
- Less noise in the logs, including changed priority of "Connection Timeout Errors" to debug, and state changes written to the individual device logs only when state actually has changed, not on every poll.
- (Hopefully) fix for a rare occurrence where all the groups contained the same devices
- (Hopefully) fix where domoticz just dies when encountering a read or write timeout from the gateway (pycoap)

Please note that a updated version of pycoap is needed (0.7.0), upgrade with:

Code: Select all

$ sudo -H pip3 install -U -r requirements.txt
Regards,
M
I've got the same problem after the update as mentioned above:

Code: Select all

2020-01-14 22:40:53.308 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:09:14.733 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:33:37.293 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:36:20.420 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:40:31.298 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:51:56.649 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:10.266 Error: (Ikea) Connection to gateway timed out
2020-01-14 23:56:20.119 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:01:22.683 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:08:06.354 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:33:17.575 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:46:27.772 Error: (Ikea) Connection to gateway timed out
2020-01-15 00:53:34.681 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 00:53:34.681 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 00:53:34.682 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 01:03:44.468 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:21:06.614 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:39:11.066 Error: (Ikea) Connection to gateway timed out
2020-01-15 01:52:30.699 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:06:29.882 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:11:23.118 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:23.179 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:28:33.156 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:32:31.722 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:45:15.098 Error: (Ikea) Connection to gateway timed out
2020-01-15 02:52:19.111 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:02:02.373 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:13:28.360 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:16:24.249 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:47:46.108 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:51:17.410 Error: (Ikea) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 426 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 373 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 267 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 374 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 93 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function __init__
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-15 03:51:17.410 Error: (Ikea) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request
2020-01-15 03:52:00.022 Error: (Ikea) Connection to gateway timed out
2020-01-15 03:52:10.180 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:00:46.306 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:06:56.764 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:08:28.842 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:22.880 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:09:35.935 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:11:10.514 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:12:37.975 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:08.231 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:18.385 Error: (Ikea) Connection to gateway timed out
2020-01-15 04:17:28.563 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:01:53.685 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:14.260 Error: (Ikea) Connection to gateway timed out
2020-01-15 05:12:47.341 Error: (Ikea) Connection to gateway timed out
Shuld be fixed in 0.7.1, just commited to github. No need to update pycoap

Regards,
M
Yes works fine with update 0.7.1. Thanks!!!!
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: Wednesday 15 January 2020 11:15 Shuld be fixed in 0.7.1, just commited to github. No need to update pycoap

Regards,
M
Mmm, this morning I did a completely clean install with the latest version (0.7.2).
That is: I removed IKEA-Trafdri plugin from hardware page in Domoticz, then I removed the plugin folder, and I followed all installation steps to install it as new plugin.

After that everything is working OK: it did not crash Domoticz like an earlier version did :P , and all my devices are present and working fine.
But intermittingly I get the following error messages:

Code: Select all

2020-01-18 16:50:58.823 Error: (IKEA Tradfri) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 448 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 395 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 279 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 371 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request 
Maybe I also need to fix some python version troubles? :?:
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 18 January 2020 17:15
moroen wrote: Wednesday 15 January 2020 11:15 Shuld be fixed in 0.7.1, just commited to github. No need to update pycoap

Regards,
M
Mmm, this morning I did a completely clean install with the latest version (0.7.2).
That is: I removed IKEA-Trafdri plugin from hardware page in Domoticz, then I removed the plugin folder, and I followed all installation steps to install it as new plugin.

After that everything is working OK: it did not crash Domoticz like an earlier version did :P , and all my devices are present and working fine.
But intermittingly I get the following error messages:

Code: Select all

2020-01-18 16:50:58.823 Error: (IKEA Tradfri) 'onHeartbeat' failed 'ReadTimeoutError'.
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 448 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 395 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onHeartbeat
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 279 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 371 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap.py', function get_devices
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 30 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfri/pycoap_api.py', function request
2020-01-18 16:50:58.823 Error: (IKEA Tradfri) ----> Line 47 in '/usr/local/lib/python3.5/dist-packages/pycoap/pycoap.py', function Request 
Maybe I also need to fix some python version troubles? :?:
There's probably nothing wrong with you python setup. This is a timeout failure, the plugin is unable to read data from the gateway. Timeouts are a bit difficult to debug, since they happen intermittently and are difficult to simulate, so I'll fix them as they are reported. So this will be fixed in a future update, until fixed, it should be safe to ignore this error, the plugin should recover on the next poll...

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: Saturday 18 January 2020 20:29 There's probably nothing wrong with you python setup. This is a timeout failure, the plugin is unable to read data from the gateway. Timeouts are a bit difficult to debug, since they happen intermittently and are difficult to simulate, so I'll fix them as they are reported. So this will be fixed in a future update, until fixed, it should be safe to ignore this error, the plugin should recover on the next poll...

Regards,
M
Ah, good to know :)

The timeouts happened the last 24 hours only 12 times, and no pattern can be recognised.
So I can imagine it is very hard for you to debug.
If nothing wrong happens after/during a timeout, I would just ignore them if I were you... :geek:

Thanks anyway (again :P ) for all your time and effort!

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

Well, it seems like I was a bit premature with my cheers about Domoticz not dying anymore... :cry:

After enabling the plugin (0.7.2) in the evening, the following day Domoticz has died suddenly. I don't know if there is any log or something I can use to find when and how it dies, so if anybody knows let me know!
Or if any further system information is needed to be able to pinpoint the problem, just let me know!

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: Wednesday 22 January 2020 23:07 Well, it seems like I was a bit premature with my cheers about Domoticz not dying anymore... :cry:

After enabling the plugin (0.7.2) in the evening, the following day Domoticz has died suddenly. I don't know if there is any log or something I can use to find when and how it dies, so if anybody knows let me know!
Or if any further system information is needed to be able to pinpoint the problem, just let me know!

Regards, Wouter
Hm, you might be able to find something if you enable writing the log to a file, but when domoticz dies, sometimes it's not even able to write to the log. You'll get the best info if you run domoticz from the command line. Is tradfri the only plugin you're running?

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: Thursday 23 January 2020 9:28 Hm, you might be able to find something if you enable writing the log to a file, but when domoticz dies, sometimes it's not even able to write to the log. You'll get the best info if you run domoticz from the command line. Is tradfri the only plugin you're running?
Just to be sure:
How do I run Domoticz from the command line? Is it as simple as: first stop the Domoticz service (sudo systemctl stop domoticz.service), and then start it again (sudo systemctl start domoticz.service) ?
And then I have to let my PC run with the PuTTY command window open until Domoticz dies?

Reagarding other pluguins: I am running:
  • P1 Slimme meter USB
  • SolarEdge
  • Aeon Labs Z-stick

I have tried disabling the SolarEdge plugin, because that was the last one I added.
But still Domoticz dies when running your Ikea Trafdri plugin.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest