nschum / homebridge-twinkly

37 stars 10 forks source link

Trouble with discovering devices #16

Closed mpappas441 closed 3 years ago

mpappas441 commented 3 years ago

I have been using the plugin successfully until the most recent update 0.4.0. None of the Twinkly accessories I have added to the Twinkly app are "found" with the updated plugin. All the depreciated accessories work without issue. Is there a step I am missing somewhere? Add device to Twinkly App, no new devices found in home bridge plugin. Included most recent log. Thank you! MP

EDIT: I am using all Gen 2 devices

[28/02/2021, 19:29:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:30:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:31:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:32:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:33:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:34:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:35:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:36:07] [homebridge-twinkly] Broadcasting to find devices... [28/02/2021, 19:37:07] [homebridge-twinkly] Broadcasting to find devices...

saiajin commented 3 years ago

Same issue...I have a a Gen 1 device and I can't get it to see it at all.. I tried using the IP address but to no avail...

nschum commented 3 years ago

@mpappas441 No, there shouldn't be any additional steps.

You could try adding "timeout": 5000 to increase the discovery timeout to 5 seconds to see if that makes a difference. Do you know if your network has any unusual configurations? Discovery requires an UDP response.

urluba commented 3 years ago

Hi,

Same for me, but the issue is that the response doesn't match expectedResponse .

For my devices, two icicle 190 (TWI190STP-T) running firmware 2.5.9, the ouputs in hexa are:

2201a8c04f4b
0c01a8c04f4b

Instead of the expected 3500000a4f4b. Don't know why the code before the "OK" is different.

Update: Found this doc: https://xled-docs.readthedocs.io/en/latest/protocol_details.html#discovery-protocol

Twinkly devices respond with message:

  • first four bytes are octets of IP address of the device in reverse order - first byte is last octet of the IP adress, second one is the second to last, …
  • fifth and sixth byte are 0x79 0x75 - string OK
  • rest is a string representing device id
  • last one is a zero byte

So I suppose your Twinkly has IP 10.0.0.53 :)

Therefore this simple change does the trick for me:

            let expectedResponse = Buffer.from("OK");
            let results = [];

            socket.on("message", (message, info) => {
                if (message.subarray(4, 6).equals(expectedResponse)) {