diyHue Add-on

Can you only get it on your external HTTPS URL? Do you run HA itself as https or are you using something like nginx in front of it?

So I can access HA locally via IP address, I just get the security warning in my browser.
eg. https://internalIP:8123
I am using the Duck DNS add-on, which I think just reports external IP address changes to Duck DNS, so that doesn’t really matter.
I port forward to a different port externally so it’s not so obvious how to get to my HA instance.
I do not use nginx.

Ok it is because you are running your Home Assistant instance as HTTPS itself. If you feel confident going into the diyhue Docker container I can tell you what to change to try to fix it?

Yea if you don’t want to bog down the topic you can PM me.
I have portainer installed, hopefully we can use the shell there or something.

So this is the change you need to make…

in /opt/hue-emulator/protocols/homeassistant_ws.py

Find the line:

homeassistant_url = f'ws://{homeassistant_ip}:{homeAssistant_port}/api/websocket'

And change the ws to wss:

homeassistant_url = f'wss://{homeassistant_ip}:{homeAssistant_port}/api/websocket'

Let me know if that works and i’ll add a config option into diyhue.

So I was able to manage re-writing that line, and I am able to verify my save is being made by opening the file again, but when I restart the container in HA it seems to remove my change. Is it somehow pulling a fresh image on each start?

Is there maybe a command I can run to just try this without restarting the container to test for you?

edit: I tried sh run.sh, that didn’t seem to happy.

So restarting via portainer kept my change but I still get the following error in the add-on log:

Docker Setup Initiated
SSL certificate found
Config file found
Docker Setup Complete
WARNING:root:Home Assistant Web Socket Client disconnected trying to (re)connect
ERROR:root:Error connecting to Home Assistant WebSocket
Traceback (most recent call last):
  File "/opt/hue-emulator/protocols/homeassistant_ws.py", line 223, in create_websocket_client
    homeassistant_ws_client.connect()
  File "/usr/local/lib/python3.8/site-packages/ws4py/client/__init__.py", line 233, in connect
    raise HandshakeError("Invalid response")
ws4py.exc.HandshakeError: Invalid response
{"ok"}
{"ok"}
{"ok"}
{"ok"}
{"ok"}
{"ok"}

I’ve only discovered diyHUE today and I’m getting a very similar error.

This is what I have in the config.json file:

    "homeassistant": {
        "enabled": true,
        "homeAssistantIncludeByDefault": true,
        "homeAssistantIp": "192.168.1.40",
        "homeAssistantPort": 8123,
        "homeAssistantToken": "xxxxxxxxxxxxxxxx",
        "homeAssistantUseHttps": true

This is my configuration in Supervisor dashboard:

config_path: /config/diyhue
mac: DC:A6:32:47:FF:87
debug: false
deconz_ip: ‘’
no_serve_https: true

Out of the box - diyhue is not decting my Yeelights either.

Any help/suggestions please?

I think the gist of my issue it diyHue wants to access the HA API at http:// not https:// the way my setup works, and I thought this was relatively standard, was that http is refused when https is enabled.

My friend is going to help me set up NGINX soon which will hopefully fix this. Which is good because my node red color animations were a bit buggy this 4th of July.

Ok so after setting up NGINX diyHue wants port 443, which is what NGINX uses.
Any tips for anyone who has both running?

So after some re-jiggering to my NGINX and Router I was able to use 443 and 80.
Now I’m getting:

WARNING:root:Home Assistant Web Socket Client disconnected trying to (re)connect
192.168.1.207 - - [14/Jul/2021 21:47:46] "GET /api/hueess38e50d11ebbb600242ac1e210a/groups HTTP/1.1" 200 -
192.168.1.207 - - [14/Jul/2021 21:47:46] "GET /api/hueess38e50d11ebbb600242ac1e210a/lights HTTP/1.1" 200 -
192.168.1.207 - - [14/Jul/2021 21:47:47] "GET /api/hueess38e50d11ebbb600242ac1e210a/lights HTTP/1.1" 200 -
192.168.1.207 - - [14/Jul/2021 21:47:47] "GET /api/hueess38e50d11ebbb600242ac1e210a/groups HTTP/1.1" 200 -
{"ok"}

Is it reconnected after failing at first because something isn’t ready?
Is it happy after that?
There’s no lights available in the “Lights config” nor in the Hue Elements app.

Thanks.

You must click search/add lights to get them in app(hue or hue essentials)

How does this addon compare to emulated Hue Emulated Hue - Home Assistant?

I had emulated hue running on my HASS docker install to expose Deconz switches to my Harmony.

I’m now migrating to a dedicated Hass box (Blue), so wondering whether to ditch emulated hue for this?

Thanks of course I’m not home now.
I couldn’t find that buried in the Hue Elements menus.
I don’t seem to be able to do it over VPN.

Now after getting everything set up so I can allow the add-on to play on the ports it wants to, my lights have been discovered in Hue elements and iConnectHue, which is the real prize.
But upon commanding things, the response times are very slow.
Upon commanding a light animation to play last night I saw an attempt by it going to the first color and then the animation failing.
This morning the lights didn’t even attempt to be begin the animations.
Here is an issue I see in the logs, hopefully there’s some correlation to what I’m seeing, it doesn’t make much sense to me.

----------------------------------------
Exception happened during processing of request from ('192.168.1.160', 55589)
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.8/http/server.py", line 429, in handle
    self.handle_one_request()
  File "/usr/local/lib/python3.8/http/server.py", line 395, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------

So all errors aside there does seem to be some light in the dark.
The lights are connected to a few Hue apps, but I’m really not feeling the viability.
The lights are very slow to respond vie the Hue apps and just give up on trying to make color animations happen.
I’m specifically trying to use iConnectHue, not sure if anybody here uses that?
If I execute color commands in HA to the same lights they respond instantly.

With the end of summer looming in my mind I might have to switch back to the Hue bridge so I can have my spooky color animations.
I was really hoping to cut out a Zigbee bridge.

Only wifi light are fast, special those with diyhue firmware

Proper Zigbee lights are slow?
I guess I’ll be firing the Hue hub back up…

you can tryout huemulator

I am embarrassed to ask the noob of all noob questions, but I’m stuck on the very first step setting up the config in the add-on.

The question: What mac address are you referring to?

Is it the mac address of the native hue bridge? Is is the mac address of the raspberry pi I’m running HA on? Is it the mac address of your mom?

As far as I can tell, none of the docs or guides anywhere explain what device’s mac address I’m supposed to put; they all assume everyone knows what it’s referring to. Go ahead, see for yourself.

The official add-on documentation:

Option: mac

The mac-address of your device.

Wow, super helpful. Looking elsewhere, @foxy82 's guide is definitely very thorough, but even there:

Once installed you need to configure the add on it as follows setting the MAC address is very important before the first run - this is the MAC address of your server.

Ok, what “server”? Again, is this HA, aka my pi? The native Hue bridge? nginx? duckdns? Again, “mac address” of some “device” is presumed known and leaves idiots like me behind.

And don’t get me started on Home Assistant — diyHue 1.0 documentation which begins with editing the config json. There must be some creative unspoken inferences not mentioned for that guide to truly begin at the real starting point.

An obvious question to me: “Hey ManImCool, instead of posing your question here with obvious petty and bratty undertones, why didn’t you just try all those mac addresses you were able to come up with until you figured it out?”

My response: First, I acknowledge I’m being a little bitchy. I thought about trying this, until reading through all of the threads and seeing that a lot of people smarter than me mess this up even when they have the correct mac address to begin with, whether they started this add-on too early, or forgot to turn off nginx, etc. In most instances, people only seemed to fix it by starting all over deleting everything or worse, a fresh install of HA. From all these data points I’ve read, a trial-and-error approach seemed unwise.

In sum, please tell this dum-dum what (*&@&4’ing MAC address of what *&$^#@ device to enter into the add-on config so I can continue foxy82’s guide like a normal person. And maybe we add this info to all the main guides so other dum-dums like myself can avoid feeling extra dum-dum.

xoxo, -Sean

1 Like