Setting up Home Assistant on Synology NAS to control Mi-Light via Google Home Mini speaker with voice
This guide is written to explain how you can control Mi-Lights via Google Home with voice control without using the paid Nabu Casa service. In my own setup I’m running Home Assistant on Synology Docker, and have chosen to write this guide as I was unable to find anything similar, and it took me a long time to piece everything together, considering that I have close to 0 knowledge of Linux command line or scripting otherwise, and my networking knowledge isn’t the strongest either But the set-up described below ended up working for me. So this guide should be easy to follow for everyone who has a similar setup, although you might have to make adaptations for differences in your own set-up.
My set-up is as follows:
• Linksys WRT1900ACS Router
• Synology DS1515+ NAS
o Running DSM 6.2.1-23824 Update 1
o Running Docker
o Running Home Assistant 0.82.1
• Google Home Mini speaker
• 8x Mi-Light 4W RGB+CT GU10 LED spots connected to WiFi Box Mi-Light IBOX V6 bridge (the 8 spots are connected to the bridge divided across 3 zones)
I found that running this set-up on a Raspberry Pi would probably have been easier, but I chose specifically for this set-up because my Synology NAS is running 24/7 anyway, and didn’t want to connect yet another device consuming power, even though I have multiple RPi’s in the house.
I’ve found that there are bits and pieces of instructions on the HA forums already, but no 1 guide to help for this particular set-up, which is why I wrote this guide. In case I missed something, or if anyone has any corrections or tips, I’d love to hear about them.
This guide is assuming you already have your lights set-up based on the instructions provided by Mi-Light (Or Limitless LED or Easybulb, they all appear to be the same thing).
1. Installing Docker and Home Assistant on your Synology NAS
For this first step I’ve found that this guide on the HA community forum works just fine: Installation - Home Assistant Follow the Synology section, and you should be able to have your Home Assistant instance up and running in no time.
2. Connecting your Mi-Lights to HA
This only works if you are using the iBOX like I am. Without an iBox the Mi-lights are only controllable via 2.4Ghz RF. With the iBox you can expose them to the network. To add this to your configuration.yaml, this guide is useful:
Easiest is to add the following to your configuration.yaml:
# Components:
Light: !include: lights.yaml
The lights.yaml is set-up like this:
Platform: limitlessled
Bridges:
- Host: <internal IP address of your bridge> 192.168.x.x
Version: 6
Port: 5987
Groups:
- number: 1
Type: rgbww
Name: livingroom
- number: 2
Type: rgbww
Name: diningroom
- number: 3
Type: rgbww
Name: mood
After having restarted HA, these lights should now show up in your HA GUI with simple on/off switches for each light, and if you click them you should be able to control color & brightness.
If you have the HA app installed on your smartphone you should be able to control your light from there as well now, but that doesn’t yet add much value as you could have done the same from the Mi-light app (even though that app isn’t the greatest)
3. Exposing your HA instance to the internet with dynamic DNS
The next step is to make sure you can connect to your HA instance from outside your own network. This is required by the Google Home app because, although the Google Home speaker sits on your internal WiFi, it seems to only use that to connect to the outside, and then needs a secured way back into your own network. The automatic set-up using Nabu Casa explained at the top of this page: Google Assistant - Home Assistant tells you just how to do that using the paid service with Home Assistant Cloud. This will cost you €5,- per month. Scrolling down on the same page you can find instructions for a manual set-up to achieve the same effect. This guide was very useful, but not 100% perfect for this particular set-up.
So let’s start by setting up a Dynamic DNS service for your Home Assistant. The why and how is explained here: Remote access - Home Assistant But in short it means converting your external facing IP address (Ask Google: “What’s my IP”) to a easy to remember url. Since your Internet Service Provider might change your external IP address every now and then, this so called Dynamic DNS service needs to be able to account for this periodic change. DuckDNS.org will help you accomplish that. It’s free, and after signing in with your Google account (or facebook or twitter) the instructions are fairly easy. Some more good info is explained under Step 3 in this article, but you don’t need to follow the addition to your configuration.yaml Installing TLS/SSL using Let's Encrypt - Community Guides - Home Assistant Community . However, I did end up adding the following to my configuration.yaml:
http:
base_url: mydomain.duckdns.org:8123
So you should now have your own domainname registered with duckdns.org in the form of a url that looks like: www.yourname.duckdns.org.
Don’t forget to follow the instructions on Duck DNS - install specifically for your Synology to do the periodic check if your IP has changed. Without it, this whole set-up was pointless.
For this periodic check to work you do need to make sure some ports on your firewall are open. Have a look at the next section to set-up all the ports you need for this entire set-up to work.
4. Opening up firewall ports
Assuming you have the same Linksys WRT1900ACS router as I do, follow these steps to forward the needed ports.
- After logging into your router, under ‘Router Settings’ click ‘Security’.
- Click the ‘Apps and Gaming’ tab.
- Click ‘single port forwarding’
- Click the ‘Add a new single port forwarding’ button.
- Fill in a name, an external port, an internal port, protocol, device ip (internal) and click save, and then ‘apply’.
- Repeat steps 2-5 for the other rules.
Rules needed:
-443 to 443 to the internal IP address of your Synology NAS
-8123 to 8123 to the internal IP address of your Synology NAS
-80 to 80 to the internal IP address of your Synology NAS
The protocol for these ports I’m not 100% sure of. I think they can all be set to TCP only, but if you’re not sure, use both. Ports 80 and 443 I have set to both. Port 8123 I have set to TCP only.
5. SSL certificate set-up
Synology provides an easy way to set-up a SSL certificate from ‘Letsencrypt’ without having to use the command line on your HA instance, and without having to alter anything in your configuration.yaml.
First, in your Synology DSM you need to install the package ‘Web Station’. You will not use any of it’s features, and this can be uninstalled later, but it is supposedly needed to allow the creation of a ‘Letsencrypt’ SSL certificate in the next step.
Next go to the ‘Security’ section of the DSM ‘Control Panel’ and click the tab ‘Certificate’. Click the ‘Add’ button, select ‘Add a new certificate’, click next, select ‘Get a new certificate from Let’s Encrypt’, click next, and for Domain name, fill in your new Duckdns domain name that you created under step 3. Email is your own email address and Subject Alternative Name doesn’t really matter, you can fill in the same domain name again.
6. Reverse Proxy
Next you need to set-up a Reverse proxy rule to effectively route the external traffic coming from the DuckDNS url to the ip address of your NAS followed by the correct port for HA.
Again Synology provides this functionality within the GUI (I do believe this functionality is not available in DSM under version 6.2).
In your Synology DSM, go to the Control Panel > Application Portal. Here you find the tab titled ‘Reverse Proxy’. You have to create 1 rule, choose a description, and for Source fill in the following:
Protocol: HTTPS
Hostname: Your DuckDNS URL (www.yourname.duckdns.org)
Port: 443Check: HSTS
Destination:
Protocol: HTTP
Hostname: The ip address of your Synology NAS
Port: 8123 (for HA)
After creating the new Reverse proxy rule, select it and click edit, and make sure under the ‘Custom Header’ tab, there are 2 entries for Connection and upgrade. If not, click create>Websocket to generate the 2 entries.
Once you have done this, go back to the Security>Certificate section of the DSM Control Panel, and after selecting your new Letsencrypt certificate, click ‘Configure’ and find your duckdns domain in the list and make sure the dropdown on the right has your new Letsencrypt certificate selected.
7. Setting up Google developers test app.
You’ve now taken care of all the prerequisites for your mi-light to work with HA and be reachable from the outside (some reboots of both your NAS and HA might be needed/useful at this point). Next you need to create the Google Assistant app to link your HA to your Google Home application on your phone (which controls your Google Home speaker). For this please follow the instructions on Google Assistant - Home Assistant.
Please note that this manual mentions migration to Home Assistant Release 0.80 or above. Upon initial set-up my HA was not on this level and I ran into connection problems which were magically solved once I upgraded my HA to the latest version (0.82.1). So make sure you do that first.
Follow the steps to create a new project on the Actions on Google console as mentioned in that guide. Once in the Actions on Google Console you have to get your project_id (explained here: New google_assistant component - #2 by FrenchToast )which is in the format: name-x0xx0. You’ll need this for your configuration.yaml. Also using the homegraph API functionality, you need to generate an API key which you will also need for your configuration.yaml. (This is explained in this thread here: Google Home , specifically in this section:
If you want to use the google_assistant.request_sync service in Home Assistant, then enable Homegraph API for your project:
_Go to https://console.cloud.google.com/apis/api/homegraph.googleapis.com/overview_
Select your project and click Enable Homegraph API
Go to Credentials and select API Key from Create Credentials
Note down the generated API Key and use this in the configuration)
8. Final steps
Now it’s time to configure your configuration.yaml. I was using notepad++ for editing my .yaml files, but have found “Visual Studio Code” to be more useful.
For Google Assistant, add the following entry to your configuration.yaml file:
Google_assistant:
Project_id: name-x0xx0
Api_key: api-key from Google Homegraph
Exposed_domains:
- light
Now when you go to the Google Home app on your smartphone as described in Google Assistant - Home Assistant, you should be able to find your own new project and connect to you Home Assistant instance and it should add your Mi-Lights automatically, from which point you can turn them on and off (or adjust color and brightness) by telling your Google Home speaker.
Enjoy!