Skip to content
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

Implement mDNS discovery and use as default #51

Merged
merged 3 commits into from
Jan 3, 2024

Conversation

Siphonay
Copy link
Contributor

@Siphonay Siphonay commented Jan 2, 2024

On the Hue Bridge developer documentation, the mDNS method is listed first, and mentioned to have replaced the old UPnP approach.

https://developers.meethue.com/develop/application-design-guidance/hue-bridge-discovery/

I implemented it using Ruby’s stdlib mDNS resolver. Since it got added in version 2.1.0, I bumped the minimum version to that one.

I think this method is preferable as a default, because it does not need internet connectivity to discover Hue bridges on a local network, and is not subject to rate limiting or temporary or permanent outage of the online API.

The old method is still available as a fallback after a 10 seconds timeout, for example if the user’s router blocks multicast messages. The mDNS discovery can be completely bypassed by passing use_mdns: false to the Client initializer.

@soffes
Copy link
Owner

soffes commented Jan 3, 2024

Thanks for doing this!

Tested it locally with this:

$:.unshift File.dirname(__FILE__) + '/lib'
require 'hue'

client = Hue::Client.new
light = client.lights.first
puts light

and was able to see a light. Also doing light.on! worked too. So I'm assuming it's good to go. Unfortunate there's not a better way to test this 😅 (Although that is totally outside the scope of this PR. Adding all this for future me.)

@soffes soffes merged commit e2f878b into soffes:main Jan 3, 2024
@soffes
Copy link
Owner

soffes commented Jan 3, 2024

Available in version 0.3.0

@Siphonay
Copy link
Contributor Author

Siphonay commented Jan 3, 2024

Awesome, thanks for merging so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants