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.