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

Python and python framework

Moderator: leecollings

Jasper79
Posts: 85
Joined: Sunday 26 July 2020 8:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

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

Post by Jasper79 »

Last night the lights didn't turn on, This morning I tried them en getting this error.

Code: Select all

2020-09-01 08:27:51.330 Status: User: Admin initiated a switch command (61/Ikea Tradfri - Lamp Op Vitrine Kast/On)
2020-09-01 08:27:51.337 Error: (Ikea Tradfri) 'onCommand' failed 'KeyError'.
2020-09-01 08:27:51.337 Error: (Ikea Tradfri) ----> Line 694 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
2020-09-01 08:27:51.337 Error: (Ikea Tradfri) ----> Line 615 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
Nothing changed and the Ikea hub has a static IP.
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

flexx wrote: Tuesday 21 April 2020 17:24 i'm struggeling to install the plugin onto my Synology 414 nas.
I believe I followed all steps correctly (after trying several times) but now i'm stuck at step 4, configuring the trafri coap.

The command sudo python3 plugin.py config 192.168.x.y ************** generates the following output.

Code: Select all

Traceback (most recent call last):
  File "plugin.py", line 172, in <module>
    create_ident(args.IP, args.KEY, CONFIGFILE)
  File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
    result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
I have no clue how to troubleshoot this and can't find anything on this forum to push me in the right direction.

Hi Flexx/Moroen,

I have the same issue.
I was wondering where the command tries to write the config file as permissions issue seems related to that.
Flexx mentioned he chmod some directories??

Below my output. Similar config. Synology NAS and had to use coapcmd as the only viable option.
-------------------------------------------------
python3 plugin.py config IP KEY

Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

-------------------------------------------------

Axel
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

AxelvanH wrote: Wednesday 16 September 2020 9:50
flexx wrote: Tuesday 21 April 2020 17:24 i'm struggeling to install the plugin onto my Synology 414 nas.
I believe I followed all steps correctly (after trying several times) but now i'm stuck at step 4, configuring the trafri coap.

The command sudo python3 plugin.py config 192.168.x.y ************** generates the following output.

Code: Select all

Traceback (most recent call last):
  File "plugin.py", line 172, in <module>
    create_ident(args.IP, args.KEY, CONFIGFILE)
  File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
    result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied


I have no clue how to troubleshoot this and can't find anything on this forum to push me in the right direction.

Hi Flexx/Moroen,

I have the same issue.
I was wondering where the command tries to write the config file as permissions issue seems related to that.
Flexx mentioned he chmod some directories??

Below my output. Similar config. Synology NAS and had to use coapcmd as the only viable option.
-------------------------------------------------
python3 plugin.py config IP KEY

Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

-------------------------------------------------

Axel
Just as a temp work around, Maybe it's also possible to manually create/edit the config file?
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 »

AxelvanH wrote: Wednesday 16 September 2020 16:37
AxelvanH wrote: Wednesday 16 September 2020 9:50
flexx wrote: Tuesday 21 April 2020 17:24 i'm struggeling to install the plugin onto my Synology 414 nas.
I believe I followed all steps correctly (after trying several times) but now i'm stuck at step 4, configuring the trafri coap.

The command sudo python3 plugin.py config 192.168.x.y ************** generates the following output.

Code: Select all

Traceback (most recent call last):
  File "plugin.py", line 172, in <module>
    create_ident(args.IP, args.KEY, CONFIGFILE)
  File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
    result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied


I have no clue how to troubleshoot this and can't find anything on this forum to push me in the right direction.

Hi Flexx/Moroen,

I have the same issue.
I was wondering where the command tries to write the config file as permissions issue seems related to that.
Flexx mentioned he chmod some directories??

Below my output. Similar config. Synology NAS and had to use coapcmd as the only viable option.
-------------------------------------------------
python3 plugin.py config IP KEY

Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

-------------------------------------------------

Axel
Just as a temp work around, Maybe it's also possible to manually create/edit the config file?
It might be possible, but then you need a working IDENT/KEY pair. I'm not an expert on synology, but from the error-messages, it appears that the plugin fails when trying to execute coapcmd, so that's before it tries to write to the config file. Are you able to run the coapcmd command manually?

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 »

The latest firmware update from IKEA appears to break the plugin when using py3coap as the COAP transport, as there is a significant delay between commands. It's possible to switch one device, and then there is a significant pause before it's possible to switch the device again, or switch another device.

Using coapcmd seems to avoid this issue, so as a temporary solution is to use coapcmd instead of py3coap:

Code: Select all

$ cd ../plugins/IKEA-Tradfri
$ sh ./install_coapcmd.sh
$ python3 plugin.py api coapcmd
$ python3 plugin.py list
This requires that git and go is installed.

Alternatively there are prebuild binaries available for linux-x86_64, arm v6 and v7, darwin (macos) and windows. Download the correct binary from https://github.com/moroen/coapcmd/releases and put the binary into the bin-directory in the IKEA-Tradfri directory and rename it to coapcmd (coapcmd.exe on windows). The bin directory might not exists, just create it before copying in the binary.

Regards,
M
Last edited by moroen on Thursday 17 September 2020 20:23, edited 1 time in total.
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

moroen wrote: Wednesday 16 September 2020 17:30
AxelvanH wrote: Wednesday 16 September 2020 16:37
AxelvanH wrote: Wednesday 16 September 2020 9:50


Hi Flexx/Moroen,

I have the same issue.
I was wondering where the command tries to write the config file as permissions issue seems related to that.
Flexx mentioned he chmod some directories??

Below my output. Similar config. Synology NAS and had to use coapcmd as the only viable option.
-------------------------------------------------
python3 plugin.py config IP KEY

Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

-------------------------------------------------

Axel
Just as a temp work around, Maybe it's also possible to manually create/edit the config file?
It might be possible, but then you need a working IDENT/KEY pair. I'm not an expert on synology, but from the error-messages, it appears that the plugin fails when trying to execute coapcmd, so that's before it tries to write to the config file. Are you able to run the coapcmd command manually?

Regards,
M
HI Moroen,

Thanks for the swift reply.
1. but then you need a working IDENT/KEY pair:
I have all the data, IP and key were left out intentionally :)
So if, IP and the identity key (bottom of hub) are enough I have those.

2. Are you able to run the coapcmd command manually?
You might be right that the OS can't find the command, should the directory be listed in the PATH?
Which command should I run to check that. just 'coapcmd' does not resonate at least :)

== Update, I added the dir of coapcmd to the path, that helped. coapcmd now works.
The error is still the same though.


Thanks,
Axel
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 »

AxelvanH wrote: Wednesday 16 September 2020 17:59
moroen wrote: Wednesday 16 September 2020 17:30
It might be possible, but then you need a working IDENT/KEY pair. I'm not an expert on synology, but from the error-messages, it appears that the plugin fails when trying to execute coapcmd, so that's before it tries to write to the config file. Are you able to run the coapcmd command manually?

Regards,
M
HI Moroen,

Thanks for the swift reply.
1. but then you need a working IDENT/KEY pair:
I have all the data, IP and key were left out intentionally :)
So if, IP and the identity key (bottom of hub) are enough I have those.

2. Are you able to run the coapcmd command manually?
You might be right that the OS can't find the command, should the directory be listed in the PATH?
Which command should I run to check that. just 'coapcmd' does not resonate at least :)

Thanks,
Axel
You can't use the KEY printed on the bottom of the gateway in the config file. That key is the "master key", and it can only be used to create KEYS for new IDENTS. That'a what the plugin does when issuing the config command, it uses the master key to generate a PSK for a randomly created IDENT and then stores this random IDENT along with the generated PSK in the config file. So in order to manually specify a IDENT/PSK pair in the config file, you need to have a pair that's generated using a working installation...

In order for the plugin to find coapcmd, the coapcmd needs to be placed in a bin subdirectory in the IKEA-Tradfri directory.

Regards,
M
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

