michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

Filter list of endpoints that SsdpLocator returns? #120

Closed niels9001 closed 7 years ago

niels9001 commented 7 years ago

I'm running into a weird issue: for some reason, whenever I use the SsdpLocator it returns over 1900 devices (although I only have 3 actual devices) on my network. Its probably related to my network (but I do think some endusers are experiencing the same issue). What happens then is that the locator checks for each device if it is a Hue bridge (so it really takes a long time :-)).

To be safe, it would be nice if we only check if its a Hue bridge for a list of destinct devices:

var endpoints = discoveredDevices.Where(s => s.EndsWith("/description.xml")).ToList(); // 1907 var filteredEndpoints = endpoints.Distinct(); //3 foreach (var endpoint in filteredEndpoints)

Please let me know what you think before I do a pull request!

michielpost commented 7 years ago

Yes, sounds great. If they all have the same IP, they should only be checked once.

niels9001 commented 7 years ago

Thanks! Will NuGet package be up soon as well?

michielpost commented 7 years ago

Q42.HueApi.WinRT.3.3.2 and Q42.HueApi.Net.3.3.2 are up on NuGet now