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 that has now been included in the diyhue project (https://github.com/diyhue/hassio-addon) 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
- http://my.domain.com or https://my.domain.com - you will get the lovelace ui
- using just your ip address, e.g. https://192.168.1.2 - you will get the diyhue UI
- Using your IP address with home assistant port e.g. http://192.168.1.2:8123 - you will get the lovelace UI (If anything goes wrong during setup below you should always be able to access your Home Assistant install on this URL).
Install Diy Hue Addon
-
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.
-
Install the DiyHue Add on (but don’t start it!) from here: https://github.com/diyhue/hassio-addon
-
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)
-
Start the add on.
-
Navigate to http://
-
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.
- 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
-
Stop the diyHue add on
-
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
-
Check the diyHue docs on how to configure diyHue’s connection to Home Assistant here: Home Assistant — diyHue 1.0 documentation
-
Start the DiyHue Add on and check the logs to ensure there are no errors.
-
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.
-
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.
-
Stop the diyhue addon
-
Open the Hue App or Hue Essentials app and delete the hub you added in the first test.
-
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.
-
Install my modified NGINX add on from: https://github.com/foxy82/ha-addons
-
Set the config up like this being sure to enter your own
domain
. Thefallback_certfile
andfallback_keyfile
were created by diyHue when you first started the diyHue addon.
-
On your server go to
/usr/share/hassio/share
and create a directoy callednginx_proxy
-
In
/usr/share/hassio/share/nginx_proxy
create a file calleddiyhue.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;
}
}
-
Start my modified NGINX add on
-
Navigate to http:// :41080
-
Open Hue Essentials or Hue App on your phone and it should successfully connect. Try toggling a light to make sure it is working.
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 (21) and click “Link Device”. The default username and password are Hue/Hue. Then click the “Activate” button.
There we have it - a lot of hard work went into making this work from both myself, @MaxBec92, @Mevel, and Mauris Moteta. It has included 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.