moroen wrote: Wednesday 16 September 2020 18:13
AxelvanH wrote: Wednesday 16 September 2020 17:59
moroen wrote: Wednesday 16 September 2020 17:30
It might be possible, but then you need a working IDENT/KEY pair. I'm not an expert on synology, but from the error-messages, it appears that the plugin fails when trying to execute coapcmd, so that's before it tries to write to the config file. Are you able to run the coapcmd command manually?

Regards,
M
HI Moroen,

Thanks for the swift reply.
1. but then you need a working IDENT/KEY pair:
I have all the data, IP and key were left out intentionally :)
So if, IP and the identity key (bottom of hub) are enough I have those.

2. Are you able to run the coapcmd command manually?
You might be right that the OS can't find the command, should the directory be listed in the PATH?
Which command should I run to check that. just 'coapcmd' does not resonate at least :)

Thanks,
Axel
You can't use the KEY printed on the bottom of the gateway in the config file. That key is the "master key", and it can only be used to create KEYS for new IDENTS. That'a what the plugin does when issuing the config command, it uses the master key to generate a PSK for a randomly created IDENT and then stores this random IDENT along with the generated PSK in the config file. So in order to manually specify a IDENT/PSK pair in the config file, you need to have a pair that's generated using a working installation...

In order for the plugin to find coapcmd, the coapcmd needs to be placed in a bin subdirectory in the IKEA-Tradfri directory.

Regards,
M
Hi Moroen,

I have coapcmd working (updated my previous post) by adding the path to PATH.
So it now works from anywhere.
I tried the command agian, but the error message stays the same.
Is there anything else I can check?

Thanks,
Axel
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 16 September 2020 17:39 The latest firmware update from IKEA appears to break the plugin when using py3coap as the COAP transport, as there is a significant delay between commands. It's possible to switch one device, and then there is a significant pause before it's possible to switch the device again, or switch another device.

Using coapcmd seems to avoid this issue, so as a temporary solution is to use coapcmd instead of py3coap:

Code: Select all

$ cd ../plugins/IKEA-Tradfri
$ sh ./install_coapcmd.sh
$ python3 plugin.py api coapcmd
$ python3 plugin.py api list
This requires that git and go is installed.

Alternatively there are prebuild binaries available for linux-x86_64, arm v6 and v7, darwin (macos) and windows. Download the correct binary from https://github.com/moroen/coapcmd/releases and put the binary into the bin-directory in the IKEA-Tradfri directory and rename it to coapcmd (coapcmd.exe on windows). The bin directory might not exists, just create it before copying in the binary.

Regards,
M
got an error, what can I do to fix?

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py api list
usage: plugin.py api [-h] {pycoap,coapcmd}
plugin.py api: error: argument API: invalid choice: 'list' (choose from 'pycoap', 'coapcmd')


when using:
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py list
Connection 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: Thursday 17 September 2020 19:00 got an error, what can I do to fix?

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py api list
usage: plugin.py api [-h] {pycoap,coapcmd}
plugin.py api: error: argument API: invalid choice: 'list' (choose from 'pycoap', 'coapcmd')


when using:
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py list
Connection timed out
My bad, there's an error in the instructions, the command should be:

Code: Select all

$ python3 plugin.py list
I've updated the original post to correct this!

Regards,
M
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

AxelvanH wrote: Wednesday 16 September 2020 18:39
moroen wrote: Wednesday 16 September 2020 18:13
AxelvanH wrote: Wednesday 16 September 2020 17:59

HI Moroen,

Thanks for the swift reply.
1. but then you need a working IDENT/KEY pair:
I have all the data, IP and key were left out intentionally :)
So if, IP and the identity key (bottom of hub) are enough I have those.

2. Are you able to run the coapcmd command manually?
You might be right that the OS can't find the command, should the directory be listed in the PATH?
Which command should I run to check that. just 'coapcmd' does not resonate at least :)

Thanks,
Axel
You can't use the KEY printed on the bottom of the gateway in the config file. That key is the "master key", and it can only be used to create KEYS for new IDENTS. That'a what the plugin does when issuing the config command, it uses the master key to generate a PSK for a randomly created IDENT and then stores this random IDENT along with the generated PSK in the config file. So in order to manually specify a IDENT/PSK pair in the config file, you need to have a pair that's generated using a working installation...

In order for the plugin to find coapcmd, the coapcmd needs to be placed in a bin subdirectory in the IKEA-Tradfri directory.

Regards,
M
Hi Moroen,

I have coapcmd working (updated my previous post) by adding the path to PATH.
So it now works from anywhere.
I tried the command agian, but the error message stays the same.
Is there anything else I can check?

Thanks,
Axel
Hi Moroen,

I kept on testing and discovered the following, that hopefully helps solving my issue.
When I delete the config.json file in the IKEA-Tradfri directory and run.
(IP and Code are fake, just for testing)

python3 plugin.py config 1.1.1.1 code
Py3coap module not found!
Install with "pip3 install py3coap" or select another api with "python3 plugin.py api"

So I run
python3 plugin.py api coapcmd

Which recreates the config.json file.

But running

python3 plugin.py config 1.1.1.1 code
Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

Again gives still the same error. chmod 777 on config.json did not make any difference.

My config.json file:

vi config.json
{"Gateway": null, "Identity": null, "Api": "Coapcmd", "Transition_time": 10, "Passkey": null, "Verbosity": 0}


Any suggestion is welcome on how to proceed.

Thanks,
Axel
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

Please help!

python3 plugin.py config 1.1.1.1 code
Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

Again gives still the same error. chmod 777 on config.json did not make any difference.

My config.json file:

vi config.json
{"Gateway": null, "Identity": null, "Api": "Coapcmd", "Transition_time": 10, "Passkey": null, "Verbosity": 0}


Any suggestion is welcome on how to proceed.

Thanks,
Axel
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 »

AxelvanH wrote: Saturday 19 September 2020 21:02 Please help!

python3 plugin.py config 1.1.1.1 code
Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

Again gives still the same error. chmod 777 on config.json did not make any difference.

My config.json file:

vi config.json
{"Gateway": null, "Identity": null, "Api": "Coapcmd", "Transition_time": 10, "Passkey": null, "Verbosity": 0}


Any suggestion is welcome on how to proceed.

Thanks,
Axel
I'm still pretty sure that the error is a permission error when the plugin tries to run coapcmd, the error seems to occur at

Code: Select all

result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload],
Have you tried to set permission on coapcmd?

Code: Select all

chmod gou+rwx bin/coapcmd
Reagards,
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 »

The latest version of pycoap (0.9.0) and the plugin (0.9.5) now works with the latest IKEA Tradfri firmware 1.11.47. It's necessary to update both pycoap and the plugin to the latest version.

I'm not completely satisfied with this solution, it's a brute force solution to a problem I don't fully understand, but at least it's possible to switch more than one device without waiting > 45 seconds before switching another.

Unfortunately, it's noticeably slower when switching multiple devices than the previous version. When switching just one device, there shouldn't be much of a delay, but when switching several devices (as when using scenes), there will be a noticeable delay between lights changing state. On my system this delay is around 1-2 seconds between each light switching, so the lights turn on/off in an obvious sequence.

At the moment this can't be helped. I've not been able to figure out why the gateway just ignores PUT requests for around 45 seconds after receiving a PUT-request. It might be some kind of acknowledgement-issue, but since the API is not public, it's impossible to tell. The plugin and pycoap works around this issue by keeping the connection open between GET requests, but closes it after a PUT-request. The next GET or PUT request will then reopen the connection. Since updating several lights at once, entails several PUT requests, the connection gets closed and reopened several times, hence the delay.

Regards,
M
Jasper79
Posts: 85
Joined: Sunday 26 July 2020 8:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

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

Post by Jasper79 »

Thanks I'll update.

I've used home assistant with trådfri before and that was instant all the time. It didn't need to wait for a pull from the IKEA hub.

Might want to have a look at that plug in to improve this one for Domoticz.
Dutchhornet
Posts: 2
Joined: Sunday 22 July 2018 13:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

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

Post by Dutchhornet »

Works fine after the update of the plugin to 0.9.6.

5hanx
hairynoggin
Posts: 7
Joined: Thursday 26 October 2017 6:26
Target OS: Windows
Domoticz version:
Contact:

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

