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

Python and python framework
User avatar
heggink
Posts: 581
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

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

Post by heggink » Saturday 06 October 2018 10:03

No error messages, just domoticz complaining even though the plugin runs:

Code: Select all

2018-10-06 09:48:06.761 Error: Ikea hardware (83) thread seems to have ended unexpectedly

Code: Select all

IKEA-tradfri COAP-adaptor version 0.8 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=54994)
Data received: b'{"observe": "True", "action": "initGateway", "groups": "False", "pollinterval": "20"}'
Initializing gateway
Adding light with ID: 65540
Adding light with ID: 65539
Adding light with ID: 65538
Adding light with ID: 65537
Adding socket with ID: 65542
Adding socket with ID: 65544
Data received: b'{"action": "getLights"}'
{"action": "getLights", "status": "Ok", "result": [{"Name": "dressoir 1A", "HasRGB": false, "DeviceID": 65537, "Dimmable": true, "HasWB": true, "Type": "Light"}, {"Name": "dressoir 1B", "HasRGB": false, "DeviceID": 65538, "Dimmable": true, "HasWB": true, "Type": "Light"}, {"Name": "dressoir 2A", "HasRGB": false, "DeviceID": 65539, "Dimmable": true, "HasWB": true, "Type": "Light"}, {"Name": "dressoir 2B", "HasRGB": false, "DeviceID": 65540, "Dimmable": true, "HasWB": true, "Type": "Light"}, {"DeviceID": 65544, "Name": "TRADFRI control outlet 2", "Type": "Outlet"}, {"DeviceID": 65542, "Name": "TRADFRI control outlet", "Type": "Outlet"}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65537, 'Hex': 'efd275', 'Name': 'dressoir 1A', 'Level': 2}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65538, 'Hex': 'efd275', 'Name': 'dressoir 1B', 'Level': 2}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65539, 'Hex': 'efd275', 'Name': 'dressoir 2A', 'Level': 2}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65540, 'Hex': 'efd275', 'Name': 'dressoir 2B', 'Level': 2}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65544, 'Name': 'TRADFRI control outlet 2'}]}
{'action': 'deviceUpdate', 'status': 'Ok', 'result': [{'State': False, 'DeviceID': 65542, 'Name': 'TRADFRI control outlet'}]}
I suspect the plugin just takes more time to complete causing domoticz to complain... I have that on a number of other plugins as well but this one definitely outnumbers in terms of complaints :D . Just changed Domoticz.Heartbeat to 15 as that's mentioned to lead to these messages if above 30...
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

User avatar
heggink
Posts: 581
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

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

Post by heggink » Saturday 06 October 2018 10:31

Domoticz.Heartbeat(15) did the trick. No more complaints.
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen » Saturday 06 October 2018 11:35

heggink wrote:
Saturday 06 October 2018 10:31
Domoticz.Heartbeat(15) did the trick. No more complaints.
Thanks for letting me know, I'll change the heartbeat-frequency and update the branch!

Regards,
M

User avatar
jaha
Posts: 93
Joined: Thursday 26 January 2017 11:26
Target OS: Linux
Domoticz version:
Contact:

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

Post by jaha » Wednesday 10 October 2018 14:17

-¨>
Last edited by jaha on Wednesday 10 October 2018 16:10, edited 1 time in total.

User avatar
jaha
Posts: 93
Joined: Thursday 26 January 2017 11:26
Target OS: Linux
Domoticz version:
Contact:

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

Post by jaha » Wednesday 10 October 2018 16:08

Any idea what to do when getting this error?

root@domoticz:/home/system/domoticz/plugins/IKEA-Tradfri# /usr/local/bin/python3.6 ./configure.py 10.22.2.4 fnYhASmWfdfyFqa
Failed to generate ID/PSK-pair.
Check that the IP and Master Key is correct.

Is the format correct?

I tripple checked the key and ip. The key is also scaned from the QR code.

Stimpy68
Posts: 11
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

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

Post by Stimpy68 » Wednesday 10 October 2018 16:14

jaha wrote:
Wednesday 10 October 2018 16:08
Any idea what to do when getting this error?

root@domoticz:/home/system/domoticz/plugins/IKEA-Tradfri# /usr/local/bin/python3.6 ./configure.py 10.22.2.4 fnYhASmWfdfyFqa
Failed to generate ID/PSK-pair.
Check that the IP and Master Key is correct.

Is the format correct?

I tripple checked the key and ip. The key is also scaned from the QR code.
Have you tried:

Code: Select all

root@domoticz:/home/system/domoticz/plugins/IKEA-Tradfri# sudo ./configure.py 10.22.2.4 fnYhASmWfdfyFqa

Stimpy68
Posts: 11
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

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

Post by Stimpy68 » Wednesday 10 October 2018 16:15

moroen wrote:
Monday 01 October 2018 21:47
Stimpy68 wrote:
Monday 01 October 2018 13:21
Hi guys, I can't get the plugin updated. I want to use the beta of Domoticz because of a bug in Hue that is fixed in the beta. But after updating domoticz to beta the Tradfri plugin stops working. Updated that to the development branch version. But now the plugin won't connect to libcoap because it broke. It won't start. Anyone else having this problem (and a solution maybe ;-) )
Hi!

The latest developmen-version introduced a new way of handling the ident/key-pair needed for DTLS, so if you're upgrading from a previous development version or from master, you need to make a couple of changes:

First, configure the adapter:

Code: Select all

domoticz/plugins/IKEA-Tradfri$ sudo systemctrl stop domoticz
domoticz/plugins/IKEA-Tradfri$ sudo systemctrl stop ikea-tradfri
domoticz/plugins/IKEA-Tradfri$ ./configure.py IP GATEWAY-KEY
domoticz/plugins/IKEA-Tradfri$ sudo systemctrl start ikea-tradfri
domoticz/plugins/IKEA-Tradfri$ sudo systemctrl stop domoticz
And then you need to go to the hardware-page, select the IKEA-Tradfri plugin, and change the adapter IP-adress to point to where the adapter is running (localhost if running domoticz and the adapter on the same server).

This is documented in the readme-file of the development branch. If the instructions are unclear (which they probably are, since I'm generally rubbish at writing documentation), let me know what the sticking-points are, and I'll try to make them clearer... :shock:

Regards,
M
Thanks, Stupid me, :lol: , I didn't read the readme . Looks like its working now!

pvklink
Posts: 111
Joined: Wednesday 12 November 2014 16:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by pvklink » Wednesday 10 October 2018 17:08

HI all,

I have the latest beta from domoticz on an rpi 3b.
I bought the ikea tradfri hub and a bulb. The bulb is working via the gateway and with the latests software and app.
Now i like to use my domoticz too. Is there documentation how to install trafdri gateway on my domoticz..

I tried:
https://rutger.kirkels.nl/2018/02/01/do ... s-tradfri/

But thats not working, i get an error that coap-client does not exist.
Is there a better manual that is working!

Thanks

Stimpy68
Posts: 11
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

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

Post by Stimpy68 » Wednesday 10 October 2018 17:12

pvklink wrote:
Wednesday 10 October 2018 17:08

Is there a better manual that is working!

Thanks
This one: https://github.com/moroen/IKEA-Tradfri-plugin

But thats the same, are you using the stable or beta domoticz?

pvklink
Posts: 111
Joined: Wednesday 12 November 2014 16:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by pvklink » Wednesday 10 October 2018 17:24

mmm
It mentions that these requirements :

Requirements:
1. Domoticz compiled with support for Python-Plugins.
2 . Python library pytradfri by ggravlingen (https://github.com/ggravlingen/pytradfri). Required version: 6.0.1 or greater.
3. Twisted (https://twistedmatrix.com/trac/)
4. IKEA-Tradfri-plugin (https://github.com/moroen/IKEA-Tradfri-plugin)

i guess that i dont have to do step 1
but nr 2 and 3 dont have a clear install procedure...

I made a script install-coap-client.sh with
#!/bin/sh
git clone --depth 1 --recursive -b dtls https://github.com/home-assistant/libcoap.git
cd libcoap
./autogen.sh
./configure --disable-documentation --disable-shared --without-debug CFLAGS="-D COAP_DEBUG_FD=stderr"
make
make install

and started it with sudo ./install-coap-client.sh
and with this first command i get errors!

sudo ./install-coap-client.sh
Cloning into 'libcoap'...
remote: Enumerating objects: 138, done.
remote: Counting objects: 100% (138/138), done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 138 (delta 9), reused 58 (delta 9), pack-reused 0
Receiving objects: 100% (138/138), 235.93 KiB | 0 bytes/s, done.
Resolving deltas: 100% (9/9), done.
Submodule 'ext/tinydtls' (https://git.eclipse.org/r/tinydtls/org.eclipse.tinydtls) registered for path 'ext/tinydtls'
Cloning into '/home/pi/domoticz/plugins/IKEA-Tradfri/IKEA-Tradfri/libcoap/ext/tinydtls'...
remote: Total 539 (delta 0), reused 539 (delta 0) B/s
Receiving objects: 100% (539/539), 528.02 KiB | 281.00 KiB/s, done.
Resolving deltas: 100% (235/235), done.
Submodule path 'ext/tinydtls': checked out 'cc5863fa0e438ba1fa46c05f2a27cd8dd3d85b96'

[HINT] You can run 'autogen.sh --clean' to remove all generated files by the autotools.


Couldn't find 'autoconf'!
You probably need to install the package 'autoconf'.

Couldn't find 'aclocal'!
You probably need to install the package 'automake'.

Couldn't find 'libtool'!

Couldn't find 'libtoolize'!
You probably need to install the package 'libtool'.

One or more needed tools are missing, exiting ...
Please install the needed software packages and restart 'autogen.sh' again.

./install-coap-client.sh: 5: ./install-coap-client.sh: ./configure: not found
make: *** Geen doelen opgegeven en geen Makefile gevonden. Gestopt.
make: *** Er is geen regel om doel 'install' te maken. Gestopt.
pi@RPI_DOM:~/domoticz/plugins/IKEA-Tradfri/IKEA-Tradfri $

Stimpy68
Posts: 11
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

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

Post by Stimpy68 » Wednesday 10 October 2018 17:34

pvklink wrote:
Wednesday 10 October 2018 17:24

Couldn't find 'autoconf'!
You probably need to install the package 'autoconf'.

Couldn't find 'aclocal'!
You probably need to install the package 'automake'.

Couldn't find 'libtool'!

Couldn't find 'libtoolize'!
You probably need to install the package 'libtool'.

One or more needed tools are missing, exiting ...
Please install the needed software packages and restart 'autogen.sh' again.

./install-coap-client.sh: 5: ./install-coap-client.sh: ./configure: not found
make: *** Geen doelen opgegeven en geen Makefile gevonden. Gestopt.
make: *** Er is geen regel om doel 'install' te maken. Gestopt.
pi@RPI_DOM:~/domoticz/plugins/IKEA-Tradfri/IKEA-Tradfri $
Heb je die pakketten ook geinstalleerd zoals aangegeven? Die heeft ie nodig om make te gebruiken als ik het mij goed herinner.
Did you install the packages as mentioned in the logs?

pvklink
Posts: 111
Joined: Wednesday 12 November 2014 16:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by pvklink » Wednesday 10 October 2018 21:58

My procedure

see my problems above with https://github.com/ggravlingen/pytradfri

$ git clone https://github.com/ggravlingen/pytradfri.git
$ cd pytradfri
$ sudo python3 setup.py install
$ sudo pip3 install twisted
$ cd /home/pi/domoticz/plugins
$ git clone https://github.com/moroen/IKEA-Tradfri-plugin.git IKEA-Tradfri

$ coap-client -m post -u "Client_identity" -k “xxxxx” -e '{"9090":"TRADFRI_1"}' "coaps://IP:xxxxxxxx"
-bash: coap-client: opdracht niet gevonden

User avatar
heggink
Posts: 581
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

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

Post by heggink » Wednesday 10 October 2018 22:06

You need to install libcoap. Follow the instructions in the file called building.
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

mdenouden
Posts: 5
Joined: Sunday 23 August 2015 10:52
Target OS: Raspberry Pi
Domoticz version: beta
Location: Netherlands
Contact:

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

Post by mdenouden » Friday 12 October 2018 11:15

Hi all!

Have been using the plugin for about a week now, after installing it according to the manual on Github and tips in this thread. Although it's running fine, I'm getting these errors when starting Domoticz:

2018-10-12 11:05:43.934 Status: (Tradfri) Initialized version 1.0.6, author 'moroen'
2018-10-12 11:05:45.125 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState
2018-10-12 11:05:45.125 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


Not a big thing I guess, because I can't find any reduction in functionality. The lamps react correctly and changes from the Tradfri app replicate within the time-out I setup in Domoticz:

2018-10-12 11:06:15.047 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/On)
2018-10-12 11:06:17.324 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/Off)
2018-10-12 11:06:18.579 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/On)
2018-10-12 11:06:21.981 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/Set Level)
2018-10-12 11:06:32.026 Status: Incoming connection from: 127.0.0.1


Any ideas??

ps: running development branch on beta-version of Domoticz.

moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen » Friday 12 October 2018 12:19

mdenouden wrote:
Friday 12 October 2018 11:15
Hi all!

Have been using the plugin for about a week now, after installing it according to the manual on Github and tips in this thread. Although it's running fine, I'm getting these errors when starting Domoticz:

2018-10-12 11:05:43.934 Status: (Tradfri) Initialized version 1.0.6, author 'moroen'
2018-10-12 11:05:45.125 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState
2018-10-12 11:05:45.125 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 11:05:45.125 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


Not a big thing I guess, because I can't find any reduction in functionality. The lamps react correctly and changes from the Tradfri app replicate within the time-out I setup in Domoticz:

2018-10-12 11:06:15.047 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/On)
2018-10-12 11:06:17.324 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/Off)
2018-10-12 11:06:18.579 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/On)
2018-10-12 11:06:21.981 Status: User: Admin initiated a switch command (9/Tradfri - Lamp hal/Set Level)
2018-10-12 11:06:32.026 Status: Incoming connection from: 127.0.0.1


Any ideas??

ps: running development branch on beta-version of Domoticz.
Interesting... Just to make sure that I have understood this correctly: Do the "Error: (Tradfri) 'onMessage' failed 'KeyError'" only occure when starting domoticz, or do you also see them during use? Do you have any of the new Ikea outlets added to the gateway?

Regards,
M

mdenouden
Posts: 5
Joined: Sunday 23 August 2015 10:52
Target OS: Raspberry Pi
Domoticz version: beta
Location: Netherlands
Contact:

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

Post by mdenouden » Friday 12 October 2018 13:54

Interesting... Just to make sure that I have understood this correctly: Do the "Error: (Tradfri) 'onMessage' failed 'KeyError'" only occure when starting domoticz, or do you also see them during use? Do you have any of the new Ikea outlets added to the gateway?

Regards,
M
So far it's only on initialization, when (re)starting Domoticz.

At the moment it's three LED lights with one motion sensor. Haven't bought the new outlets yet.

mdenouden
Posts: 5
Joined: Sunday 23 August 2015 10:52
Target OS: Raspberry Pi
Domoticz version: beta
Location: Netherlands
Contact:

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

Post by mdenouden » Friday 12 October 2018 14:04

mdenouden wrote:
Friday 12 October 2018 13:54
Interesting... Just to make sure that I have understood this correctly: Do the "Error: (Tradfri) 'onMessage' failed 'KeyError'" only occure when starting domoticz, or do you also see them during use? Do you have any of the new Ikea outlets added to the gateway?

Regards,
M
So far it's only on initialization, when (re)starting Domoticz.

At the moment it's three LED lights with one motion sensor. Haven't bought the new outlets yet.
Sorry, answered to soon, did some testing shortly after the above reply. The error also logged when I change the state of one of the lamps via the Tradfri app:

2018-10-12 13:57:56.513 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


The state of the lamp DOES update correctly in Domoticz. So the polling works.

Further research showed that the error occurred because I set 'Add groups as devices' to 'Yes' in the plugin configuration. After switching that off there's no error anymore. Does that make sense?

moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen » Friday 12 October 2018 14:10

mdenouden wrote:
Friday 12 October 2018 14:04
mdenouden wrote:
Friday 12 October 2018 13:54
Interesting... Just to make sure that I have understood this correctly: Do the "Error: (Tradfri) 'onMessage' failed 'KeyError'" only occure when starting domoticz, or do you also see them during use? Do you have any of the new Ikea outlets added to the gateway?

Regards,
M
So far it's only on initialization, when (re)starting Domoticz.

At the moment it's three LED lights with one motion sensor. Haven't bought the new outlets yet.
Sorry, answered to soon, did some testing shortly after the above reply. The error also logged when I change the state of one of the lamps via the Tradfri app:

2018-10-12 13:57:56.513 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


The state of the lamp DOES update correctly in Domoticz. So the polling works.

Further research showed that the error occurred because I set 'Add groups as devices' to 'Yes' in the plugin configuration. After switching that off there's no error anymore. Does that make sense?
Could you please set debug to true, and post the log including lines before and after this error message?

mdenouden
Posts: 5
Joined: Sunday 23 August 2015 10:52
Target OS: Raspberry Pi
Domoticz version: beta
Location: Netherlands
Contact:

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

Post by mdenouden » Friday 12 October 2018 14:32

moroen wrote:
Friday 12 October 2018 14:10
mdenouden wrote:
Friday 12 October 2018 14:04
mdenouden wrote:
Friday 12 October 2018 13:54


So far it's only on initialization, when (re)starting Domoticz.

At the moment it's three LED lights with one motion sensor. Haven't bought the new outlets yet.
Sorry, answered to soon, did some testing shortly after the above reply. The error also logged when I change the state of one of the lamps via the Tradfri app:

2018-10-12 13:57:56.513 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


The state of the lamp DOES update correctly in Domoticz. So the polling works.

Further research showed that the error occurred because I set 'Add groups as devices' to 'Yes' in the plugin configuration. After switching that off there's no error anymore. Does that make sense?
Could you please set debug to true, and post the log including lines before and after this error message?
2018-10-12 14:30:53.103 Status: (Tradfri) Started.
2018-10-12 14:30:53.289 Status: (Tradfri) Entering work loop.
2018-10-12 14:30:53.289 Status: (Tradfri) Initialized version 1.0.6, author 'moroen'
2018-10-12 14:30:55.048 (Tradfri) 7b 22 61 63 74 69 6f 6e 22 3a 20 22 67 65 74 4c 69 67 68 74 {"action":."getLight
2018-10-12 14:30:55.048 (Tradfri) 73 22 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. s"}
2018-10-12 14:30:55.054 (Tradfri) Pushing 'ReadEvent' on to queue
2018-10-12 14:30:55.099 (Tradfri) Processing 'ReadEvent' message
2018-10-12 14:30:55.099 (Tradfri) Received 1258 bytes of data
2018-10-12 14:30:55.099 (Tradfri) 7b 22 72 65 73 75 6c 74 22 3a 20 5b 7b 22 4e 61 6d 65 22 3a {"result":.[{"Name":
2018-10-12 14:30:55.099 (Tradfri) 20 22 4c 61 6d 70 20 68 61 6c 22 2c 20 22 54 79 70 65 22 3a ."Lamp.hal",."Type":
2018-10-12 14:30:55.099 (Tradfri) 20 22 4c 69 67 68 74 22 2c 20 22 44 69 6d 6d 61 62 6c 65 22 ."Light",."Dimmable"
2018-10-12 14:30:55.099 (Tradfri) 3a 20 74 72 75 65 2c 20 22 48 61 73 57 42 22 3a 20 66 61 6c :.true,."HasWB":.fal
2018-10-12 14:30:55.099 (Tradfri) 73 65 2c 20 22 44 65 76 69 63 65 49 44 22 3a 20 36 35 35 33 se,."DeviceID":.6553
2018-10-12 14:30:55.099 (Tradfri) 37 2c 20 22 48 61 73 52 47 42 22 3a 20 66 61 6c 73 65 7d 2c 7,."HasRGB":.false},
2018-10-12 14:30:55.099 (Tradfri) 20 7b 22 4e 61 6d 65 22 3a 20 22 46 69 6c 6d 6c 61 6d 70 22 .{"Name":."Filmlamp"
2018-10-12 14:30:55.099 (Tradfri) 2c 20 22 54 79 70 65 22 3a 20 22 4c 69 67 68 74 22 2c 20 22 ,."Type":."Light",."
2018-10-12 14:30:55.099 (Tradfri) 44 69 6d 6d 61 62 6c 65 22 3a 20 74 72 75 65 2c 20 22 48 61 Dimmable":.true,."Ha
2018-10-12 14:30:55.099 (Tradfri) 73 57 42 22 3a 20 66 61 6c 73 65 2c 20 22 44 65 76 69 63 65 sWB":.false,."Device
2018-10-12 14:30:55.100 (Tradfri) 49 44 22 3a 20 36 35 35 33 38 2c 20 22 48 61 73 52 47 42 22 ID":.65538,."HasRGB"
2018-10-12 14:30:55.100 (Tradfri) 3a 20 66 61 6c 73 65 7d 2c 20 7b 22 4e 61 6d 65 22 3a 20 22 :.false},.{"Name":."
2018-10-12 14:30:55.100 (Tradfri) 4c 61 6d 70 20 62 6f 76 65 6e 20 64 65 20 74 61 66 65 6c 22 Lamp.boven.de.tafel"
2018-10-12 14:30:55.100 (Tradfri) 2c 20 22 54 79 70 65 22 3a 20 22 4c 69 67 68 74 22 2c 20 22 ,."Type":."Light",."
2018-10-12 14:30:55.100 (Tradfri) 44 69 6d 6d 61 62 6c 65 22 3a 20 74 72 75 65 2c 20 22 48 61 Dimmable":.true,."Ha
2018-10-12 14:30:55.100 (Tradfri) 73 57 42 22 3a 20 74 72 75 65 2c 20 22 44 65 76 69 63 65 49 sWB":.true,."DeviceI
2018-10-12 14:30:55.100 (Tradfri) 44 22 3a 20 36 35 35 33 39 2c 20 22 48 61 73 52 47 42 22 3a D":.65539,."HasRGB":
2018-10-12 14:30:55.100 (Tradfri) 20 66 61 6c 73 65 7d 2c 20 7b 22 4e 61 6d 65 22 3a 20 22 47 .false},.{"Name":."G
2018-10-12 14:30:55.100 (Tradfri) 72 6f 75 70 20 2d 20 57 6f 6f 6e 6b 61 6d 65 72 22 2c 20 22 roup.-.Woonkamer",."
2018-10-12 14:30:55.100 (Tradfri) 54 79 70 65 22 3a 20 22 47 72 6f 75 70 22 2c 20 22 44 69 6d Type":."Group",."Dim
2018-10-12 14:30:55.100 (Tradfri) 6d 61 62 6c 65 22 3a 20 74 72 75 65 2c 20 22 48 61 73 57 42 mable":.true,."HasWB
2018-10-12 14:30:55.100 (Tradfri) 22 3a 20 66 61 6c 73 65 2c 20 22 44 65 76 69 63 65 49 44 22 ":.false,."DeviceID"
2018-10-12 14:30:55.100 (Tradfri) 3a 20 31 33 31 30 37 34 7d 2c 20 7b 22 4e 61 6d 65 22 3a 20 :.131074},.{"Name":.
2018-10-12 14:30:55.101 (Tradfri) 22 47 72 6f 75 70 20 2d 20 48 61 6c 22 2c 20 22 54 79 70 65 "Group.-.Hal",."Type
2018-10-12 14:30:55.101 (Tradfri) 22 3a 20 22 47 72 6f 75 70 22 2c 20 22 44 69 6d 6d 61 62 6c ":."Group",."Dimmabl
2018-10-12 14:30:55.101 (Tradfri) 65 22 3a 20 74 72 75 65 2c 20 22 48 61 73 57 42 22 3a 20 66 e":.true,."HasWB":.f
2018-10-12 14:30:55.101 (Tradfri) 61 6c 73 65 2c 20 22 44 65 76 69 63 65 49 44 22 3a 20 31 33 alse,."DeviceID":.13
2018-10-12 14:30:55.101 (Tradfri) 31 30 37 37 7d 5d 2c 20 22 73 74 61 74 75 73 22 3a 20 22 4f 1077}],."status":."O
2018-10-12 14:30:55.101 (Tradfri) 6b 22 2c 20 22 61 63 74 69 6f 6e 22 3a 20 22 67 65 74 4c 69 k",."action":."getLi
2018-10-12 14:30:55.101 (Tradfri) 67 68 74 73 22 7d 7b 22 72 65 73 75 6c 74 22 3a 20 5b 7b 22 ghts"}{"result":.[{"
2018-10-12 14:30:55.101 (Tradfri) 4e 61 6d 65 22 3a 20 22 4c 61 6d 70 20 68 61 6c 22 2c 20 22 Name":."Lamp.hal",."
2018-10-12 14:30:55.101 (Tradfri) 4c 65 76 65 6c 22 3a 20 32 35 34 2c 20 22 53 74 61 74 65 22 Level":.254,."State"
2018-10-12 14:30:55.101 (Tradfri) 3a 20 66 61 6c 73 65 2c 20 22 44 65 76 69 63 65 49 44 22 3a :.false,."DeviceID":
2018-10-12 14:30:55.101 (Tradfri) 20 36 35 35 33 37 2c 20 22 48 65 78 22 3a 20 6e 75 6c 6c 7d .65537,."Hex":.null}
2018-10-12 14:30:55.101 (Tradfri) 5d 2c 20 22 73 74 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 ],."status":."Ok",."
2018-10-12 14:30:55.101 (Tradfri) 61 63 74 69 6f 6e 22 3a 20 22 64 65 76 69 63 65 55 70 64 61 action":."deviceUpda
2018-10-12 14:30:55.101 (Tradfri) 74 65 22 7d 7b 22 72 65 73 75 6c 74 22 3a 20 5b 7b 22 4e 61 te"}{"result":.[{"Na
2018-10-12 14:30:55.102 (Tradfri) 6d 65 22 3a 20 22 46 69 6c 6d 6c 61 6d 70 22 2c 20 22 4c 65 me":."Filmlamp",."Le
2018-10-12 14:30:55.102 (Tradfri) 76 65 6c 22 3a 20 31 32 37 2c 20 22 53 74 61 74 65 22 3a 20 vel":.127,."State":.
2018-10-12 14:30:55.102 (Tradfri) 66 61 6c 73 65 2c 20 22 44 65 76 69 63 65 49 44 22 3a 20 36 false,."DeviceID":.6
2018-10-12 14:30:55.102 (Tradfri) 35 35 33 38 2c 20 22 48 65 78 22 3a 20 6e 75 6c 6c 7d 5d 2c 5538,."Hex":.null}],
2018-10-12 14:30:55.102 (Tradfri) 20 22 73 74 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 ."status":."Ok",."ac
2018-10-12 14:30:55.102 (Tradfri) 74 69 6f 6e 22 3a 20 22 64 65 76 69 63 65 55 70 64 61 74 65 tion":."deviceUpdate
2018-10-12 14:30:55.102 (Tradfri) 22 7d 7b 22 72 65 73 75 6c 74 22 3a 20 5b 7b 22 4e 61 6d 65 "}{"result":.[{"Name
2018-10-12 14:30:55.102 (Tradfri) 22 3a 20 22 4c 61 6d 70 20 62 6f 76 65 6e 20 64 65 20 74 61 ":."Lamp.boven.de.ta
2018-10-12 14:30:55.102 (Tradfri) 66 65 6c 22 2c 20 22 4c 65 76 65 6c 22 3a 20 32 35 34 2c 20 fel",."Level":.254,.
2018-10-12 14:30:55.102 (Tradfri) 22 53 74 61 74 65 22 3a 20 66 61 6c 73 65 2c 20 22 44 65 76 "State":.false,."Dev
2018-10-12 14:30:55.102 (Tradfri) 69 63 65 49 44 22 3a 20 36 35 35 33 39 2c 20 22 48 65 78 22 iceID":.65539,."Hex"
2018-10-12 14:30:55.102 (Tradfri) 3a 20 22 66 31 65 30 62 35 22 7d 5d 2c 20 22 73 74 61 74 75 :."f1e0b5"}],."statu
2018-10-12 14:30:55.102 (Tradfri) 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 74 69 6f 6e 22 3a 20 s":."Ok",."action":.
2018-10-12 14:30:55.102 (Tradfri) 22 64 65 76 69 63 65 55 70 64 61 74 65 22 7d 7b 22 72 65 73 "deviceUpdate"}{"res
2018-10-12 14:30:55.103 (Tradfri) 75 6c 74 22 3a 20 5b 7b 22 4e 61 6d 65 22 3a 20 22 57 6f 6f ult":.[{"Name":."Woo
2018-10-12 14:30:55.103 (Tradfri) 6e 6b 61 6d 65 72 22 2c 20 22 4c 65 76 65 6c 22 3a 20 30 2c nkamer",."Level":.0,
2018-10-12 14:30:55.103 (Tradfri) 20 22 53 74 61 74 65 22 3a 20 66 61 6c 73 65 2c 20 22 44 65 ."State":.false,."De
2018-10-12 14:30:55.103 (Tradfri) 76 69 63 65 49 44 22 3a 20 31 33 31 30 37 34 7d 5d 2c 20 22 viceID":.131074}],."
2018-10-12 14:30:55.103 (Tradfri) 73 74 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 74 69 status":."Ok",."acti
2018-10-12 14:30:55.103 (Tradfri) 6f 6e 22 3a 20 22 64 65 76 69 63 65 55 70 64 61 74 65 22 7d on":."deviceUpdate"}
2018-10-12 14:30:55.103 (Tradfri) 7b 22 72 65 73 75 6c 74 22 3a 20 5b 7b 22 4e 61 6d 65 22 3a {"result":.[{"Name":
2018-10-12 14:30:55.103 (Tradfri) 20 22 48 61 6c 22 2c 20 22 4c 65 76 65 6c 22 3a 20 30 2c 20 ."Hal",."Level":.0,.
2018-10-12 14:30:55.103 (Tradfri) 22 53 74 61 74 65 22 3a 20 74 72 75 65 2c 20 22 44 65 76 69 "State":.true,."Devi
2018-10-12 14:30:55.103 (Tradfri) 63 65 49 44 22 3a 20 31 33 31 30 37 37 7d 5d 2c 20 22 73 74 ceID":.131077}],."st
2018-10-12 14:30:55.103 (Tradfri) 61 74 75 73 22 3a 20 22 4f 6b 22 2c 20 22 61 63 74 69 6f 6e atus":."Ok",."action
2018-10-12 14:30:55.103 (Tradfri) 22 3a 20 22 64 65 76 69 63 65 55 70 64 61 74 65 22 7d .. .. ":."deviceUpdate"}
2018-10-12 14:30:55.104 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.104 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.104 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.104 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.105 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.105 (Tradfri) Pushing 'onMessageCallback' on to queue
2018-10-12 14:30:55.105 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.105 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.106 (Tradfri) Registering: {"Name": "Lamp hal", "Dimmable": "true", "HasRGB": "false", "Type": "Light", "DeviceID": 65537, "HasWB": "false"}
2018-10-12 14:30:55.106 (Tradfri) Registering: {"Name": "Filmlamp", "Dimmable": "true", "HasRGB": "false", "Type": "Light", "DeviceID": 65538, "HasWB": "false"}
2018-10-12 14:30:55.106 (Tradfri) Registering: {"Name": "Lamp boven de tafel", "Dimmable": "true", "HasRGB": "false", "Type": "Light", "DeviceID": 65539, "HasWB": "true"}
2018-10-12 14:30:55.107 (Tradfri) Registering: {"Name": "Group - Woonkamer", "Type": "Group", "DeviceID": 131074, "Dimmable": "true", "HasWB": "false"}
2018-10-12 14:30:55.107 (Tradfri) Registering: {"Name": "Group - Hal", "Type": "Group", "DeviceID": 131077, "Dimmable": "true", "HasWB": "false"}
2018-10-12 14:30:55.107 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.107 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.107 (Tradfri) {'Name': 'Lamp hal', 'DeviceID': 65537, 'Level': 254, 'Hex': '', 'State': 'false'}
2018-10-12 14:30:55.107 (Tradfri - Lamp hal) Updating device from 0:'101' to have values 0:'101'.
2018-10-12 14:30:55.114 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.114 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.114 (Tradfri) {'Name': 'Filmlamp', 'DeviceID': 65538, 'Level': 127, 'Hex': '', 'State': 'false'}
2018-10-12 14:30:55.115 (Tradfri - Filmlamp) Updating device from 0:'50' to have values 0:'50'.
2018-10-12 14:30:55.121 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.121 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.122 (Tradfri) {'Name': 'Lamp boven de tafel', 'DeviceID': 65539, 'Level': 254, 'Hex': 'f1e0b5', 'State': 'false'}
2018-10-12 14:30:55.122 (Tradfri - Lamp boven de tafel) Updating device from 0:'101' to have values 0:'101'.
2018-10-12 14:30:55.128 (Tradfri - Lamp boven de tafel - WB) Updating device from 0:'20' to have values 0:'20'.
2018-10-12 14:30:55.136 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.136 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.136 (Tradfri) {'Name': 'Woonkamer', 'DeviceID': 131074, 'Level': 0, 'State': 'false'}
2018-10-12 14:30:55.136 (Tradfri) Processing 'onMessageCallback' message
2018-10-12 14:30:55.136 (Tradfri) Calling message handler 'onMessage'.
2018-10-12 14:30:55.136 (Tradfri) {'Name': 'Hal', 'DeviceID': 131077, 'Level': 0, 'State': 'true'}
2018-10-12 14:30:55.136 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 14:30:55.136 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 14:30:55.136 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 14:30:55.136 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState
2018-10-12 14:30:55.137 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 14:30:55.137 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 14:30:55.137 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 14:30:55.137 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState
2018-10-12 14:31:03.290 (Tradfri) Pushing 'onHeartbeatCallback' on to queue
2018-10-12 14:31:03.302 (Tradfri) Processing 'onHeartbeatCallback' message
2018-10-12 14:31:03.302 (Tradfri) Calling message handler 'onHeartbeat'.

moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen » Friday 12 October 2018 14:52

mdenouden wrote:
Friday 12 October 2018 14:32
moroen wrote:
Friday 12 October 2018 14:10
mdenouden wrote:
Friday 12 October 2018 14:04


Sorry, answered to soon, did some testing shortly after the above reply. The error also logged when I change the state of one of the lamps via the Tradfri app:

2018-10-12 13:57:56.513 Error: (Tradfri) 'onMessage' failed 'KeyError'.
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 290 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 214 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function onMessage
2018-10-12 13:57:56.513 Error: (Tradfri) ----> Line 131 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py', function updateDeviceState


The state of the lamp DOES update correctly in Domoticz. So the polling works.

Further research showed that the error occurred because I set 'Add groups as devices' to 'Yes' in the plugin configuration. After switching that off there's no error anymore. Does that make sense?
Could you please set debug to true, and post the log including lines before and after this error message?
2018-10-12 14:30:53.103 Status: (Tradfri) Started.
2018-10-12 14:30:53.289 Status: (Tradfri) Entering work loop.
Thank you!

I think I've found the bug, but I'm currently at work, so I'm not able to fix it right now... I'll fix this as soon as possible, and post here when a new version is commited to github!

Regards,
M

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests