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

Python and python framework

Moderator: leecollings

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

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

Post by moroen »

jeroenze wrote: Saturday 12 October 2019 17:35 Hi! Also from the NL and starting with Domoticz, however with a little bit of Linux knowledge... but your manual is pretty good to follow.

I have installed everything and I also get response from the Tradfri gateway & it displays as a plugin in the Domoticz interface. However it doesn't list any devices.

In the debug via ssh it says the following:

Code: Select all

(myvenv) pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8086
ERROR:Task exception was never retrieved
future: <Task finished coro=<tcp_server.main() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py:244> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 1235): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py", line 249, in main
    self.handle_echo, hostConfig["Server_ip"], hostConfig["Tcp_port"]
  File "/usr/lib/python3.7/asyncio/streams.py", line 114, in start_server
    return await loop.create_server(factory, host, port, **kwds)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 1235): address already in use
ERROR:Task exception was never retrieved
future: <Task finished coro=<start() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py:18> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 8086): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py", line 38, in start
    await site.start()
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/aiohttp/web_runner.py", line 102, in start
    reuse_port=self._reuse_port)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 8086): address already in use
As you can see I already tried to change the ports to have it working, but that did not solve the issue.
As far as I can tell, it fails because the ports are in use. Are you sure you dont't have the adapter already running as a service? And alas, as of yet, changing the ports of the adapter fails on the plugin side, unless you also have changed the port-number in plugin.py?

Regards,
M
jeroenze
Posts: 5
Joined: Saturday 12 October 2019 17:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by jeroenze »

moroen wrote: Saturday 12 October 2019 19:43
jeroenze wrote: Saturday 12 October 2019 17:35 Hi! Also from the NL and starting with Domoticz, however with a little bit of Linux knowledge... but your manual is pretty good to follow.

I have installed everything and I also get response from the Tradfri gateway & it displays as a plugin in the Domoticz interface. However it doesn't list any devices.

In the debug via ssh it says the following:

Code: Select all

(myvenv) pi@domoticz:~/domoticz/plugins/IKEA-Tradfri $ tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8086
ERROR:Task exception was never retrieved
future: <Task finished coro=<tcp_server.main() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py:244> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 1235): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py", line 249, in main
    self.handle_echo, hostConfig["Server_ip"], hostConfig["Tcp_port"]
  File "/usr/lib/python3.7/asyncio/streams.py", line 114, in start_server
    return await loop.create_server(factory, host, port, **kwds)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 1235): address already in use
ERROR:Task exception was never retrieved
future: <Task finished coro=<start() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py:18> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 8086): address already in use")>
Traceback (most recent call last):
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py", line 38, in start
    await site.start()
  File "/home/pi/domoticz/plugins/IKEA-Tradfri/myvenv/lib/python3.7/site-packages/aiohttp/web_runner.py", line 102, in start
    reuse_port=self._reuse_port)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
    % (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 8086): address already in use
As you can see I already tried to change the ports to have it working, but that did not solve the issue.
As far as I can tell, it fails because the ports are in use. Are you sure you dont't have the adapter already running as a service? And alas, as of yet, changing the ports of the adapter fails on the plugin side, unless you also have changed the port-number in plugin.py?

Regards,
M
Reinstalled the Buster Lite OS again, did an install of the Domoticz and then your plugin. But still the same error.

Before I did the tradfri service create, the debug said:
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234

After creating the service it then gave those errors again (address already in use).

FYI: Using a Pi 4 with Raspberry Lite
peerkersezuuker
Posts: 70
Joined: Monday 14 December 2015 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Mierlo
Contact:

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

Post by peerkersezuuker »

Hi Jeroenze
Maybe you could run

Code: Select all

sudo lsof -i -P -n |grep LISTEN
The you get a list of services and at which port they are listening.
So you can determine who is on which port.

Regards Peer
jeroenze
Posts: 5
Joined: Saturday 12 October 2019 17:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by jeroenze »

peerkersezuuker wrote: Sunday 13 October 2019 9:48 Hi Jeroenze
Maybe you could run

Code: Select all

sudo lsof -i -P -n |grep LISTEN
The you get a list of services and at which port they are listening.
So you can determine who is on which port.

Regards Peer
Hi Peerkersezuuker, did that, but the only one which shows up on the same ports is the tradfri service:
pi@raspberrypi:~ $ sudo lsof -i -P -n |grep LISTEN
tradfri 339 pi 6u IPv4 12697 0t0 TCP 127.0.0.1:1234 (LISTEN)
tradfri 339 pi 7u IPv4 12698 0t0 TCP 127.0.0.1:8085 (LISTEN)
sshd 516 root 3u IPv4 13752 0t0 TCP *:22 (LISTEN)
sshd 516 root 4u IPv6 13754 0t0 TCP *:22 (LISTEN)
domoticz 517 root 16u IPv6 13242 0t0 TCP *:8080 (LISTEN)
domoticz 517 root 23u IPv6 13249 0t0 TCP *:443 (LISTEN)
domoticz 517 root 30u IPv6 13258 0t0 TCP *:6144 (LISTEN)
And this is the current error log:
(env) pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
ERROR:Task exception was never retrieved
future: <Task finished coro=<tcp_server.main() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py:244> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 1234): address already in use")>
Traceback (most recent call last):
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/tcp_server.py", line 249, in main
self.handle_echo, hostConfig["Server_ip"], hostConfig["Tcp_port"]
File "/usr/lib/python3.7/asyncio/streams.py", line 114, in start_server
return await loop.create_server(factory, host, port, **kwds)
File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
% (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 1234): address already in use
ERROR:Task exception was never retrieved
future: <Task finished coro=<start() done, defined at /home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py:18> exception=OSError(98, "error while attempting to bind on address ('127.0.0.1', 8085): address already in use")>
Traceback (most recent call last):
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/http_server.py", line 38, in start
await site.start()
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/aiohttp/web_runner.py", line 102, in start
reuse_port=self._reuse_port)
File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
% (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('127.0.0.1', 8085): address already in use
peerkersezuuker
Posts: 70
Joined: Monday 14 December 2015 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Mierlo
Contact:

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

Post by peerkersezuuker »

So it seems tradfri is already running.
What is the output of :

Code: Select all

ps -Al |grep tradfri

Code: Select all

systemctl status ikea-tradfri.service

Code: Select all

ls -Ral /etc/systemd |grep ikea
And how is your plugin configured ?
Here is a screenshot of mine :
Image

Peer
jeroenze
Posts: 5
Joined: Saturday 12 October 2019 17:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by jeroenze »

peerkersezuuker wrote: Sunday 13 October 2019 12:33 So it seems tradfri is already running.
What is the output of :

Code: Select all

ps -Al |grep tradfri

Code: Select all

systemctl status ikea-tradfri.service

Code: Select all

ls -Ral /etc/systemd |grep ikea
And how is your plugin configured ?
Here is a screenshot of mine :
Image

Peer

Code: Select all

ps -Al |grep tradfri
4 S  1000   317     1  0  80   0 -  7864 do_epo ?        00:00:01 tradfri

Code: Select all

systemctl status ikea-tradfri.service
ikea-tradfri.service - IKEA Tradfri COAP-adapter
   Loaded: loaded (/etc/systemd/system/ikea-tradfri.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-10-13 12:32:54 BST; 3min 11s ago
 Main PID: 317 (tradfri)
    Tasks: 1 (limit: 1599)
   Memory: 27.3M
   CGroup: /system.slice/ikea-tradfri.service
           └─317 /home/pi/domoticz/plugins/IKEA-Tradfri/env/bin/python3 /home/pi/domoticz/plugins/IKEA-Tradfri/env/bin/tradfri server

Oct 13 12:32:54 raspberrypi systemd[1]: Started IKEA Tradfri COAP-adapter.
Oct 13 12:32:56 raspberrypi tradfri[317]: INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
Oct 13 12:32:56 raspberrypi tradfri[317]: INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234

Code: Select all

ls -Ral /etc/systemd |grep ikea
-rw-r--r--  1 root root  213 Oct 13 12:32 ikea-tradfri.service
lrwxrwxrwx  1 root root   40 Oct 13 12:32 ikea-tradfri.service -> /etc/systemd/system/ikea-tradfri.service
And somehow the plugin is now gone from the Domoticz hardware list ... really don't have a clue what's happening here....
peerkersezuuker
Posts: 70
Joined: Monday 14 December 2015 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Mierlo
Contact:

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

Post by peerkersezuuker »

Hi Jeroenze,
could you add the plugin in your hardware page and configure it.
First set the domoticz server to accept new hardware/devices
In Setup, Settings set appropriate switch to green :
Image
And then press "Apply Settings" at the top of the page.
Image



And I figured out the errors you are getting when you run the command " tradfri -vv server"
This tries to run the server interactive, so starting to bind to the ports and spit out logging.
Since you already have the ikea-tradfri.service service running as a service this results in the errors because the ports are already bind to the service.

Gr. Peer
jeroenze
Posts: 5
Joined: Saturday 12 October 2019 17:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by jeroenze »

peerkersezuuker wrote: Sunday 13 October 2019 14:16 Hi Jeroenze,
could you add the plugin in your hardware page and configure it.
First set the domoticz server to accept new hardware/devices
In Setup, Settings set appropriate switch to green :
Image
And then press "Apply Settings" at the top of the page.
Image



And I figured out the errors you are getting when you run the command " tradfri -vv server"
This tries to run the server interactive, so starting to bind to the ports and spit out logging.
Since you already have the ikea-tradfri.service service running as a service this results in the errors because the ports are already bind to the service.

Gr. Peer
Hi Peer,

Thanks for the information, that makes a lot more clear why those errors were there :lol: .

So ... I did a full reinstall of the Pi. Then installed the plugin, and then on your advice used the button to Allow for 5 Minutes. Which gave an error log with some information on what's happening! It gave the error that libpython was missing. After installing python3-dev , the device finally showed up in the hardware list!

Added the gateway and it's all working now :mrgreen: . Thanks alot all for the support!
wokkelp
Posts: 24
Joined: Monday 24 August 2015 22:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post by wokkelp »

I seem to be having a problem with the Tradfri plugin lately.
I am running the latest version of Raspbian Buster on a RPi3B+ with Domoticz V4.10717 and Python v3.7.3

I have the plugin set-up in the hardware list of Domoticz and the lights are added to my dashboard. However, pressing them doesn't do a thing anymore (I managed to switch 1 light on directly after installing). In the domoticz log I get this:
2019-10-20 12:30:11.760 Status: User: Admin initiated a switch command (207/Woonkamer 1/Off)

Whenever I go into the virtual environment and issue tradfri off <id> the light turns off. I can switch the lights this way but I'd prefer using the Domoticz gui anyway..


*Edit: I reinstalled the ikea-tradfri plugin to no avail.

**Edit: I removed the tradfri from the domoticz hardware list and surely, I no longer saw errors in the console.
Then I re-added the gateway to the domoticz hardware list and without even adding any lights into domoticz, I started getting errors again.
Below is a piece of the output.

Code: Select all

(env) pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ tradfri -vv server
INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234
INFO:Connected from ('127.0.0.1', 52786)
INFO:Received {"action": "initGateway", "observe": "False", "pollinterval": "30", "groups": "False", "battery_levels": "False"}
 from ('127.0.0.1', 52786)
INFO:Sending: b'{"action": "initGateway", "status": "Ok"}'
INFO:Received {"action": "getDevices", "groups": "False", "battery_levels": "False"}
 from ('127.0.0.1', 52786)
INFO:Sending: b'{"action": "getDevices", "status": "Ok", "result": [{"DeviceID": 65537, "Name": "Werkkamer plafond", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "0"}, {"DeviceID": 65538, "Name": "woonkamer 1", "State": true, "Level": 165, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "f1e0b5"}, {"DeviceID": 65539, "Name": "eetkamer plafond", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "0"}, {"DeviceID": 65540, "Name": "slaapkamer", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "0"}, {"DeviceID": 65541, "Name": "Berging", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "W", "Hex": null}, {"DeviceID": 65542, "Name": "werkkamer 1", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "0"}, {"DeviceID": 65543, "Name": "TRADFRI bulb 5", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "W", "Hex": null}, {"DeviceID": 65544, "Name": "Toilet plafond", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "W", "Hex": null}, {"DeviceID": 65545, "Name": "TRADFRI bulb 4", "State": true, "Level": 238, "Type": "Light", "Dimmable": true, "Colorspace": "CWS", "Hex": "f1e0b5"}, {"DeviceID": 65546, "Name": "eetkamer 2", "State": true, "Level": 139, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "efd275"}, {"DeviceID": 65548, "Name": "Gang plafond", "State": false, "Level": 0, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "0"}, {"DeviceID": 65549, "Name": "TRADFRI bulb 13", "State": true, "Level": 193, "Type": "Light", "Dimmable": true, "Colorspace": "W", "Hex": null}, {"DeviceID": 65550, "Name": "TRADFRI bulb 12", "State": false, "Level": 250, "Type": "Light", "Dimmable": true, "Colorspace": "W", "Hex": null}]}'
ERROR:Exception CancelledError() can not be represented as errno, setting -1.
^CINFO:Received signal SIGINT: exiting
INFO:Closed all running tasks!

***EDIT: So I reset the gateway and the remote to factory defaults, redid the tradfri config gateway command and hooked up the remote and 1 light.
Resut? Nada, exactly the same error message.
I guess I have ruled out the Tradfri plugin, the gateway, the remote, faulty bulbs.
Which leaves me to python3 or any other dependancy maybe?

Can anyone push me into the right direction?
CRB7
Posts: 7
Joined: Tuesday 24 November 2015 21:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post by CRB7 »

Hello,

For the same problem.

I've used successfully the plugin and I remove it.

Now I want to use it again.
I remove IKEA folder on domoticz/plugin, then replay the install manual.
plugin worked one time (all my device are back in Domoticz and now when I launch in verbose mode I have this:

Code: Select all

INFO:Starting IKEA-Tradfri HTTP server 0.2.0 on 127.0.0.1:8085
INFO:Starting IKEA-Tradfri TCP server 0.2.0 on 127.0.0.1:1234
INFO:Connected from ('127.0.0.1', 58784)
INFO:Received {"action": "initGateway", "observe": "False", "pollinterval": "30", "groups": "False", "battery_levels": "False"}
 from ('127.0.0.1', 58784)
INFO:Sending: b'{"action": "initGateway", "status": "Ok"}'
INFO:Received {"action": "getDevices", "groups": "False", "battery_levels": "False"}
 from ('127.0.0.1', 58784)
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 46 bytes cleartext
decrypt_verify(): found 230 bytes cleartext
decrypt_verify(): found 304 bytes cleartext
decrypt_verify(): found 232 bytes cleartext
decrypt_verify(): found 235 bytes cleartext
decrypt_verify(): found 301 bytes cleartext
decrypt_verify(): found 30 bytes cleartext
decrypt_verify(): found 144 bytes cleartext
decrypt_verify(): found 145 bytes cleartext
decrypt_verify(): found 232 bytes cleartext
decrypt_verify(): found 304 bytes cleartext
decrypt_verify(): found 235 bytes cleartext
decrypt_verify(): found 301 bytes cleartext
INFO:Sending: b'{"action": "getDevices", "status": "Ok", "result": [{"DeviceID": 65537, "Name": "Bureau", "State": false, "Level": 217, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "f5faf6"}, {"DeviceID": 65541, "Name": "TRADFRI bulb 3", "State": false, "Level": 124, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "efd275"}]}'
ERROR:Exception CancelledError() can not be represented as errno, setting -1.
INFO:Received {"action": "setState", "state": "Off", "deviceID": "65537", "transition_time": "10"}
 from ('127.0.0.1', 58784)
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 301 bytes cleartext
decrypt_verify(): found 8 bytes cleartext
INFO:Calling refresh for device id: 65537
decrypt_verify(): found 301 bytes cleartext
INFO:Sending: b'{"action": "setState", "status": "Ok", "result": [{"DeviceID": 65537, "Name": "Bureau", "State": false, "Level": 217, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "f5faf6"}]}'
ERROR:Exception CancelledError() can not be represented as errno, setting -1.
INFO:Received {"action": "setState", "state": "Off", "deviceID": "65537", "transition_time": "10"}
 from ('127.0.0.1', 58784)
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 301 bytes cleartext
decrypt_verify(): found 8 bytes cleartext
INFO:Calling refresh for device id: 65537
decrypt_verify(): found 301 bytes cleartext
INFO:Sending: b'{"action": "setState", "status": "Ok", "result": [{"DeviceID": 65537, "Name": "Bureau", "State": false, "Level": 217, "Type": "Light", "Dimmable": true, "Colorspace": "WS", "Hex": "f5faf6"}]}'
ERROR:Exception CancelledError() can not be represented as errno, setting -1.
Getting data from Ikea gateway seems to works but I cannot control anything.
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 »

CRB7 wrote: Friday 25 October 2019 23:43 Getting data from Ikea gateway seems to works but I cannot control anything.
Could you please provide some more context? OS? Python version? Output of pip3 list? Can you switch the lights using the tradfri command line tool?

Regards,
M
CRB7
Posts: 7
Joined: Tuesday 24 November 2015 21:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post by CRB7 »

I use it with Debian 10.1 on VMware
Python 2.7.16
Python3 3.7.3

pip3 list

Code: Select all

Package          Version      
---------------- -------------
asn1crypto       0.24.0       
attrs            19.1.0       
Automat          0.7.0        
bluepy           1.3.0        
chardet          3.0.4        
constantly       15.1.0       
cryptography     2.6.1        
entrypoints      0.3          
httplib2         0.11.3       
hyperlink        19.0.0       
idna             2.8          
incremental      17.5.0       
jsonpickle       1.2          
keyring          17.1.1       
keyrings.alt     3.1.1        
pip              19.3.1       
pycrypto         2.6.1        
pycurl           7.43.0.2     
PyGObject        3.30.4       
PyHamcrest       1.9.0        
PySimpleSOAP     1.16.2       
python-apt       1.8.4        
python-debian    0.1.35       
python-debianbts 2.8.2        
pytradfri        6.1.0        
pyxdg            0.25         
reportbug        7.5.3-deb10u1
requests         2.12.4       
SecretStorage    2.3.1        
setuptools       40.8.0       
six              1.12.0       
Twisted          19.2.1       
urllib3          1.19.1       
wheel            0.32.3       
zope.interface   4.6.0     
When I try to play with bulb with the command line it works.

I don't know if it has a interaction, but I also use Zigbee2mqtt with a zigbee key to log Xiaomi temperature sensor values

Last minute edit :

I've the error but une bulb is working.

But the state of the bulb isn't working and is false :
Fist time I click the bulb goes on but status remain off, second time bulb remain on but status goes to on, third bulb goes off but stays remain on and I have to click one more time for the state goes to off.
CRB7
Posts: 7
Joined: Tuesday 24 November 2015 21:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post by CRB7 »

I've try to install ikea plugin on a new vm (one vm for domoticz and the plugin and one with the tradfri server) but the problems avec the same.
Leeeke
Posts: 2
Joined: Tuesday 05 July 2016 19:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Leeeke »

Yesterday I installed the Ikea Plug-in without any problems.
Works great!
Thanks for the huge amount of work you put into it! :D

Grtz,
Leo
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 »

Hi all,

I would like to run my tradfri service on another machine then Domoticz, but the Tradfri service won't allow me to connect to it from a remote server.
The service is only listening on 127.0.0.1:1234

/lib/systemd/system $ sudo lsof -i -P -n |grep LISTEN
tradfri 328 pi 6u IPv4 11908 0t0 TCP 127.0.0.1:1234 (LISTEN)
tradfri 328 pi 7u IPv4 11909 0t0 TCP 127.0.0.1:8085 (LISTEN)

How can I change this so that I can connect to it from a remote server?
I can't find a config file anywhere...
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: Friday 22 November 2019 13:17 Hi all,

I would like to run my tradfri service on another machine then Domoticz, but the Tradfri service won't allow me to connect to it from a remote server.
The service is only listening on 127.0.0.1:1234

/lib/systemd/system $ sudo lsof -i -P -n |grep LISTEN
tradfri 328 pi 6u IPv4 11908 0t0 TCP 127.0.0.1:1234 (LISTEN)
tradfri 328 pi 7u IPv4 11909 0t0 TCP 127.0.0.1:8085 (LISTEN)

How can I change this so that I can connect to it from a remote server?
I can't find a config file anywhere...
I've updated the repository. On a fresh install the default configuration now listens to all ips, on a existing setup, set the service to listen to all with:

Code: Select all

./tradfri config server-ip 0.0.0.0
Note: There is no need to pull the latest changes on an existing install, just issue the command above...

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 »

Hi Morten,

This command works great! I'm now able to connect from my Synology Domoticz install to the COAP-adapter running on my RPi! And I can control my Tradfri LED panels, jay! :)

One thing though, after changing the server config you have to restart the ikea-tradfri.service before the change goes into effect.

Code: Select all

systemctl restart ikea-tradfri.service
Greetz,

·´¯`·.¸¸.·´¯`·. ( Creaky ) .·´¯`·.¸¸.·´¯ `·
iTDB
Posts: 29
Joined: Friday 29 November 2019 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Gent
Contact:

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

Post by iTDB »

I am new to Domoticz and am trying to install the Tradfri plugin.
I purchased the Tradfri last month and has the latest update.
* New install of Raspbian Buster on Pi 4B 2GB
* Update and upgrade
* Install Domoticz
So far so good.

As I see it, https://github.com/moroen/ikea-tradfri must be first installed. After that install https://github.com/moroen/IKEA-Tradfri-plugin
It goes wrong at the point "Configure the Tradfri COAP adapter"
I do the install under root "# sudo su". Otherwise I get more errors.
I am also not convinced what 'KEY' is. There is a Security Code, Home Code and I read somewhere for the MAC address / Serial Number

Code: Select all

tradfri config gateway IP KEY
I get the following error message:
Dec 06 00:05:09 ALRT 20 invalidate peer
Dec 06 00:05:09 WARN received alert, peer has been invalidated
Error in close: -1
Traceback (most recent call last):
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pytradfri-6.4.0-py3.7.egg/pytradfri/api/aiocoap_api.py", line 95, in _get_response
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/aiocoap-0.4a1-py3.7.egg/aiocoap/protocol.py", line 816, in _run_outer
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/aiocoap-0.4a1-py3.7.egg/aiocoap/protocol.py", line 865, in _run
OSError: [Errno -1] Unknown error -1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/bin/tradfri", line 4, in <module>
__import__('pkg_resources').run_script('ikeatradfri==0.0.1', 'tradfri')
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1462, in run_script
exec(code, namespace, namespace)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/EGG-INFO/scripts/tradfri", line 162, in <module>
config.handle_config_command(args)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/config.py", line 101, in handle_config_command
loop.run_until_complete(create_psk(args))
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/ikeatradfri-0.0.1-py3.7.egg/ikeatradfri/config.py", line 79, in create_psk
psk = await api_factory.generate_psk(args.KEY)
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pytradfri-6.4.0-py3.7.egg/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pytradfri-6.4.0-py3.7.egg/pytradfri/api/aiocoap_api.py", line 155, in request
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pytradfri-6.4.0-py3.7.egg/pytradfri/api/aiocoap_api.py", line 146, in _execute
File "/home/pi/domoticz/plugins/IKEA-Tradfri/env/lib/python3.7/site-packages/pytradfri-6.4.0-py3.7.egg/pytradfri/api/aiocoap_api.py", line 106, in _get_response
pytradfri.error.ServerError: ('There was an error with the request.', OSError(-1, 'Unknown error -1'))
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

iTDB wrote: Friday 06 December 2019 0:35 I am new to Domoticz and am trying to install the Tradfri plugin.
I purchased the Tradfri last month and has the latest update.
* New install of Raspbian Buster on Pi 4B 2GB
* Update and upgrade
* Install Domoticz
So far so good.

As I see it, https://github.com/moroen/ikea-tradfri must be first installed. After that install https://github.com/moroen/IKEA-Tradfri-plugin
It goes wrong at the point "Configure the Tradfri COAP adapter"
I do the install under root "# sudo su". Otherwise I get more errors.
I am also not convinced what 'KEY' is. There is a Security Code, Home Code and I read somewhere for the MAC address / Serial Number
If your starting a fresh install of the IKEA-tradfri plugin, I would recommend trying out the "new" plugin-version. It's easier to install and most importantly, doesn't require running a tradfri service. It also works on Windows. Please check out the readme in the pycoap branch for instructions!

The KEY is the security code printed on the label on the bottom of the gateway.

Regards,
M
iTDB
Posts: 29
Joined: Friday 29 November 2019 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Gent
Contact:

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

Post by iTDB »

moroen wrote: Friday 06 December 2019 1:09 I would recommend trying out the "new" plugin-version. It's easier to install and most importantly, doesn't require running a tradfri service.
So /moroen/IKEA-Tradfri-plugin is not the newest plugin? Where can I find the new one?
Thx
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest