[GUIDE] Using the Hue App with Home Assistant (via DiyHue)

Tags: #<Tag:0x00007fc4125e6b08>

I wanted to use the Hue App to control Home Assistant lights as some members of the family prefer the Hue App to the Home Assistant interface.

So I set out to add Home Assistant integration into diyHue (https://diyhue.org/) and as luck would have it at the same time @MaxBec92 created the DiyHue Addon (diyHue Add-on) here is how to configure everything you need to get the Hue App working to control Home Assistant lights…

Before we start one limitation of this setup is that the Hue App will only work when your phone is on the same local network as your Home Assistant installation - it isn’t a solution for remote access.

You will also need to setup your own home network dns so that my.domain.com points to your home assistant server. This is out of scope of this guide as all networks are different.

This setup will then mean that from now on when on your home network if you enter

Install Diy Hue Addon

  1. First are you using port 80 or 443 on your home assistant install? E.g. if you are using the “NGINX Configurable Home Assistant SSL proxy” addon. If so you need to stop the services running on these ports to start with. If you are using NGINX add on there is an alternative later in this guide.

  2. Install Max’s Diy Hue Add on (but don’t start it!) from here: https://github.com/MaxBec/hassio-diyHue
    (more details on his add on can be found in this post: diyHue Add-on)

  3. 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.

(debug isn’t strictly necessary but does make it easier to check issues - if you are running on a pi or similar you should disable debug once it is working to preserve the SD card)

  1. Start the add on.

  2. Click the “Open Web UI” to open the web ui.

  3. Open up either the Hue Essentials or normal Hue App on your phone and add a new hub.

E.g. in the Hue App click settings “Add Hue Bridge”, it will search but if you don’t want to wait you can click “help” and enter the IP address of your server. It will ask you to push the “Hue Link Button” to do this on diyHue you need to go to the web UI we opened in Step (4) and click “Link Device”. The default username and password are Hue/Hue. Then click the “Activate” button.

  1. If everything is successful the Hue App should connect - however at this stage it may not have any lights setup we will do this in the next step.

Setup DiyHue to connect to Home Assistant

  1. Stop the diyHue add on

  2. Find diyHue’s config.json file. If you have access to the server and configured the add on as above then it will be in /usr/share/hassio/homeassistant/diyhue

  3. Check the diyHue docs on how to configure diyHue’s connection to Home Assistant here: https://diyhue.readthedocs.io/en/latest/lights/homeassistant.html

  4. Start the DiyHue Add on and check the logs to ensure there are no errors.

  5. In the Hue App / Hue Essentials search for lights - it might say it didn’t find any but this is ok. Once you enter out of the search screen you should see the lights.

  6. Toggle a light to make sure it is working

Re-enable port 443 / 80

If you were using the “NGINX Configurable Home Assistant SSL proxy” on port 443/80 to access the Home Assistant lovelace UI then this addon isn’t compatible with running diyHue however I have created a modified add on here: https://github.com/foxy82/ha-addons. Unfortunately if you are using port 443/80 for something else then I can’t easily help but comment and we can see what we can do.

  1. Go to the diyHue add on configuration page and change it so it doesn’t use port 443/80 by changing these settings, here i’ve used 41443 and 41080. Once changed save and restart the addon.

  1. Install my modified NGINX add on from: https://github.com/foxy82/ha-addons

  2. Set the config up like this being sure to enter your own domain. The fallback_certfile and fallback_keyfile were created by diyHue when you first started the diyHue addon.

  1. On your server go to /usr/share/hassio/share and create a directoy called nginx_proxy

  2. In /usr/share/hassio/share/nginx_proxy create a file called diyhue.conf which contains the details below changing <your ip address> for your home assistant IP address e.g. 192.168.1.2:

    server {
        server_name <your ip address>;
        ssl_certificate  /config/diyhue/cert.pem;
        ssl_certificate_key  /config/diyhue/cert.pem;

        listen 443 ssl http2;

        location / {
            proxy_pass http://<your ip address>:41080;
            proxy_set_header Host $host;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    server {
        server_name <your ip address>;

        listen 80;
        proxy_buffering off;

        location / {
            proxy_pass http://<your ip address>:41080;
            proxy_set_header Host $host;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
  1. Start my modified NGINX add on

  2. Open Hue Essentials or Hue App on your phone and it should successfully connect. Try toggling a light to make sure it is working.

There we have it - a lot of hard work went into making this work from both myself and @MaxBec92 including submissions to diyHue and creating the addons in use so if you are using this and it is working please let us know. Any comments please add them below.

5 Likes

[Reserved for future updates]

Moved to community guides.

Thank you very much for the guide, @foxy82. Will add this to the add-on if you are ok with it! :slight_smile:

Fine by me - although maybe we should wait a bit to see what feedback arrives as we might find this only works for me :slight_smile:

1 Like