Not detected in Hue app - Problem with certificate

My diyHue running as a docker install on my Raspberry Pi is detected by HueDynamic but not the Hue app. So following the instructions here https://diyhue.readthedocs.io/en/latest/AddFuncts/debug.html#https-certificate-check

I ran

curl https://127.0.0.1/api/nouser/config -v -k

but that returns

pi@raspberrypi:~ $

  • Expire in 0 ms for 6 (transfer 0x1321880)
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Expire in 200 ms for 4 (transfer 0x1321880)
  • connect to 127.0.0.1 port 443 failed: Connection refused
  • Failed to connect to 127.0.0.1 port 443: Connection refused
  • Closing connection 0
    curl: (7) Failed to connect to 127.0.0.1 port 443: Connection refused

Any ideas how I can fix this?

Looks like the ports were not forwarded in docker.

I setup diyhue via docker too. The HUE APP wont connect. The ssl check gives me this error:

root@photon-machine [ ~ ]# curl https://127.0.0.1/api/nouser/config -v -k

  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Connected to 127.0.0.1 (127.0.0.1) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  • successfully set certificate verify locations:
  • CAfile: /etc/pki/tls/certs/ca-bundle.crt
    CApath: none
  • TLSv1.2 (OUT), TLS header, Certificate Status (22):
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443
    curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:443

Anyone able to help me with this?

The instructions recommend running in host network mode, so that’s what I did using the command given

docker run -d --name “diyHue” --restart=“always” --network=“host” -e MAC=‘XX:XX:XX:XX:XX:XX’ -v ‘/mnt/hue-emulator/export/’:’/opt/hue-emulator/export/’:‘rw’ diyhue/core:latest

so why would that not work?

I googled forwarding the ports and tried adding -p 443:443 so the command was

docker run -d -p 443:443 --name “diyHue” --restart=“always” --network=“host” -e MAC=‘XX:XX:XX:XX:XX:XX’ -v ‘/mnt/hue-emulator/export/’:’/opt/hue-emulator/export/’:‘rw’ diyhue/core:latest

and I got

WARNING: Published ports are discarded when using host network mode

and when I tried

curl https://127.0.0.1/api/nouser/config -v -k

I still get

  • Expire in 0 ms for 6 (transfer 0x173e880)
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Expire in 200 ms for 4 (transfer 0x173e880)
  • connect to 127.0.0.1 port 443 failed: Connection refused
  • Failed to connect to 127.0.0.1 port 443: Connection refused
  • Closing connection 0
    curl: (7) Failed to connect to 127.0.0.1 port 443: Connection refused

Can you send a debug log from diyhue. Just noticed you are using host networking so no need to forward ports.

Try accessing diyhue from http not https.

Sorry, I got busy with stuff and haven’t had any time to tinker with this until now.

I tried running the command via http instead of https

pi@raspberrypi:~ docker run -d --name "diyHue" --restart="always" --network="host" -e MAC='XX:XX:XX:XX:XX:XX' -v '/mnt/hue-emulator/export/':'/opt/hue-emulator/export/':'rw' -e DEBUG='true' diyhue/core:latest be2a7cb0951c445cfd19f4caa2bef0f0fd978f0e83c6fa2debfeb344a581e65e pi@raspberrypi:~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be2a7cb0951c diyhue/core:latest “python3 -u /opt/hue⦔ 33 seconds ago Up 7 seconds diyHue
pi@raspberrypi:~ $ curl https://127.0.0.1/api/nouser/config -v -k

  • Expire in 0 ms for 6 (transfer 0x1abf880)
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Expire in 200 ms for 4 (transfer 0x1abf880)
  • connect to 127.0.0.1 port 443 failed: Connection refused
  • Failed to connect to 127.0.0.1 port 443: Connection refused
  • Closing connection 0
    curl: (7) Failed to connect to 127.0.0.1 port 443: Connection refused

pi@raspberrypi:~ $ curl http://127.0.0.1/api/nouser/config -v -k

  • Expire in 0 ms for 6 (transfer 0x268880)
  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • Expire in 200 ms for 4 (transfer 0x268880)
  • Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)

GET /api/nouser/config HTTP/1.1
Host: 127.0.0.1
User-Agent: curl/7.64.0
Accept: /

< HTTP/1.1 200 OK
< Server: nginx
< Date: Sat, 01 Aug 2020 20:38:39 GMT
< Content-type: application/json
< Content-Length: 227
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, OPTIONS, POST, PUT, DELETE
< Access-Control-Allow-Headers: X-Requested-With
< Access-Control-Allow-Headers: Content-Type
<

  • Connection #0 to host 127.0.0.1 left intact
    {“name”:“Philips hue”,“datastoreversion”:70,“swversion”:“1937113020”,“apiversion”:“1.35.0”,“mac”:“XX:XX:XX:XX:XX:XX”,“bridgeid”:“XXXXXXFFFEXXXXXX”,“factorynew”:false,“replacesbridgeid”:null,“modelid”:“BSB002”,“starterkitid”:""}pi@raspberrypi:~ $

As you can see, it doesn’t really help. I think the Hue app needs to certificate to be able to find diyHue via https but the documentation doesn’t explain how to fix the problem if the certificate is bad, or even why it might be bad after doing a fresh install of docker/diyHue.

You should be able to simply delete it from /mnt/hue-emulator/export/. On restart of the container, it will automatically recreate it. Also do not forget to change the mac variable to the actual mac address.

Feel free to add to the documentation!

OK, I’ll try that. I didn’t think I needed to specify the actual MAC address as the page here https://diyhue.readthedocs.io/en/latest/getting_started.html only says:

“When running with the bridge network mode you must provide the IP and MAC address of the host device. Four ports are also opened to the container. These port mappings must not be changed as the hue ecosystem expects to communicate over specific ports.”

and doesn’t mention anything about having to provide the MAC address when running in host network mode.

That helped thanks. Now the curl command returns the correct result and I can detect my Yeelights in the Hue app. It can’t detect my Hue dimmer switches though. It only detects them if I switch back to the Hue bridge by deleting and redetecting it but then the app can’t detect the Yeelights as they’re only available via the diyHue bridge, so how do I get my Hue dimmer switches to work with with diyHue?

If you specify a mac address, then the program prioritizes that over looking for the mac automatically.

You need to link the hue bridge to get that to work.

OK, how do I link the hue bridge? I guess I have to do that in diyHue but I can’t see any instructions on the website about that.

I’m not sure since I don’t use that feature.