Emulated Hue with Alexa

Getting some errors trying to set up Emulated Hue. I have this in my config:

emulated_hue:
  expose_by_default: true
  exposed_domains:
    - switch
    - light

When I go to the IP to check status xxx:8300/api/homeassistant/lights, I get:
500 Internal Server Error

Server got itself in trouble

At the same time in my log:
2017-08-08 11:00:29 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py”, line 422, in start
resp = yield from self._request_handler(request)
File “/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web.py”, line 306, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/init.py”, line 421, in handle
result = handler(request, **request.match_info)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/emulated_hue/hue_api.py”, line 78, in get
number = self.config.entity_id_to_number(entity.entity_id)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/emulated_hue/init.py”, line 196, in entity_id_to_number
number = str(max(int(k) for k in self.numbers) + 1)
ValueError: max() arg is an empty sequence

I have my HASS installed in virtualenv, so I did the:
sudo setcap ‘cap_net_bind_service=+ep’ /srv/homeassistant/bin/python3

After some more searching, I found that I had to add the type to my config:

emulated_hue:
  type: alexa
  expose_by_default: true
  exposed_domains:
    - switch
    - light

I can now see the devices in the link as provided, but still nothing in the Alexa app

You didn’t need that setcap thing, that’s only for Google Home’s that use port 80, the Alexa setting uses 8300. However, the Alexa version is deprecated and using the Google Home one is recommended for both, this is what I use…

emulated_hue:
  type: google_home
  expose_by_default: false
  listen_port: 8300

Have you tried turning off global expose and just adding one switch to see if that works. There is a limit to the number Alexa can handle which I believe is 40 odd

Thanks Bobby,

When I remove the type, the errors as described in my first post come back. In addition to a warning:

2017-08-08 11:35:35 WARNING (Thread-2) [homeassistant.components.emulated_hue] When targetting Google Home, listening port has to be port 80

You can ignore that new one, literally just a warning and not relevant to using with Alexa.

What version of HA are you using?

Gotya, I am using 0.50.2

Found this in relation to the same error but looks like that problem has been fixed in the current version :man_shrugging:

Strange. I will keep looking for a solution. Thanks for the help so far.

Did you try defining the listening port as 8300?

Yes sir!

emulated_hue:
  host_ip: 10.0.xxx
  listen_port: 8300
  expose_by_default: true
  exposed_domains:
    - switch
    - light

Doh…meant to add this

I can’t, for the life of me, find the location of the json…

So to recap. I readded type Alexa in the config. I can now access the xx:8300/api/homeassistant/lights and see a bunch of equipment. But still no luck when trying to discover with Alexa.

I shouldn’t have to add a Smart Home Skill right?
Thanks!

Okay. Some progress. Looking at the results I had on xx:8300/api/homeassistant/lights, and some examples online it didn’t match up.

So I then added the emulated_hue_ids.json (with one entry) to my /.homeassistant folder. Now the results look better on the xx:8300/api/homeassistant/lights and xx:8300/description.xml.

But I am still not able to discover anything in my Alexa app. Still unsure if I have to enable a skill…

Definitely no skill needed.

It should just work, I literally stuck the config in I shared above and after a restart everything instantly appeared to Alexa and Harmony. That was on a Mac Mini and I’ve recently done it to a clean install of Hass.io with the same results.

mmm, strange. I may have to make the transition to hass.io :).

Is there still the limit of 49 entities?

Not aware it’s changed, that’s why some people use multiple instances of emulated_hue.

I’m very happy with it, the add-ons system makes it a piece of cake to add functions I’ve been unsure on trying and gives a no effort more secure environment.

You just need to be sure the add-ons you want either exist already (the most popular ones do), be happy to wait for it or create it yourself!

The buzz of being part of something very new is fun too :slight_smile:

Were you able to fix this issue?

how? Does it work?

p.s. Now I use this custom component, but is not maintained by the developer and I think is notworking in HASS.IO