Page 16 of 48

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

Posted: Tuesday 21 August 2018 13:22
by moroen
Philos31 wrote: Tuesday 21 August 2018 10:18 Hi, I am allready busy for 2 days to get this working.
Everything seems ok, but there is something strange going on.
In the domoticz log I see:

Code: Select all

2018-08-21 10:04:21.915 Error: (Tradfri) ----> Line 280 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-21 10:04:21.915 Error: (Tradfri) ----> Line 190 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-21 10:04:22.567 Error: (Tradfri) ----> Line 280 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-21 10:04:22.567 Error: (Tradfri) ----> Line 190 in '/home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
When I try:

Code: Select all

python3 tradfri.tac
It is stuck when initializing

Code: Select all

IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=52704)
Data received: b'{"identity": "domoticz", "gateway": "192.168.1.136", "action": "setConfig", "pollinterval": "30", "groups": "False", "psk": "*****************", "observe": "True"}'
Initializing gateway
And it stays initializing, doing nothing further...
Any idea?
Sorry for the late reply! It would appear that you're using the latest beta of domoticz?

I commited a small fix to the development-branch of the plugin a couple of days ago, that should address this issue. If it still fails, feel free to open a issue on github or let me know here in the forum.

Regards,
M

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

Posted: Wednesday 22 August 2018 9:36
by ivarka
IKEA will launch a smart plug in october: https://teknikveckan.com/nyheter/ikea-g ... rt-i-host/

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

Posted: Wednesday 22 August 2018 9:41
by Philos31
moroen wrote: Tuesday 21 August 2018 13:22
Philos31 wrote: Tuesday 21 August 2018 10:18

Code: Select all

IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=52704)
Data received: b'{"identity": "domoticz", "gateway": "192.168.1.136", "action": "setConfig", "pollinterval": "30", "groups": "False", "psk": "*****************", "observe": "True"}'
Initializing gateway
And it stays initializing, doing nothing further...
Any idea?
Sorry for the late reply! It would appear that you're using the latest beta of domoticz?

I commited a small fix to the development-branch of the plugin a couple of days ago, that should address this issue. If it still fails, feel free to open a issue on github or let me know here in the forum.

Regards,
M
Thanks, that would explain a lot. I am running the latest Beta, started this week building my years old domoticz from scratch.
Now if I just knew how to pull the development-branch from Git.... but I found that out.

It seems to work now. Thanks.

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

Posted: Friday 24 August 2018 23:47
by dzjr
Hello everyone,

I have made a new attempt, a completely new installation (read that there was an update).

now I'm a little further .. it just does not work ...

when I reboot the PI I get the following message in the log of domoticz:

Code: Select all



2018-08-24 23:46:27.012 (IKEA Tradfri) Connected successfully to: 192.168.0.19
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) 'onMessage' failed 'TypeError':'byte indices must be integers or slices, not str'.
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) ----> Line 282 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) ----> Line 195 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-24 23:46:38.088 PluginSystem: Restarting I/O service thread.
2018-08-24 23:46:38.089 (IKEA Tradfri) Device has disconnected



What did I do wrong?

maybe done too much?

I hope someone could help!

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

Posted: Saturday 25 August 2018 18:51
by moroen
dzjr wrote: Friday 24 August 2018 23:47 Hello everyone,

I have made a new attempt, a completely new installation (read that there was an update).

now I'm a little further .. it just does not work ...

when I reboot the PI I get the following message in the log of domoticz:

Code: Select all



2018-08-24 23:46:27.012 (IKEA Tradfri) Connected successfully to: 192.168.0.19
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) 'onMessage' failed 'TypeError':'byte indices must be integers or slices, not str'.
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) ----> Line 282 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-24 23:46:27.013 Error: (IKEA Tradfri) ----> Line 195 in /home/pi/domoticz/plugins/IKEA-Tradfri/plugin.py, function onMessage
2018-08-24 23:46:38.088 PluginSystem: Restarting I/O service thread.
2018-08-24 23:46:38.089 (IKEA Tradfri) Device has disconnected



What did I do wrong?

maybe done too much?

I hope someone could help!
Hi!

Which version of domoticz and which branch of the plugin are you using?

[edit]
I managed to recreate this error by using the domoticz stable with the development-branch of the plugin. If you try using the plugin's master branch with domoticz stable, it should work.
[/edit]

Regards,
M

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

Posted: Saturday 25 August 2018 19:37
by dzjr
moroen wrote: Saturday 25 August 2018 18:51

Good evening M,

Yesterday i used the latest stable final version of Domoticz, and in used the plugin from your github, i downloaded both yesterday.

Today i have tried to upgrade tot Domoticz Beta (now Version: 4.9942 Build Hash: 5524d792)

Now i have this message on the Domoticz Log:

Code: Select all

 2018-08-25 19:24:17.133 (IKEA Tradfri) Connected successfully to: 192.168.0.19
2018-08-25 19:24:28.107 (IKEA Tradfri) Device has disconnected 
When i start " python3 tradfri.tac " i get the following message;

Code: Select all


IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Couldn't listen on any:1234: [Errno 98] Address already in use.

Whit twistd -n -y tradfri.tac i get the message:

Code: Select all

Another twistd server is running, PID 267

This could either be a previously started instance of your application or a
different application entirely. To start a new one, either run it in some other
directory, or use the --pidfile and --logfile parameters to avoid clashes.
The content of ikea-tradfri.service is:

Code: Select all

[Unit]
Description=IKEA Tradfri COAP-adapter

[Service]
Type=simple
Environment=IKEA_HOME=/home/pi/domoticz/plugins/IKEA-Tradfri
ExecStart=/usr/local/bin/twistd --nodaemon \
      --rundir=${IKEA_HOME} \
      --pidfile=${IKEA_HOME}/twistd.pid \
      --python=${IKEA_HOME}/tradfri.tac

User=root
Group=root

Restart=always

[Install]
WantedBy=multi-user.target
What do i wrong?

as far as I can see, the coap client just works.


I hope you can help me

dzjr

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

Posted: Sunday 26 August 2018 2:37
by moroen
dzjr wrote: Saturday 25 August 2018 19:37
moroen wrote: Saturday 25 August 2018 18:51

Good evening M,

Yesterday i used the latest stable final version of Domoticz, and in used the plugin from your github, i downloaded both yesterday.

Today i have tried to upgrade tot Domoticz Beta (now Version: 4.9942 Build Hash: 5524d792)

Now i have this message on the Domoticz Log:

Code: Select all

 2018-08-25 19:24:17.133 (IKEA Tradfri) Connected successfully to: 192.168.0.19
2018-08-25 19:24:28.107 (IKEA Tradfri) Device has disconnected 
When i start " python3 tradfri.tac " i get the following message;

Code: Select all


IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Couldn't listen on any:1234: [Errno 98] Address already in use.

Whit twistd -n -y tradfri.tac i get the message:

Code: Select all

Another twistd server is running, PID 267

This could either be a previously started instance of your application or a
different application entirely. To start a new one, either run it in some other
directory, or use the --pidfile and --logfile parameters to avoid clashes.
The content of ikea-tradfri.service is:

Code: Select all

[Unit]
Description=IKEA Tradfri COAP-adapter

[Service]
Type=simple
Environment=IKEA_HOME=/home/pi/domoticz/plugins/IKEA-Tradfri
ExecStart=/usr/local/bin/twistd --nodaemon \
      --rundir=${IKEA_HOME} \
      --pidfile=${IKEA_HOME}/twistd.pid \
      --python=${IKEA_HOME}/tradfri.tac

User=root
Group=root

Restart=always

[Install]
WantedBy=multi-user.target
What do i wrong?

as far as I can see, the coap client just works.


I hope you can help me

dzjr
It looks like you already have the adapter running. If you're using latest beta of domoticz with the plugin version from the developmen-branch, a reboot of the Pi should do the trick...

