-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
discover_devices edge case bug #4
Comments
Hmm, thanks for the report, that is strange. I assumed if the code got that far there would always be an IP field in the response... I'll just add a quick check to ensure the IP variable has been assigned before adding it to the response dictionary. I'm glad you're enjoying using this package! |
No problems. I wish I had been thinking more clearly. At the time I sort of realised/assumed that the lights had already been connected to another network. I was a little mad. But would have been great to seen the malformed string that generated the error. If somehow it ever happens again I will be sure to get more info. |
If you'd like, with the update I'm planning to do tomorrow to fix this, I'll also add a debug argument to |
I found the problem. the Nanoleaf Light Panels are returning records that are included in your search (nanoleaves list) but the record format is very different. Nanoleaf Light Panels (Record) Nanoleaf Canvas (Record) |
- Resolve error described in issue #4 - Add a debug argument to `discover_devices()` that prints out the SSDP string
Thanks for the further details! I've just updated the package with code that should recognise the Light Panels from the record you provided (although it will be unable to give a name, just the IP). Unfortunately, I don't have access to my lights at the current time, so please try updating the package to Again, thank you for the detailed information regarding this! |
Maybe you could help me with something. I really have no understanding of the socket work going on in the discover_devices func. I found the above problem again before I had seen your post because I was looking to see if I could get a quicker discover time. I hadn’t realised there was a timeout param :(. Anyway, after some testing I found that if I pass 1sec to the func I was getting timing of about 1.4-1.75 sec to complete with a correct dict returned. if i passed say .4 it started to get a little unpredictable empty or malformed dict. Given some networks would be faster/slower than others, once you got a baseline for a network would it remain fairly consistent for the network or is there complicated caching etc. going on that invalidates that idea. |
To be totally honest, I don't know a lot about it either, but I managed to figure it out to (mostly) work for that function. From what I understand, it can take some time after a SSDP M-SEARCH packet is sent for the Nanoleaf to reply, which is why there is a timeout. In some cases, yes, it may be a lot quicker than 30 seconds, but in my limited testing it's not always guaranteed and I think it may be hard to set a baseline because of this. As I said previously, unfortunately I don't have access to my lights to test this further currently, but I would recommend installing Wireshark and setting a filter for |
Myles, Traceback (most recent call last): |
Hm, I think I misunderstood what you meant in the previous one. Do the light panels have a record that is similar to that of the Canvas? Would ignoring that record stop the discovery of the Light Panels totally? Unfortunately, I never owned the Light Panels so I could not test with them :( |
Myles,
|
Alright, I'll update it to what you suggested, for the time being, thanks for your help with this! |
Myles, In my mind, the only change required is to filter the list of devices something like I have done below or some version of that. btw, my light panels are model nl28 the canas being nl29, but I could not get search to return anything for nanoleaf:nl28. I tried various combos. Anyway, not sure if you came to the same conclusion or not. I went down a lot of rabbit holes.
|
Does anyone else with the Light Panels still have this issue? Since I don't have them myself it's hard for me to test. |
I have been using nanoleafapi with 3 canvas sets. Today I got a Nanoleaf Rhythm edition set also. So I turn it on and could not pair it in the nano app or Homekit. Out of interest I wanted to see if nanoleafpapi would see it. So the discovery.discover_devices() started to fail.
Traceback (most recent call last):
, line 4, in
nanoleaf_dict = discovery.discover_devices()
, line 36, in discover_devices
nanoleaf_dict[name] = ip
UnboundLocalError: local variable 'ip' referenced before assignment
So I did a hard reset on the light panels and before adding them to the apps I tested discovery.discover_devices() and it was working fie. Did not see the light panels which is fine but did not error out.
I know it's a out there edge case, but thought you would like to know.
Python 3.8.2
MacOS 10.15.4
Thanks for doing the work on nanoleafapi, its great to have and a lot of fun and works very well.
The text was updated successfully, but these errors were encountered: