diyHue Add-on

Hello Max,

Thank you for all the work you have been doing on this addon.

I have recently got an ambilight tv and have 2 yeelight 1se bulbs set up to use ambilight+hue. This addon allows this to be done really well, there’s a tiny delay but it’s not something that I am fussed about.

There is a bit of a quirk with this setup though that I’m hoping you would know how to fix. The bulbs don’t seem to like the colour blue when running this way, it wants to use purple instead. I know they can do blue quite well, as I’ve used the colour picker to change them to blue and they look very vibrant. It is only when I have ambilight+hue running. Do you have any suggestions?

Thanks,
M

Hey for the diyhue app you need to be able to expose both port 80 and port 443 for diyhue you also must ensure that you enter the mac address when you first start so that a certificate is created.

If (like me) you are trying to get it to work whilst using the nginx add on there are a bunch of hoops to jump through however I’ve submitted two PRs to make this easier:

  1. Max is going to merge soon: https://github.com/MaxBec/hassio-diyHue/pull/16
  2. The other has meet some initial resistance from the home assistant maintainers and i’m working to alleviate their concerns: https://github.com/home-assistant/addons/pull/1948

If you are interested in using the nginx addon so that your home assistant is on https://homeassistant.mydomain.com with the hue app still working then please check out the second PR and add any feedback.

If anyone does want this desperately I can post instructions on how to modify your setup to get it working.

Hi, do you mean by expose Port 80 & 443 that they need to be open to the outside internet?

I actually see in the logs, that my hue essentials is getting recognized as well as that a key is created. But then I simply receive the error message: Bridge unreachable.

I have the addon running with both 80 & 443 but none of them are exposed to the internet. A Certificate is created as well.

2021-03-29 16:02:23,616 - root - INFO - b'{"devicetype":"Hue Essentials#SM-F916B","generateclientkey":true}'
2021-03-29 16:02:24,323 - root - INFO - sync with lights
192.168.1.101 - - [29/Mar/2021 16:02:24] "GET /hue/linkbutton?username=&password=&action=Activate HTTP/1.1" 200 -
192.168.10.54 - - [29/Mar/2021 16:02:24] "POST /api/ HTTP/1.1" 200 -
2021-03-29 16:02:24,658 - root - INFO - in post method
2021-03-29 16:02:24,658 - root - INFO - /api/
2021-03-29 16:02:24,659 - root - INFO - b'{"devicetype":"Hue Essentials#SM-F916B","generateclientkey":true}'
2021-03-29 16:02:24,660 - root - INFO - [
    {
        "success": {
            "clientkey": "XXXX",
            "username": "XXXX"
        }
    }
]

I am actually employing Frenk’s amazing NGINX Proxy Manager Addon to have DIYHUE as well as my Homeassistant available via duckdns. In that case, I simply switched my NGINX ports to 8443 and 8080 and forward to that from 80 and 443. This also worked fine with the previous version of DIYHUE, but now i dont seem to get a connection to the apps anymore. Everything else still works though.

Hey - no not to the internet but exposed on your local network. I’m assuming the Hue App is on your phone also on your local network?

(not sure about the ssdp one didn’t realise that was different - put them to the same if you can)

image

Like this and ensure no_serve_https isn’t ticked:

image

My PR has been rejected so far - so if you are interested in running both the diyHue add on and home assistant on port 443 please pile in and let them know if not i’ll look to create another community add on

Not sure which part it was… but i now finally have it working again with both the original HUE App, the Hue essentials app and the DUCKDNS served through NGINX.

I set the SSDP actually to 1900 and just removed the certificate completely to create a new one.
I assume just recreating the certificate did it.

My goal is to migrate all bulbs and stuff currently connected to native HUE bridge to Deconz, but yet I’m unsure how those integrations/addons have to be connected to each other.

I still want to use Hue or Hue Essential App, but also Alexa integration, so I think, that I would be fine with diyhue.

My setup:

  • hassio supervised: supervisor-2021.03.9
  • marthoc/deconz: latest image with WEB_PORT 8081 and WS_PORT 8443

My guess is, that diyhue needs to conmmunicate with deconz API to fetch registered devices from there. Hue* Apps are communicating with diyhue and accessing those devices.

Based on that assumption, diyhue addon is only used to integrate the configuration and docker container management into home assistant. And finally deconz is presenting devices to home assistant and diyhue?

The default config.json uses port 8080 for communicating with deconz. Is it communication on web or ws port?

I also noticed following error message:

-----------------------------------------------------------
 Add-on: diyHue
 Philips Hue Bridge Emulator
-----------------------------------------------------------
 Add-on version: 1.4.1
 You are running the latest version of this add-on.
 System: Debian GNU/Linux 10 (buster)  (amd64 / qemux86-64)
 Home Assistant Core: 2021.3.4
 Home Assistant Supervisor: 2021.03.9
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
/config/diyhue exists.
Your Architecture is = amd64
Serve HTTPS
Host MAC given as 00012e4da112
Docker Setup Initiated
SSL certificate found
Config file found
Docker Setup Complete
Deconz IP given as 192.168.1.21
Exception in thread Thread-8:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/hue-emulator/HueEmulator3.py", line 1976, in run
    ctx.load_cert_chain(certfile=_certfile)
ssl.SSLError: [SSL] PEM lib (_ssl.c:4023)
{"ok"}

:Edit I was able to fix the above issue by entering docker container (docker exec -it bash) and execute genCert.sh with the configured mac address.

Still my Osram Smart Plug doesn’t show up in diyhue, but in hassio. Actually, I have no idea how to verify, if the diyhue <-> deconz connection is fine or not.

Regards
Oliver

If you tick the Debug Log Box in the configuration you will see all devices that are connected.
Alternatively, you can also see all the discovered devices in the config.json in the diyhue folder.

In this config.json you can also directly change the config for deconz or homeassistant lights.

    "deconz": {
        "enabled": false,
        "lights": {},
        "port": 8080,
        "sensors": {}

As for the rest, your logic is correct. Deconz/ZHA/Zigbee2MQTT wil connect all the Lights to your HomeAssistant. Then depending on how you configure it, you can either expose the lights via HomeAssistant, or directly via DECONZ to DIYHUE. This DIYHUE will then also enable you to expose the lights to Alexa, Harmony, the Hue app etc.

I’ve created a guide here on getting the Hue App working with Home Assistant here: [GUIDE] Using the Hue App with Home Assistant (via DiyHue)

It was an emotional journey!

I’ve uninstalled the addon + removed the config and did a fresh install. It’s now working. I think, that I started the addon before setting up the base config (deconz_ip, mac address) and that broke everything.

Hue App + Hue Essentials App are connected. I’m not using https/nginx proxy, so I’m fine with my current config.

Yet, I’m unsure, if I should expose the lights only to HASS and let HASS announce it to diyHue. In that case, I’ll have to set up groups, like multi bulb roof lamps, only once. At least in my imagination :wink:

It is up to you - I always found getting Hue app to connect with Deconz was hard work. The advantage with using Home Assistant -> diyHue -> Hue App is that you can expose more than just deconz lights to it in my house i’ve got a mix of sonoff/zwave/deconz/official hue hub all in the Hue App. Doing it just using Home Assistant means that I can disable all the other “protocols” in diyHue to avoid getting duplicates.

Yeah i will change the startup-process soon, so that it will abort if there is no mac address set. :slight_smile:

Yeah, that was also my idea. I would like to keep the hue app for convenience, e.g. controlling brightness, coloring. At this point, I don’t have enough time to build floor plans and so on to provide a better GUI for my family.

Thanks for sharing your thoughts.

@MaxBec92 yeaht, that would be great :sweat_smile:

Would it also be possible to add the ‘host_network’ back or add as an optional selection to the configuration? I have noticed that when this is removed it stops diyhue from being able to discover yeelight and my tv isn’t able to find the virtual hub.

1 Like

Will check that!

1 Like

Long time no see!
I’ve been very interested in condensing my zigbee footprint by removing my actual Hue hub.
I gave this all another swing and feel I got much further than my last attempt, I wasn’t really at a spot where I could handle that level of frivolity, but now I want the frivols.

I’ve followed @foxy82 's guide, I have my MAC address set for my HA VM, I was able to detect and activate the bridge in the official Hue app, now looking where you configure HA lights in the config I think I’m throwing some errors somewhere.

I created the token fine, I used my local IP address, not my external URL, not sure that that would make sense… I’ve pointed it at 8123 as that’s what it speaks on internal to my network. I’ve set up the diyhue attribute in the lights I wanted included but there’s a lot of lights to add it to every one I don’t want included, I can’t imagine that’s throwing these errors though.

Thanks for any help.

Logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: diyHue
 Philips Hue Bridge Emulator
-----------------------------------------------------------
 Add-on version: 1.4.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 5.13  (amd64 / qemux86-64)
 Home Assistant Core: 2021.5.5
 Home Assistant Supervisor: 2021.05.4
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
/config/diyhue exists.
Your Architecture is = amd64
Serve HTTPS
Host MAC given as 000c298086ce
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 217, in connect
    self.sock.connect(self.bind_addr)
ConnectionRefusedError: [Errno 111] Connection refused

Config:

        "homeassistant": {
            "enabled": true,
            "homeAssistantIncludeByDefault": false,
            "homeAssistantIp": "192.168.1.252",
            "homeAssistantPort": 8123,
            "homeAssistantToken": "<REDACTED>"
        },

Hi.

In your main home assistant configuration.xml you either need
default_config or frontend : Home Assistant Frontend - Home Assistant

OR

api : Home Assistant API - Home Assistant

Thanks for the reply.
I think frontend has been default since before I was using HA, so that’s there.
I tried adding api: which seemed to work without issue, but I still got the same errors in the diyHue logs.

Maybe I wasn’t clear, I have a token, I just removed it from the config for security reasons.

The error you posted looks like you don’t have the API running, it is blocked, isn’t on that IP address or the diyhue docker doesn’t have access to it.

Can you try to connect to the API using the instructions on this page: REST API | Home Assistant Developer Docs

ok so I’ve verified I get:

message
-------
API running.

When using my external https URL.
If the system can’t accept insecure connections how would I format my config?

I’ve tried https://URL for the Home Assistant IP and just URL with the external port.
I’ve tried local IPs with and without https:// or http:// with the internal port.