Post by hairynoggin »

HI peeps,

can someone help me, I have updated the plugin to 0.9.6, but whenever I select it in the dropdown for "hardware" it always seems to revert back to 0.9.2 .... anything I can do to rectify this?

apologies if this is a repeat question

/
MdeBoer
Posts: 10
Joined: Thursday 23 January 2020 14:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 11942
Location: Alkmaar, NL
Contact:

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

Post by MdeBoer »

HI!

I have the plugin updated tot 0.9.6 en PyCoap to 0.9.0 now I have the following error:

(Domoticz Version: Version: 2020.2 Build Hash: b63341bc0)

Can someone explain this?

Lights wil switch on, but it takes about 5 to 10 seconds to switch them on.

Code: Select all

2020-09-25 23:00:43.127 Error: (IKEA-Tradfri) 'onCommand' failed 'JSONDecodeError'.
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 725 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 645 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 165 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function State
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 64 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function process_result
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 348 in '/usr/lib/python3.7/json/__init__.py', function loads
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 337 in '/usr/lib/python3.7/json/decoder.py', function decode
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 355 in '/usr/lib/python3.7/json/decoder.py', function raw_decode
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 »

MdeBoer wrote: Friday 25 September 2020 23:04 HI!

I have the plugin updated tot 0.9.6 en PyCoap to 0.9.0 now I have the following error:

(Domoticz Version: Version: 2020.2 Build Hash: b63341bc0)

Can someone explain this?

Lights wil switch on, but it takes about 5 to 10 seconds to switch them on.

Code: Select all

2020-09-25 23:00:43.127 Error: (IKEA-Tradfri) 'onCommand' failed 'JSONDecodeError'.
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 725 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 645 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onCommand
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 165 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function State
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 64 in '/home/pi/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function process_result
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 348 in '/usr/lib/python3.7/json/__init__.py', function loads
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 337 in '/usr/lib/python3.7/json/decoder.py', function decode
2020-09-25 23:00:43.128 Error: (IKEA-Tradfri) ----> Line 355 in '/usr/lib/python3.7/json/decoder.py', function raw_decode
Please take a look at https://github.com/moroen/IKEA-Tradfri- ... issues/114

Regards,
M
AxelvanH
Posts: 29
Joined: Sunday 22 November 2015 22:11
Target OS: NAS (Synology & others)
Domoticz version: 2020.01
Location: Netherlands
Contact:

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

Post by AxelvanH »

moroen wrote: Monday 21 September 2020 0:35
AxelvanH wrote: Saturday 19 September 2020 21:02 Please help!

python3 plugin.py config 1.1.1.1 code
Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

Again gives still the same error. chmod 777 on config.json did not make any difference.

My config.json file:

vi config.json
{"Gateway": null, "Identity": null, "Api": "Coapcmd", "Transition_time": 10, "Passkey": null, "Verbosity": 0}


Any suggestion is welcome on how to proceed.

Thanks,
Axel
I'm still pretty sure that the error is a permission error when the plugin tries to run coapcmd, the error seems to occur at

Code: Select all

result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload],
Have you tried to set permission on coapcmd?

Code: Select all

chmod gou+rwx bin/coapcmd
Reagards,
M

Hi Moroen,

Yes, I just did and run the command again with the same result.:
/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri# python3 plugin.py config 1.1.1.1 code
Traceback (most recent call last):
File "plugin.py", line 177, in <module>
create_ident(args.IP, args.KEY, CONFIGFILE)
File "/volume1/@appstore/domoticz/var/plugins/IKEA-Tradfri/tradfricoap/coapcmd_api.py", line 81, in create_ident
result = json.loads(subprocess.run([_coapCMD, "post", "--ident", "Client_identity", "--key", key, uri, payload], stdout=subprocess.PIPE).stdout.decode('utf-8'))
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/subprocess.py", line 1544, in _execute_child
raise child_exception_type(errno_num, err_msg)

Let's try a different approach :)
How do I start with a 'clean install' ? Is it enough just to remove the Tradfri directory?

Thanks, Axel
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest