szokeptr / homebridge-tradfri-plugin

Ikea Tradfri plugin for Homebridge
59 stars 6 forks source link

No Lights in Home App #13

Closed n30ngruu3n closed 7 years ago

n30ngruu3n commented 7 years ago

Hello,

i've configured the tradfri-plugin and updated the config.json, homebrigde starts and reports:

[6/8/2017, 3:49:47 PM] Loaded plugin: homebridge-tradfri
[6/8/2017, 3:49:47 PM] Registering platform 'homebridge-tradfri.Tradfri'
[6/8/2017, 3:49:47 PM] ---
[6/8/2017, 3:49:48 PM] Loaded plugin: homebridge-tradfri-plugin
[6/8/2017, 3:49:48 PM] Registering platform 'homebridge-tradfri.IkeaTradfri'
[6/8/2017, 3:49:48 PM] ---
[6/8/2017, 3:49:48 PM] Loaded config.json with 0 accessories and 2 platforms.
[6/8/2017, 3:49:48 PM] ---
[6/8/2017, 3:49:48 PM] Loading 2 platforms...
[6/8/2017, 3:49:48 PM] [LimeGreen-Base] Initializing Fritz!Box platform...
[6/8/2017, 3:49:48 PM] [Tradfri-Gateway] Initializing Tradfri platform...
[6/8/2017, 3:49:48 PM] Loading 0 accessories...
[6/8/2017, 3:49:48 PM] [Tradfri-Gateway] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux
[6/8/2017, 3:49:48 PM] [Tradfri-Gateway] GET: coaps://192.168.178.25:5684/15001/
[6/8/2017, 3:49:48 PM] [Tradfri-Gateway] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux
[6/8/2017, 3:49:48 PM] [Tradfri-Gateway] GET: coaps://192.168.178.25:5684/15001/
<Buffer 2f 75 73 72 2f 6c 6f 63 61 6c 2f 6c 69 62 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 68 6f 6d 65 62 72 69 64 67 65 2d 74 72 61 64 66 72 69 2f 64 69 73 ... >
<Buffer 2f 75 73 72 2f 6c 6f 63 61 6c 2f 6c 69 62 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 68 6f 6d 65 62 72 69 64 67 65 2d 74 72 61 64 66 72 69 2f 64 69 73 ... >
[6/8/2017, 3:49:48 PM] [LimeGreen-Base] Fritz!Box platform login successful
[6/8/2017, 3:49:48 PM] [LimeGreen-Base] Discovering accessories
[6/8/2017, 3:49:49 PM] [LimeGreen-Base] Outlets found: 087610359099,087610362010
[6/8/2017, 3:49:50 PM] [LimeGreen-Base] Thermostats found:
[6/8/2017, 3:49:50 PM] [LimeGreen-Base] Sensors found:

but the Home app doesn't show any lights from Tradfri. Does anyone have an advice for me, how to fix that?

Regards neongruuen

n30ngruu3n commented 7 years ago

Now i fixed this error with upgrading node to the latest stable version and recompiling all plugins & home bridge. Now its a timeout error during startup:

`[2017-6-9 18:00:53] Loaded plugin: homebridge-tradfri-plugin [2017-6-9 18:00:53] Registering platform 'homebridge-tradfri.IkeaTradfri' [2017-6-9 18:00:53] --- [2017-6-9 18:00:53] Loaded config.json with 0 accessories and 2 platforms. [2017-6-9 18:00:53] --- [2017-6-9 18:00:53] Loading 2 platforms... [2017-6-9 18:00:53] [LimeGreen-Base] Initializing Fritz!Box platform... [2017-6-9 18:00:53] [Tradfri-Gateway] Initializing IkeaTradfri platform... [2017-6-9 18:00:53] Loading 0 accessories... Load homebridge-tradfri.Tradfri [2017-6-9 18:00:53] [homebridge-tradfri.Tradfri] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux [2017-6-9 18:00:53] [homebridge-tradfri.Tradfri] GET: coaps://192.168.178.25:5684/15001/ [2017-6-9 18:00:53] [homebridge-tradfri.Tradfri] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux [2017-6-9 18:00:53] [homebridge-tradfri.Tradfri] GET: coaps://192.168.178.25:5684/15001/ <Buffer 2f 75 73 72 2f 6c 6f 63 61 6c 2f 6c 69 62 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 68 6f 6d 65 62 72 69 64 67 65 2d 74 72 61 64 66 72 69 2f 64 69 73 ... > <Buffer 2f 75 73 72 2f 6c 6f 63 61 6c 2f 6c 69 62 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 68 6f 6d 65 62 72 69 64 67 65 2d 74 72 61 64 66 72 69 2f 64 69 73 ... > [2017-6-9 18:00:53] [LimeGreen-Base] Fritz!Box platform login successful [2017-6-9 18:00:53] [LimeGreen-Base] Discovering accessories [2017-6-9 18:00:54] [LimeGreen-Base] Outlets found: 087610359099,087610362010 [2017-6-9 18:00:54] [LimeGreen-Base] Thermostats found: [2017-6-9 18:00:54] [LimeGreen-Base] Sensors found: [2017-6-9 18:00:54] [LimeGreen-Base] Initializing platform accessory 'Guest WLAN'... [2017-6-9 18:00:54] [LimeGreen-Base] Initializing platform accessory 'Heizungsbrenner'... [2017-6-9 18:00:54] [LimeGreen-Base] Initializing platform accessory 'Umwälzpumpe'... v:1 t:CON c:GET i:d8e4 {} [ ] coap-client -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001 [2017-6-9 18:00:58] [Tradfri-Gateway] Command timed out: coap-client -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001 Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐
│ 031-45-154 │
└────────────┘

[2017-6-9 18:00:58] Homebridge is running on port 51826.`

i hope anybody has an idea to fix this issue.

Regards Neongruuen

0ff commented 7 years ago

The buffer that's printed as debug looks wrong: <Buffer 2f 75 73 72 2f 6c 6f 63 61 6c 2f 6c 69 62 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 68 6f 6d 65 62 72 69 64 67 65 2d 74 72 61 64 66 72 69 2f 64 69 73 ... > means /usr/local/lib/node_modules/homebridge-tradfri/dis ...

So I'm going to guess that this is actually telling you that either

  1. your binary cannot be run (missing permissions, wrong platform maybe)
  2. or your binary could not be found

Try this and post the result: /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001

n30ngruu3n commented 7 years ago

I guess you're right!

Output of the command is: -bash: /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux: cannot execute binary file: Exec format error

Any idea to fix this?

n30ngruu3n commented 7 years ago

with sudo'ing the output is: /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux: 1: /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux: Syntax error: ")" unexpected

I hope this helps..

0ff commented 7 years ago

Hm, this is where it gets a bit tricky. Try uname -a and post what linux you're on. Might be it's just unsupported by the build of this tool.

0ff commented 7 years ago

Wait. You compiled the coap-client-linux yourself, didn't you? Also post the output of the command file /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux then

n30ngruu3n commented 7 years ago

Linux LimeGreen-Pi 4.9.24-v7+ #993 SMP Wed Apr 26 18:01:23 BST 2017 armv7l GNU/Linux

n30ngruu3n commented 7 years ago

I've compiled it myself!

Output is /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=257d0d6afad7ed139c38ca1c8b7782393ba4d77a, not stripped

n30ngruu3n commented 7 years ago

Just an idea, is the "x86-64" argument the problem? While running on Arm-v7?

0ff commented 7 years ago

Okay let me guess: You've compiled the tool on your desktop, then moved it to the raspi? 😄

Unfortunately, that won't work. You'd either need to cross-compile it (that's the way down the rabbit hole, but it's the right way) or you need to find a binary built for ARM - such as the one attached.

NOTE: DO NOT TRUST A FILE A STRANGER SENT YOU OVER THE INTERNET For all you know, this file will go ahead and fry all your stuff. Or install malware. Or whatever. Maybe, just maybe, this is coap-client exactly as you need it (/usr/local/bin/coap-client: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=33514c635aa9de307a71f88bc965b2f87c021c4f, not stripped) but yeah, probably not.

coap-client.zip

0ff commented 7 years ago

Or just run these instructions on your raspi and save all of the cross-compiling trouble 👍

n30ngruu3n commented 7 years ago

Oh well, I didn't compile the package on my mbp, but it's possible, that I followed a guide for macOS and just copied the commands to the shell without givin' a thought about the compile instructions.. (maybe I mustn't play around with such things when I'm tired... :D ). I'll give the compile instructions a try ✌🏽 A big thanks until this point!

n30ngruu3n commented 7 years ago

I've copied the coap-client from /usr/local/bin/coap-client to /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux and now the output is, as expected, ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=77f6888bcd438059b7fdc08f0668ef0737fcfe1c, not stripped but the timeout error persists...

->


[2017-6-10 10:31:30] [homebridge-tradfri.Tradfri] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux
[2017-6-10 10:31:30] [homebridge-tradfri.Tradfri] GET: coaps://192.168.178.25:5684/15001/
[2017-6-10 10:31:30] [homebridge-tradfri.Tradfri] Using COAP client binary: /usr/local/lib/node_modules/homebridge-tradfri/dist/tradfri/../../bin/coap-client-linux
[2017-6-10 10:31:30] [LimeGreen-Base] Fritz!Box platform login successful
[2017-6-10 10:31:30] [LimeGreen-Base] Discovering accessories
[2017-6-10 10:31:31] [LimeGreen-Base] Outlets found: 087610359099,087610362010
[2017-6-10 10:31:32] [LimeGreen-Base] Thermostats found:
[2017-6-10 10:31:32] [LimeGreen-Base] Sensors found:
[2017-6-10 10:31:32] [LimeGreen-Base] Initializing platform accessory 'Guest WLAN'...
[2017-6-10 10:31:32] [LimeGreen-Base] Initializing platform accessory 'Heizungsbrenner'...
[2017-6-10 10:31:32] [LimeGreen-Base] Initializing platform accessory 'Umwälzpumpe'...
v:1 t:CON c:GET i:29e9 {} [ ]
  coap-client -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001
[2017-6-10 10:31:35] [Tradfri-Gateway] Command timed out: coap-client -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001

but at this point there isn't a line about the buffer, so I think we've got a step further..

n30ngruu3n commented 7 years ago

By the way, i've tripple-checked the psk and the ip address, it's both correct..

0ff commented 7 years ago

Yes that sure looks better. Try running /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001 yourself and see if it responds with a list of devices. Haha, I was literally just typing this: "Check your IP and PSK" but then your 2nd response came in. Okay, so run it and post the results.

n30ngruu3n commented 7 years ago

Sadly there are quite no devices...

pi@LimeGreen-Pi:~/.homebridge $ /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 coaps://192.168.178.25:5684/15001
v:1 t:CON c:GET i:c822 {} [ ]

🤣 , yeah I thought it was the right moment to get this point clear..

0ff commented 7 years ago

This weird, if you are sure that the IP and PSK are correct then there must be something wrong with the gateway. See, this is what should happen:

$ coap-client -u 'Client_identity' -k PSK -B 5 coaps://gw:5684/15001
v:1 t:CON c:GET i:3bb9 {} [ ]
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 78 bytes cleartext
[65544,65541,65546,65542,65537,65538,65545,65536,65540,65543,65539]

Instead, your client runs into a timeout (my guess is that the shell only returns after ~5 secs, correct?). To debug this, tell the client to print debug info like this: /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 -v 9 coaps://192.168.178.25:5684/15001

Oh also please try ping 192.168.178.25 and see if the gateway is setup correctly :)

n30ngruu3n commented 7 years ago

Well, that's the output with the additional debug information:

$ /usr/local/lib/node_modules/homebridge-tradfri/bin/coap-client-linux -u 'Client_identity' -k 'EcOVQv3DooRatowg' -B 5 -v 9 coaps://192.168.178.25:5684/15001
Jun 10 10:47:21 DEBG created DTLS endpoint 0.0.0.0:41722
v:1 t:CON c:GET i:89f8 {} [ ]
Jun 10 10:47:21 DEBG sending CoAP request:
v:1 t:CON c:GET i:89f8 {} [ Uri-Path:15001 ]
Jun 10 10:47:21 DEBG *** new session 0x9e8768
Jun 10 10:47:21 DEBG dtls_new_peer: 192.168.178.25:5684
Jun 10 10:47:21 DEBG DTLSv12: initialize HASH_SHA256
Jun 10 10:47:21 DEBG send handshake packet of type: client_hello (1)
Jun 10 10:47:21 DEBG send header: (13 bytes):
00000000 16 FE FD 00 00 00 00 00  00 00 00 00 36
Jun 10 10:47:21 DEBG send unencrypted: (12 bytes):
00000000 01 00 00 2A 00 00 00 00  00 00 00 2A
Jun 10 10:47:21 DEBG send unencrypted: (42 bytes):
00000000 FE FD 00 25 47 0E D8 E1  ED 17 23 A3 91 68 D1 BB
00000010 59 FD 40 9F 1F 8C 1D E6  DF 7E 2D 97 7B 1C 30 44
00000020 1D BE 00 00 00 02 C0 A8  01 00
Jun 10 10:47:21 DEBG call dtls_write
Jun 10 10:47:21 DEBG *** add 0x9e8020 to sendqueue of session 0x9e8768
Jun 10 10:47:21 DEBG timeout is set to 5 seconds
Jun 10 10:47:21 DEBG received 60 bytes on fd 3
Jun 10 10:47:21 DEBG dtls_handle_message: FOUND PEER
Jun 10 10:47:21 DEBG got packet 22 (60 bytes)
Jun 10 10:47:21 DEBG receive header: (13 bytes):
00000000 16 FE FD 00 00 00 00 00  00 00 00 00 2F
Jun 10 10:47:21 DEBG receive unencrypted: (47 bytes):
00000000 03 00 00 23 00 00 00 00  00 00 00 23 FE FD 20 EC
00000010 26 C9 4A 86 38 6E 23 51  CC 8D AB FB CB 3B 38 6C
00000020 BA 89 F7 71 25 61 19 30  53 D3 98 3B 48 9A 7F
Jun 10 10:47:21 DEBG received handshake packet of type: hello_verify_request (3)
Jun 10 10:47:21 DEBG handle handshake packet of type: hello_verify_request (3)
Jun 10 10:47:21 DEBG clear MAC
Jun 10 10:47:21 DEBG add MAC data: (12 bytes): 0100004A000100000000004A
Jun 10 10:47:21 DEBG add MAC data: (74 bytes): FEFD0025470ED8E1ED1723A39168D1BB59FD409F1F8C1DE6DF7E2D977B1C30441DBE0020EC26C94A86386E2351CC8DABFBCB3B386CBA89F7712561193053D3983B489A7F0002C0A80100
Jun 10 10:47:21 DEBG send handshake packet of type: client_hello (1)
Jun 10 10:47:21 DEBG send header: (13 bytes):
00000000 16 FE FD 00 00 00 00 00  00 00 01 00 56
Jun 10 10:47:21 DEBG send unencrypted: (12 bytes):
00000000 01 00 00 4A 00 01 00 00  00 00 00 4A
Jun 10 10:47:21 DEBG send unencrypted: (74 bytes):
00000000 FE FD 00 25 47 0E D8 E1  ED 17 23 A3 91 68 D1 BB
00000010 59 FD 40 9F 1F 8C 1D E6  DF 7E 2D 97 7B 1C 30 44
00000020 1D BE 00 20 EC 26 C9 4A  86 38 6E 23 51 CC 8D AB
00000030 FB CB 3B 38 6C BA 89 F7  71 25 61 19 30 53 D3 98
00000040 3B 48 9A 7F 00 02 C0 A8  01 00
Jun 10 10:47:23 DEBG ** retransmission #1 of transaction 35320
Jun 10 10:47:23 DEBG call dtls_write
Jun 10 10:47:26 DEBG ** retransmission #2 of transaction 35320
Jun 10 10:47:26 DEBG call dtls_write
Jun 10 10:47:30 DEBG ** retransmission #3 of transaction 35320
Jun 10 10:47:30 DEBG call dtls_write
Jun 10 10:47:38 DEBG ** retransmission #4 of transaction 35320
Jun 10 10:47:38 DEBG call dtls_write

may this be an encryption problem? 🤔

0ff commented 7 years ago

Hm, sorry, this is where I'm out. It looks like they start talking to each other and then fail to communicate. Why that is, though, I have no idea. Even if I change my PSK to an invalid value it looks very different from your log, it seems to me that the Raspi is not receiving a response from the gateway. Are there any kind of firewall rules in your network shielding the Raspi from access?

Sorry, but as I said I can't help you any further :( Maybe try the same command on your linux host, if it works here then there's a network problem. The client you've built earlier will work on your host.

n30ngruu3n commented 7 years ago

Thanks for your commitment. I think I've found the problem at side of the gateway.. Done a Portscan with macOS Networkutility on a port range of 5000 - 6000 and there aren't any responding ports.. But now the problem is how to get the gateway responding..

n30ngruu3n commented 7 years ago

Additional information: even if I skip the user and key params the output remains the same. So I think the needle hole is at the gateway-part

0ff commented 7 years ago

Yes, do that :) Also please verify the gateways firmware version inside the app, mine is at 1.1.0015 and just maybe this has something to do with it.

n30ngruu3n commented 7 years ago

I think I've found the problem.. Tradfri Gateway Version is 1.0.0008 . But how to update the Gateway? If I click "check for updates" it doesn't do anything..

Wireshark output seems clear from any packets by or to *.25 .. even if I change options in the Tradfri App. I am quite confused..

n30ngruu3n commented 7 years ago

Starting from scratch was the solution! Complete reset of the gateway and now it has updated to 1.1.0015 and the lightbulbs are recognised in the home app.......

A very very big thanks to you for your commitment! happy