Sunday, 3 December 2017

Home Assistant Hue Emulation

My Home Assistant setup uses nginx to proxy the web interface to HTTPS. I bought a Google Assistant for black friday and I want it to be able to control my lights... I haven't tested it yet but I figure I may as well start doing some setup!

The Home Assistant docs say that the emulated_hue component needs to run on port 80. This won't work by default because it doesn't have root permissions. I also didn't want to grant python the ability using cap_net_bind. My solution in the end was to create a NAT firewall rule on my server (see the end of this post). This takes anything that comes in via TCP on port 80 and redirects it to port 8300 (which is the port that Home Assistant was told to use for the emulated hue).

The issue with this is that nothing else that uses port 80 will work anymore - in particular nginx pages such as pi-hole. I figured I could just run pi-hole through HTTPS!

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8300

and for localhost redirects too (optional):

sudo iptables -t nat -I OUTPUT -p tcp -d --dport 80 -j REDIRECT --to-ports 8300

To remove these rules:

iptables -t nat --line-numbers -n -L

No comments:

Post a Comment

Home Assistant + Node-RED with BTRFS on Arch

After using Home Assistant for a few months and having set it up to use external MySQL databases, etc. I have decided to re-install in a rob...