moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Connection timed out #99

Open mrwolf78 opened 4 years ago

mrwolf78 commented 4 years ago

I've followed the instructions to install this plugin on my Raspberry Pi, but when running 'python3 plugin.py config 192.168.0.75 4Sk6uLS49Aw1MXXX' (last three characters edited), I get an error:

Connection timed out.

I've triple checked the IP-address and Security code, these are correct. What can I do to find the cause and resolve this?

Edit: Although I haven't seen any errors during install, I installed py3coap manually. I can now perform the config-command with no error, but python3 plugin.py list returns 'Connection timed out'.

nachtbraker commented 4 years ago

Same here, I installed the plugin on an rPi with an already working domoticz installation. OS = Raspbian GNU/Linux 10 (buster). I followed the instructions in README-PI.md. The gateway is working normally and pingable.

python3 plugin.py config xx.xx.xx.xx xxxxxxxxxx Connection timed out

Key and IP address are correct, I triple-checked. Rebooted the gateway just in case, no change.

moroen commented 4 years ago

I'm unable to reproduce this. Any firewalls etc than could be causing this? Connection working from the IKEA-app?

nachtbraker commented 4 years ago

Yes, it was working fine from the Ikea (cr)app. But a few days ago I installed py3coap manually as mrwolf78 did. That seems to have fixed the problem and it is working fine now.

Thanks for making this plugin available, much appreciated!

moroen commented 4 years ago

There seems to be some issues with downloading py3coap from pypi on raspbian, glad it worked out using manual install!

mrwolf78 commented 4 years ago

Actually, in the time between nachtbraker's post and you closing the ticket, I reinstalled the plugin and tried both an automatic and maual install of py3coap. I'm still getting the connection timed out error. But since I seem to be the only one, I'll try to reinstall everything on the RPi from scratch somewhere this week, let's hope that's solving the issue!

moroen commented 4 years ago

Ok, reopening... If that fails, try switching to coapcmd and see if that solves it!

mrwolf78 commented 4 years ago

Unfortunately, no success on a fresh SD card with Raspbian lite, only Domoticz installed (Raspberry Pi Model B). The entire log (changed only the last digits of the gateway key) shows no errors. I was hopeful when the config command initially didn't return a timeout, but the list command keeps on giving the timeout. The RPi and Gateway are both wired and actually about 10cm apart from each other.

edit: installing coapcmd seems to do the trick (finally)!!!

moroen commented 4 years ago

There's a updated version of py3coap in the master branch now (version 0.8.0), if you would like to give it a try, but using coapcmd should be a viable alternative. I'll make a fresh SD card with raspbian lite and see if I reproduce this error...

mrwolf78 commented 4 years ago

Ok, great. I've got it working right now, so I'll rather leave it alone right now ;)

brunohead commented 4 years ago

Hello,

first, thanks a lot for this plugin 👍 . Which worked perfeclty til a week ... Now I have got a Connection timed out

When I start the coap command I have got this

bin/coapcmd get --ident 7f698xxxxxxxxxxxxxxxxxx081 --key FlQuxxxxxxxx5u0 coaps://192.168.1.69:5684/15001
{"Status":"HandshakeError","Result":""}

Is this issue that related to Certificate or HTTPS ?

What does it work perfectly until a week and now anymore ? I am the only one :) ?

Gateway Ikea version 1.10.30 and 1.10.36 same issue Light Ikea version 2.0.023 Switch Ikea version 2.2.010

moroen commented 4 years ago

Sometimes the gateway resets some or all the ident/PSK-pairs. I haven't been able to determine why or how, but it happens, sometimes you also need to reconnect the official IKEA app...

So, the first thing to try, is to generate a new ident/PSK-pair:

$ python3 plugin.py config IP KEY

brunohead commented 4 years ago

Indeed, this is my fault. I had to reconfigure the pluging like this :-)

Thanks for your advice👍

I also add a bash script at startup to execute a refresh (daily refresh because daily reboot !)

#! /bin/sh

IP=192.168.1.xx
KEY=mykey
PATH=/home/pi/domoticz/plugins/IKEA-Tradfri

cd $PATH
/usr/bin/python3 plugin.py config $IP $KEY
tdsmtdsm commented 4 years ago

Same problem here on a clean install SD card. Used py3coap (pip3 install py3coap , no errors) , connection timed out. Switched to coapcmd, connection timed out. Verified key and gateway ping reply.

{'Status': 'HandshakeError', 'Result': ''} Connection timed out

Rebooted both the gateway and my RPi, grrr.

NomNomSu commented 3 years ago

Same issue Raspberry with manual pycoap install because py3coap command from how to document did not work and throws errors. When running python3 plugin.py config IP KEY there is always connection timed out

moroen commented 3 years ago

In order to try to solve this, I need to know how installing py3coap failed, and the log from installing py3coap from source. It's possible to end up with a non-working py3coap module when installing from source, so if you could provide the output from either:

sudo pip3 install -U py3coap

or

sudo -H python3 setup.py install

or both, I'll take a look!

The most common cause of either of these methods failing, is a missing go compiler...

NomNomSu commented 3 years ago

In order to try to solve this, I need to know how installing py3coap failed, and the log from installing py3coap from source. It's possible to end up with a non-working py3coap module when installing from source, so if you could provide the output from either:

sudo pip3 install -U py3coap

or

sudo -H python3 setup.py install

or both, I'll take a look!

The most common cause of either of these methods failing, is a missing go compiler...

Highly possible that it was missing go compiler. Right now it installs correctly but it may already have all dependencies and use cache due to manual installation.

Still the main issue is that it just does not connect to the Ikea gate:

below is output for py3coap and for coapcmd:

pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py config 192.168.178.47 6*************
{'Status': 'HandshakeError', 'Result': ''}
Connection timed out
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py api pycoap
pi@raspberrypi:~/domoticz/plugins/IKEA-Tradfri $ python3 plugin.py config 192.168.178.47 6*************
Connection timed out
moroen commented 3 years ago

It works on my raspberry, using the latest image of raspbian, both coapcmd and py3coap. Have you tried the precompiled binary of coapcmd?

VincentvdH-91 commented 3 years ago

Hi @moroen I've succesfully installed the IKEA Tradfri plugin on my RPI without any errors, I've followed the instruction on https://github.com/moroen/IKEA-Tradfri-plugin/blob/master/README-PI.md. In one of the very latest steps "$ python3 plugin.py config gw IP KEY", of course after entering the IP-address of my Tradfri gateway & the correct key, I'm getting the 'Connection timed out' error. I've read through this forum, but wasn't able to find any resolution, could you please advice what the best way is to solve this? Thanks a lot!

baahver commented 2 years ago

I installed This Ikea Tradfri plugin in the Domoticz plugin directory on an x86_64 system installed with os Ubuntu server 21.04. This went well. I installed tradfricoap and py3coap without errors. I tried both as sudo and as user. I configured like: python3 plugin.py config gw xxx xxx and python3 plugin.py config api py3coap All was set in config.json. But I still get a Time out:

python3 plugin.py list Connection timed out

If I uninstall py3coap and try the: sudo -H python3 setup.py install option in the pycoap directory, I have a missing Golang compiler error. Any solution to solve this?

Edit: It looks like I had to install gccgo-go as: sudo apt install gccgo-go. But still does this not solve the time out issue.

Edit: python3 plugin.py version IKEA Tradfri Plugin: 0.10.7 Tradfricoap: 0.1.0 Py3coap: 0.9.2 coapcmd: (/home/baahver/domoticz/plugins/ikea-tradfri/bin/coapcmd) 0.1.7

Edit: On another issue I found this command: ./coapcmd get --ident IDENT --key my-key coaps://192.168.178.60:5684/15001

This command gives me: {"Status":"HandshakeError","Result":""} Does that say anything what could result in a solution?