Emulated Hue instruction

I followed the instructions on Emulated Hue - Home Assistant

and use the simplest setting:

# Google Home example configuration.yaml entry
emulated_hue:
  type: google_home
  # Google Home does not work on different ports.
  listen_port: 80

but the last step, I cannot make it to work:

An additional step is required to run Home Assistant as non-root user and use port 80 when using the AiO script. Execute the following command to allow emulated_hue to use port 80 as non-root user.

sudo setcap ‘cap_net_bind_service=+ep’ /srv/homeassistant/homeassistant_venv/bin/python3

I got this error:

pi@raspberrypi:~ $ sudo setcap ‘cap_net_bind_service=+ep’ /srv/homeassistant/homeassistant_venv/bin/python3
Failed to set capabilities on file `/srv/homeassistant/homeassistant_venv/bin/python3’ (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file

Anyone knows what’s going on? What did I miss? Is there any other extra steps that I need to follow?

Ok so instead of

sudo setcap ‘cap_net_bind_service=+ep’ /srv/homeassistant/homeassistant_venv/bin/python3

I did:

sudo setcap ‘cap_net_bind_service=+ep’ /usr/bin/python3.4

And it works no error on that command line.

But when I restarted HA, I see this in HA logs:

17-02-02 23:04:50 WARNING (Thread-6) [homeassistant.components.emulated_hue] Listen IP address not specified, auto-detected address is 192.168.1.111
17-02-02 23:04:55 ERROR (MainThread) [homeassistant.components.http] Failed to create HTTP server at port 80: [Errno 98] Address already in use

I have HA setup with SSL so I’m not sure why port 80 has already been used…

Any pointers would be really helpful for me at this point.

Thank you.

VENVs are peculiar - if you don’t make the change inside the venv, HASS can’t see it.

For some reason, a couple versions ago, the path for HASS changed. Documentation hasn’t always caught up.

You want to run:

sudo setcap ‘cap_net_bind_service=+ep’ /srv/hass/hass_venv/bin/python3

I think when I installed mine, I named it “homeassistant” instead of using “hass” or something because now I only have

/srv/homeassistant/homeassistant_venv/bin/python3

Which I tried originally and I got immediate error on that sudo command line.

1 Like

Finally figured out.

When I installed php7 a while ago, it also installed apache2 and that’s why my port 80 was in used…

I stopped apache2 service and restarted HA and the emulated hue component works! I can pair it with Google Home. I don’t have any lights yet but this is a good start :slight_smile:

Thanks.

So I was following this thread here because I had the same problem with the command used for the AiO. I used the command you referenced here, and it seems the emulated_hue component is working (or at least broadcasting exposed domains) but all of a sudden I cannot access my front end.

Did this command change port settings to access my front end in anyway? Reason I ask is because the past couple of days, the only config changes I’ve made are with the emulated hue component. FYI - HASS is running and I can control a few things with remotes, etc. No errors in the log. Seems it’s running fine but I can’t access the front end. I use let’s encrypt with duck dns.

Sorry if this is vague, just curious if you had any insight.

I don’t have any advice if you’re not seeing anything in the logs. You might try temporarily disabling emulated_hue.

The emulated_hue component did have some changes recently, but that shouldn’t affect loading of the HASS UI.

I did try and disable the emulated hue component last night. Didn’t seem to change anything. Since HASS is running I can only assume it has something to do with let’s encrypt or duckdns, I’m just not sure what.

I did try going to http:<pi ip>:8123 for a shot in the dark, and it loads the login page for the front end. But when I type the password it says it’s incorrect.

I may try to renew certs with Let’s Encrypt tonight but if it doesn’t work I’m at a loss. Will post a new topic at that point.

For anyone else still having this issue here is what got it working for me:

I am running the Virtualenv setup.
I was able to see the “python3” file was there via my Windows machine.
But apparently it is a sym-link.
I ran the following command to find the actual file:

readlink -f /srv/homeassistant/bin/python3

I got the following output:

/usr/bin/python3.4

So I ran the setcap command on the actual file location:

sudo setcap ‘cap_net_bind_service=+ep’ /usr/bin/python3.4

2 Likes

Hi,

I’m struggling with the same issue. But nothing of what I’ve read here worked :frowning:

When I run:

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.4

I get the same message:

Failed to set capabilities on file `/usr/bin/python3.4' (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file

Any ideas? Thanks!

You need to run the “readlink -f /srv/homeassistant/bin/python3” command. Its most likely because now the response is “/usr/bin/python3.5”

I had PiHole running on port 80, I moved it on port 81.

My readlink output for me is /usr/local/bin/python3.6
Now… If I try sudo setcap ‘cap_net_bind_service=+ep’ /usr/local/bin/python3.6 I got the error

fatal error: Invalid argument
usage: setcap [-q] [-v] (-r|-|<caps>) <filename> [ … (-r|-|<capsN>) <filenameN> ]
Note <filename> must be a regular (non-symlink) file.

I’m sure that nothing is working on port 80 (sudo netstat -tulpn | grep :80). What could be my problem? Anyone could help me? Thanks!


Solved! The problem was the apostrophe before and after the cap_net_bing_service=+ep
I have to use the standard " ’ " and all works.
Have a nice day!

Would the command now be “readlink -f /srv/homeassistant/bin/python3.9.5” ?

Or just “…python3.9” ?

Can’t seem to get it to work. Thanks in advance!

I’m running homeassistant core and just in case this helps anyone I had the issue and went with:-
readlink -f /srv/homeassistant/bin/python3

it’ll probably return something like:-
/usr/local/bin/python3.8

then do this:-
sudo netstat -pnlt

If that seems to use a different python3.x for other services then that’s the one to use. Mine had 3.9 so
go with:-
sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/python3.9

Fingers crossed that it works.