openhue / openhue-cli

OpenHue CLI is a command-line interface for interacting with Philips Hue smart lighting systems.
https://www.openhue.io/cli
Apache License 2.0
40 stars 6 forks source link

OpenHue-CLI Discovery Never Resolves on Windows #52

Open Xevion opened 3 months ago

Xevion commented 3 months ago

At least, I assume it never will, because on Linux, this process finished in half a second, while on Windows, it's still running.

I'm building with go install directly instead of docker.

Everything else about the CLI works fine as far as I can tell, I just had to setup by manually checking and feeding in the Bridge IP address; openhue-cli setup -b 192.168.100.152.

I enabled verbose logging by setting the dev environment variable, but the logs produced don't make it obvious to me what the issue is:

PS C:\Users\Xevion\projects\openhue-cli> openhue-cli discover
time="2024-05-19T00:53:33-05:00" level=info msg="Running in dev mode, logs will be output in the console"
time="2024-05-19T00:53:33-05:00" level=info msg="Running the 'discover' command"
time="2024-05-19T00:53:33-05:00" level=info msg="DNS-SD service '_hue._tcp.local.'"
time="2024-05-19T00:53:38-05:00" level=error msg="Unable to lookup bridge with service '_hue._tcp.local.'. Check error details below:"
time="2024-05-19T00:53:38-05:00" level=error msg="context deadline exceeded"

I waited a few minutes to see if anything else was outputted, but nothing did.

thibauult commented 2 months ago

Hi @Xevion and thanks for reporting this issue.

My main problem in investigating this one is that I don´t have any Windows machine to test with.

Would you be able to run the following command on your side:

dns-sd -B _hue._tcp local.

[!NOTE] Command found from the Philips Hue Developers documentation

Xevion commented 2 months ago
PS C:\Users\Xevion> dns-sd -B _hue._tcp local.
Browsing for _hue._tcp.local.
Timestamp     A/R Flags if Domain                    Service Type              Instance Name
 2:46:23.291  Add     2 20 local.                    _hue._tcp.                Hue Bridge - 98C048

I had to install the Bonjour SDK for Windows from Apple, which was much harder to find than it should be.

FYI for anyone exploring this in the future, you need an Apple ID (standard, no special developer setup/enrollment required).

And actually, after looking into Bounjour, I found that Bonjour Print Services actually does install dns-sd into path (confirmed it). Comparably a lighterweight and simpler install to the full Bonjour SDK.

I looked into Resolve-DnsName as a more readily available alternative, but it doesn't seem to be able to look up service instances (qualified by the -B argument). I also found a npm package, node-dns-sd, and it actually does work pretty well. It has a CLI wrapper, details here: @warren-bank/node-dns-sd-cli.

thibauult commented 1 month ago

Hi @Xevion,

I've just released the 0.16, including a few improvements regarding the automatic bridge discovery.

Please let me know if the openhue discover command is now working better in Windows.

Thanks!