Hello! I'm having an issue with the emulated hue component. Not sure if this is localized issue or something more widespread. In my quick googling, looks like Python doesn't like binding ports lower than 1024 or so without giving it more permissions as a privileged user.
I'm running HA in a venv via the All-In-One script.
Thanks much for any feedback and/or help!
Home Assistant release (hass --version
): 0.34.1
Python release (python3 --version
): 3.4.2
Component/platform:
Emulated Hue
Description of problem:
Emulated Hue won't start. Throwing an error in the log.
16-12-04 19:16:57 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/base_events.py", line 757, in create_server
sock.bind(sa)
PermissionError: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 235, in _step
result = coro.send(value)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/emulated_hue/__init__.py", line 99, in start_emulated_hue_bridge
yield from server.start()
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 309, in start
self._handler, self.server_host, self.server_port, ssl=context)
File "/usr/lib/python3.4/asyncio/base_events.py", line 761, in create_server
% (sa, err.strerror.lower()))
PermissionError: [Errno 13] error while attempting to bind on address ('192.168.1.126', 80): permission denied
Expected:
Emulated Hue runs
Problem-relevant configuration.yaml
entries and steps to reproduce:
emulated_hue:
type: google_home
listen_port: 80
It's actually a Linux safeguard. Binding to < 1024 requires being root. The solution is probably going to be making home-assistant understand how to drop privs back to a normal user after binding to the port.
One could also grant the capability to bind to privileged ports for the python binary in the virtualenv like
sudo setcap 'cap_net_bind_service=+ep' /srv/hass/bin/python3
@algorythmic, good call. The only issue is that to my knowledge sudo access is turned off inside the venv that the AiO script makes.
same here.
Also : sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8300
doesn't work for Google Home. In a web browser you get the valid response on http://192.168.2.192/description.xml but GH doesn't find it
@ronvl I think that is because it is being advertised on port 8300 if the config is set to 8300. What we would need support for is having the emulated_hue component think it is on port 80, but actually be bound to port 8300
as I'm not running virtuelenv I used:
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.4
and it works .... cool 馃憤
For people who are following this thread, after a little research the setcap command does work for the AiO method.
The magic sauce for people running HA in a venv via the AiO script is
sudo setcap 'cap_net_bind_service=+ep' /srv/hass/hass_venv/bin/python3
After running that, I was able to spin up the component no problem which both Google Home and the Amazon Echo can see. Sick!
@balloob, is this something that can be added to the component or would it be easiest to update the Emulated Hue component page?
Cheers!
I think this would fit best at the emulated_hue page
Sweet! I'll try and get a pull pulled together on that page soon. Cheers!
Hi,
I don't know if it's worth mentioning it but for fresh hassbian users they need to set the setcap command for launching the http component properly
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.4
What would be the equivalent command to get Google Home working on a Mac HA install?
Thanks Antexa - I needed that!
not working for me i cannot get google home to work the port 80 not working for me after using all commands
@mohaggag Google Home updated to require a Hue account to be registered to add Phillips hue devices. It is no longer possible to add new emulated hue setups to Google Home, but existing ones will still work.
We would have to register the Home Assistant as if it were a full fledged Phillips Hue hub tying into their cloud and everything in order to fix this problem.
This morning i setup HA and my google home it worked fine with my vera + emulated bridge. Had to run as root get get it to run over port 80 however.
@kerbysj how did you make it .. i got port 80 to work but emulated hue now using hue account as @demonspork mention so it cann't be done ..
Well i just setup the emulated hub on port 80 and then paired in google home and it all just worked...
Google Home example configuration.yaml entry
emulated_hue:
type: google_home
# Google Home does not work on different ports.
listen_port: 80
@kerbysj not sure how you did this as nobody else can. You can't bind to port 80 without being root or the above commands, and i just received a google home and you have to sign into Hue to add the device
I bought a google home specifically for HA, so really disappointed right now!
Most helpful comment
For people who are following this thread, after a little research the setcap command does work for the AiO method.
The magic sauce for people running HA in a venv via the AiO script is
After running that, I was able to spin up the component no problem which both Google Home and the Amazon Echo can see. Sick!
@balloob, is this something that can be added to the component or would it be easiest to update the Emulated Hue component page?
Cheers!