Regards,
M

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

Posted: Sunday 26 August 2018 17:15
by dzjr
moroen wrote: Saturday 25 August 2018 18:51
It looks like you already have the adapter running. If you're using latest beta of domoticz with the plugin version from the developmen-branch, a reboot of the Pi should do the trick...

Regards,
M

Hello M,

I have tried a reboot several times, and still the same "error"

I made a clean install with Domoticz Beta 4.9948 & IKEA-Tradfri development branche, and again the same problem.....


Coaps is working..., only the script of ggravelingen din't work right i think (try it yourself).

i don't know what i can try next....


dzjr

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

Posted: Sunday 26 August 2018 19:52
by moroen
dzjr wrote: Sunday 26 August 2018 17:15
moroen wrote: Saturday 25 August 2018 18:51
It looks like you already have the adapter running. If you're using latest beta of domoticz with the plugin version from the developmen-branch, a reboot of the Pi should do the trick...

Regards,
M

Hello M,

I have tried a reboot several times, and still the same "error"

I made a clean install with Domoticz Beta 4.9948 & IKEA-Tradfri development branche, and again the same problem.....


Coaps is working..., only the script of ggravelingen din't work right i think (try it yourself).

i don't know what i can try next....


dzjr
Ok, please try: Go to the plugin-directory (/home/pi/domoticz/plugins/IKEA-Tradfri) look for and remove the twistd.pid file if it exists, then try to run the adapter from the command line.

Regards,
M

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

Posted: Sunday 26 August 2018 20:55
by dzjr
moroen wrote: Saturday 25 August 2018 18:51


Ok, please try: Go to the plugin-directory (/home/pi/domoticz/plugins/IKEA-Tradfri) look for and remove the twistd.pid file if it exists, then try to run the adapter from the command line.

Regards,
M
i have removed twistd.pid and run twistd -n -y tradfri.tac and the output is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ twistd -n -y tradfri.tac
2018-08-26T20:51:11+0200 [-] Loading tradfri.tac...
2018-08-26T20:51:13+0200 [-] Loaded.
2018-08-26T20:51:13+0200 [twisted.scripts._twistd_unix.UnixAppLogger#info] twistd 18.7.0 (/usr/bin/python3 3.5.3) starting up.
2018-08-26T20:51:13+0200 [twisted.scripts._twistd_unix.UnixAppLogger#info] reactor class: twisted.internet.epollreactor.EPollReactor.
2018-08-26T20:51:13+0200 [stderr#error] Traceback (most recent call last):
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 1361, in startListening
2018-08-26T20:51:13+0200 [stderr#error]     skt.bind(addr)
2018-08-26T20:51:13+0200 [stderr#error] OSError: [Errno 98] Address already in use
2018-08-26T20:51:13+0200 [stderr#error] During handling of the above exception, another exception occurred:
2018-08-26T20:51:13+0200 [stderr#error] Traceback (most recent call last):
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/bin/twistd", line 11, in <module>
2018-08-26T20:51:13+0200 [stderr#error]     sys.exit(run())
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/scripts/twistd.py", line 31, in run
2018-08-26T20:51:13+0200 [stderr#error]     app.run(runApp, ServerOptions)
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 674, in run
2018-08-26T20:51:13+0200 [stderr#error]     runApp(config)
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/scripts/twistd.py", line 25, in runApp
2018-08-26T20:51:13+0200 [stderr#error]     runner.run()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/application/app.py", line 385, in run
2018-08-26T20:51:13+0200 [stderr#error]     self.postApplication()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/scripts/_twistd_unix.py", line 254, in postApplication
2018-08-26T20:51:13+0200 [stderr#error]     self.startApplication(self.application)
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/scripts/_twistd_unix.py", line 442, in startApplication
2018-08-26T20:51:13+0200 [stderr#error]     service.IService(application).privilegedStartService()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/application/service.py", line 283, in privilegedStartService
2018-08-26T20:51:13+0200 [stderr#error]     service.privilegedStartService()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/application/internet.py", line 114, in privilegedStartService
2018-08-26T20:51:13+0200 [stderr#error]     self._port = self._getPort()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/application/internet.py", line 142, in _getPort
2018-08-26T20:51:13+0200 [stderr#error]     'listen%s' % (self.method,))(*self.args, **self.kwargs)
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/internet/posixbase.py", line 495, in listenTCP
2018-08-26T20:51:13+0200 [stderr#error]     p.startListening()
2018-08-26T20:51:13+0200 [stderr#error]   File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 1363, in startListening
2018-08-26T20:51:13+0200 [stderr#error]     raise CannotListenError(self.interface, self.port, le)
2018-08-26T20:51:13+0200 [stderr#error] twisted.internet.error.CannotListenError: Couldn't listen on any:1234: [Errno 98] Address already in use.

output of python3 tradfri.tac is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Couldn't listen on any:1234: [Errno 98] Address already in use.

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

Posted: Monday 27 August 2018 18:09
by moroen
dzjr wrote: Sunday 26 August 2018 20:55
output of python3 tradfri.tac is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Couldn't listen on any:1234: [Errno 98] Address already in use.
The network port is already taken. Either you have the adapter running in the background (started via systemd?) or another service is using the same port-number (1234). It could also be that the port is being blocked by a firewall or something. I would guess the adapter already running is the most probable reason.

If you try:

Code: Select all

$ sudo systemctl stop ikea-tradfri.service
$ python3 tradfri.tac
and let me know the output...

Regards,
M

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

Posted: Monday 27 August 2018 19:02
by dzjr
moroen wrote: Monday 27 August 2018 18:09
dzjr wrote: Sunday 26 August 2018 20:55
output of python3 tradfri.tac is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Couldn't listen on any:1234: [Errno 98] Address already in use.
The network port is already taken. Either you have the adapter running in the background (started via systemd?) or another service is using the same port-number (1234). It could also be that the port is being blocked by a firewall or something. I would guess the adapter already running is the most probable reason.

If you try:

Code: Select all

$ sudo systemctl stop ikea-tradfri.service
$ python3 tradfri.tac
and let me know the output...

Regards,
M
the output of python3 tradfri.tac is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=45418)
Data received: b'{"groups": "True", "gateway": "192.168.0.19", "identity": "*****", "pollinterval": "30", "observe": "True", "action": "setConfig", "psk": "{\\"9091\\":\\"123456789\\",\\"9029\\":\\"1.4.0015\\"}"}'
Initializing gateway
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "tradfri.tac", line 76, in dataReceived
    self.factory.initGateway(self, command)
  File "tradfri.tac", line 275, in initGateway
    self.devices = self.api(self.api(self.gateway.get_devices()))
  File "/usr/local/lib/python3.5/dist-packages/pytradfri/api/libcoap_api.py", line 96, in request
    return self._execute(api_commands, timeout=timeout)
  File "/usr/local/lib/python3.5/dist-packages/pytradfri/api/libcoap_api.py", line 85, in _execute
    raise RequestTimeout() from None
pytradfri.error.RequestTimeout: 

Disconnected
Regards
dzjr

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

Posted: Wednesday 29 August 2018 19:26
by moroen
dzjr wrote: Monday 27 August 2018 19:02
the output of python3 tradfri.tac is:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=45418)
Data received: b'{"groups": "True", "gateway": "192.168.0.19", "identity": "*****", "pollinterval": "30", "observe": "True", "action": "setConfig", "psk": "{\\"9091\\":\\"123456789\\",\\"9029\\":\\"1.4.0015\\"}"}'
Initializing gateway
Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "tradfri.tac", line 76, in dataReceived
    self.factory.initGateway(self, command)
  File "tradfri.tac", line 275, in initGateway
    self.devices = self.api(self.api(self.gateway.get_devices()))
  File "/usr/local/lib/python3.5/dist-packages/pytradfri/api/libcoap_api.py", line 96, in request
    return self._execute(api_commands, timeout=timeout)
  File "/usr/local/lib/python3.5/dist-packages/pytradfri/api/libcoap_api.py", line 85, in _execute
    raise RequestTimeout() from None
pytradfri.error.RequestTimeout: 

Disconnected

Ok, so the adapter times out when trying to use coap-client to communicate with the gateway. Are you sure you're using the correct ident/pks? Correct IP-adress? Can you use the coap-client directly to communicate with the gateway?

Regards,
M

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

Posted: Wednesday 29 August 2018 19:43
by dzjr
moroen wrote: Wednesday 29 August 2018 19:26


Ok, so the adapter times out when trying to use coap-client to communicate with the gateway. Are you sure you're using the correct ident/pks? Correct IP-adress? Can you use the coap-client directly to communicate with the gateway?

Regards,
M
i get this

Code: Select all


pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ coap-client -k "***************" coaps://192.168.0.19/.well-known/core
v:1 t:CON c:GET i:77ff {} [ ]
<//15006>;ct=0;obs,<//15001>;ct=0;obs,<//15004>;ct=0;obs,<//15004/add>;ct=0,<//15004/remove>;ct=0,<//15010>;ct=0;obs,<//15005>;ct=0;obs,<//15011/15012>;ct=0;obs,<//15011/9034>;ct=0,<//15011/9030>;ct=0,<//15011/9031>;ct=0,<//15011/9102>;ct=0,<//15011/9094>;ct=0;obs,<//15011/9095>;ct=0;obs,<//15011/9104>;ct=0;obs,<//15010/317446>;ct=0;obs,<//15010/289670>;ct=0;obs,<//15005/169498/200393>;ct=0;obs,<//15005/169498/220984>;ct=0;obs,<//15005/169498/205165>;ct=0;obs,<//15004/169498>;ct=0;obs,<//15005/169498>;ct=0;obs,<//15004/138625>;ct=0;obs,<//15005/138625>;ct=0;obs,<//15001/65537>;ct=0;obs,<//15001/65540>;ct=0;obs,<//15001/65536>;ct=0;obs,<//15001/65538>;ct=0;obs,<//15001/65542>;ct=0;obs,<//15001/65541>;ct=0;obs,<//15005/160748/212648>;ct=0;obs,<//15005/160748/217145>;ct=0;obs,<//15005/160748/197623>;ct=0;obs,<//15004/160748>;ct=0;obs,<//15005/160748>;ct=0;obs,<//15001/65543>;ct=0;obs,<//15005/138625/222168>;ct=0;obs,<//15005/138625/203559>;ct=0;obs,<//15005/138625/224462>;ct=0;obs,<//15011/9063>;ct=0,<//15001/65544>;ct=0;obs,<//15010/285904>;ct=0;obs



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

Posted: Thursday 30 August 2018 18:15
by dzjr
moroen wrote: Wednesday 29 August 2018 19:26


Ok, so the adapter times out when trying to use coap-client to communicate with the gateway. Are you sure you're using the correct ident/pks? Correct IP-adress? Can you use the coap-client directly to communicate with the gateway?

Regards,
M

:oops: i did something stupit, i used the complete ouput of the coap call into Domoticz...

i placed only the PSK :idea: , and now it is working....

thank you for the helping, and offcourse for the plugin!


regeards
dzjr

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

Posted: Friday 31 August 2018 14:17
by moroen
dzjr wrote: Thursday 30 August 2018 18:15
:oops: i did something stupit, i used the complete ouput of the coap call into Domoticz...

i placed only the PSK :idea: , and now it is working....

thank you for the helping, and offcourse for the plugin!


regeards
dzjr

Glad it worked out for you!

I've been toying with an idea to handle the whole IDENT/PSK-thing differently, I'll use your experience as motivation to finally getting it implemented...

Regards,
M

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

Posted: Tuesday 04 September 2018 22:38
by moroen
The latest version of the plugin's development branch now has a rather major change, a change that will break a current installation of the plugin, though rather easy to fix.

Instead of generating a (or using a known) IDENT/PSK pair, and then entering this information on the plugin setup page, the IDENT/PSK is handled by the adaptor, and generated using a configure.py python scipt, which need to be executed once before the adapter starts.

Anyone updating to the newest version are encouraged to the check out the readme for instructions, and report errors, problems or suggestions in this thread. Hopefully this change will alleviate a rather common problem getting the adapter to run, as you only need to supply the gateway IP and master-key on setup, no more manually using the coap-client directly to generate the IDENT/PSK-pair.

Regards,
M

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

Posted: Sunday 09 September 2018 11:02
by MichaelvK
Hi M,

I am running the plugin on development, and Domoticz on 4.9700.
When running the tradfri.tac, it is quiet.
After starting the plugin from Domoticz, I get the following result.
It is in a reboot loop after that, so the plugin re-initializes, and all lines re-occur.
It must be a very small issue, as I came this far finally (getting the right python3, pip3, twisted and coap-client setups without ipkg or so within the Synology linux variant..)

I have received the psk and marked it as x.x.xxxx below, it is a numeric value ofcourse.

Me@Diskstation216:/usr/local/domoticz/var/plugins/IKEA-Tradfri$ python3 tradfri.tac
IKEA-tradfri COAP-adaptor version 0.6 started (command line)!
Connected from IPv4Address(type='TCP', host='127.0.0.1', port=55273)
Data received: b'{"pollinterval": "30", "gateway": "192.168.1.167", "identity": "Client_identity", "groups": "False", "observe": "True", "psk": "x.x.xxxx", "action": "setConfig"}'
Initializing gateway
Unhandled Error
Traceback (most recent call last):
File "/opt/lib/python3.6/site-packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/opt/lib/python3.6/site-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/opt/lib/python3.6/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/opt/lib/python3.6/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/opt/lib/python3.6/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/opt/lib/python3.6/site-packages/twisted/internet/tcp.py", line 243, in doRead
return self._dataReceived(data)
File "/opt/lib/python3.6/site-packages/twisted/internet/tcp.py", line 249, in _dataReceived
rval = self.protocol.dataReceived(data)
File "tradfri.tac", line 76, in dataReceived
self.factory.initGateway(self, command)
File "tradfri.tac", line 275, in initGateway
self.devices = self.api(self.api(self.gateway.get_devices()))
File "/opt/lib/python3.6/site-packages/pytradfri-5.5.1-py3.6.egg/pytradfri/api/libcoap_api.py", line 96, in request

File "/opt/lib/python3.6/site-packages/pytradfri-5.5.1-py3.6.egg/pytradfri/api/libcoap_api.py", line 85, in _execute

pytradfri.error.RequestTimeout:

Disconnected


My Domoticz config:
Image

My Domoticz log:
Image

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

Posted: Sunday 09 September 2018 15:05
by Dnpwwo
I assume you have upgraded Domoticz recently because the plugin framework changed JSON handling a few months ago and I believe that is your problem.

This code at around line 188 in plugin.py:

Code: Select all

def onMessage(self, Connection, Data):
        #Domoticz.Debug("Received: " + str(Data))
command = json.loads(Data.decode("utf-8"))
is out of date because the framework now returns structured JSON rather than a simple string as it did previously.

It needs to be changed to be something like:

Code: Select all

def onMessage(self, Connection, Data):
        #Domoticz.Debug("Received: " + str(Data))
command = Data

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

Posted: Sunday 09 September 2018 19:54
by MichaelvK
Thanks!


Got it working indeed , missed an update of Domoticz, but as this is handled as a package, had to pick a beta from Jadahl.
Great!
All I now have to figure out is to have the "python3 tradfri.tac" as a daemon / service on Synology.
Not as easy as it sounds..

Great stuff this plugin!!