OH2 - HueEmulation - Alexa: Not Authorized Error

In an attempt to control my OH2 items via Alexa, I’ve performed the following steps.

  1. Added the HueEmulation service via Paper UI.
  2. Added items to my items file.
    Switch Light_Toy_Room "Switch [%s]" <switch> [ "he:Toy Room Lights" ] {zwave_device_222e6520_node2_switch_binary} (various groups)
  3. Added to hueemulation.cfg
  4. Enabled HE DEBUG logging by adding the following to runtime.cfg
    log:set DEBUG org.openhab.io.hueemulation
  5. Restarted OH2 Debug Version
    sudo ./start_dbug.sh

Tailing the log I can see the following.

13:01:52.943 [DEBUG] [org.openhab.io.hueemulation         ] - BundleEvent STARTING - org.openhab.io.hueemulation
13:01:53.029 [DEBUG] [ulation.internal.HueEmulationServlet] - Device pairing enabled : false
13:01:53.110 [DEBUG] [org.openhab.io.hueemulation         ] - ServiceEvent REGISTERED - {javax.servlet.ServletContext}={osgi.web.symbolicname=org.openhab.io.hueemulation, osgi.web.version=, osgi.web.contextpath=/, service.id=336, service.bundleid=203, service.scope=singleton} - org.openhab.io.hueemulation
13:01:53.120 [INFO ] [ulation.internal.HueEmulationServlet] - Started Hue Emulation service at /api
13:01:53.123 [DEBUG] [org.openhab.io.hueemulation         ] - ServiceEvent REGISTERED - {javax.servlet.http.HttpServlet}={service.pid=org.openhab.hueemulation, service.config.category=io, service.config.label=Hue Emulation, component.name=org.openhab.hueemulation, component.id=191, paringEnabled=true, org.openhab.hueemulation.paringEnabled=true, service.config.description.uri=io:hueemulation, service.id=335, service.bundleid=203, service.scope=bundle} - org.openhab.io.hueemulation
13:01:53.126 [DEBUG] [org.openhab.io.hueemulation         ] - BundleEvent STARTED - org.openhab.io.hueemulation

I’m concerned that I’m not in Pairing mode, because even with the paringEnabled=true, org.openhab.hueemulation.paringEnabled=true options, I don’t see a DEBUG message that states the Device paring enabled: true.

13:33:03.807 [DEBUG] [ulation.internal.HueEmulationServlet] - GET /api/discovery.xml
13:33:26.362 [DEBUG] [ulation.internal.HueEmulationServlet] - GET /api/devices
13:33:26.366 [DEBUG] [ulation.internal.HueEmulationServlet] - apiServerError 1 Not Authorized

I can see in the log the discovery.xml is served, but when I attempted to GET the devices, I am refused with the following error in the browser.

{"error":{"type":1,"address":"/api/devices","description":"Not Authorized"}}

The last clue is when I attempt to set the Pairing Enabled in Hue Emulation via the Paper Services IO Configuration, I get an ERROR 500 Internal Server Error.

Nothing is written to the Debug Console, and no other errors are returned.

Do have a real server error, or is this an authorized user Hue Bridge issue?

UPDATE: I used the REST interface to query the HE Config.

The Response shows that Pairing is Enabled.

  "org.openhab.hueemulation.paringEnabled": "true",
  "paringEnabled": "true"

I went into the Config via the REST api, and removed the two configs above. Then I performed a POST to correctly set the ParingEnabled using the following.

Then I confirmed the configuration in the DEBUG output.
14:09:16.325 [DEBUG] [ulation.internal.HueEmulationServlet] - Device pairing enabled : true
14:09:16.350 [DEBUG] [org.openhab.io.hueemulation ] - ServiceEvent MODIFIED - {javax.servlet.http.HttpServlet}={service.pid=org.openhab.hueemulation, service.config.category=io, service.config.label=Hue Emulation, component.name=org.openhab.hueemulation, component.id=191, pairingEnabled=true, service.config.description.uri=io:hueemulation, service.id=339, service.bundleid=203, service.scope=bundle} - org.openhab.io.hueemulation

I now get a partial response from the /api/devices page.

Still no Joy when attempting to discover devices via Alexa. And shouldn’t I now see my configured Items?

Suggestions welcomed!


I think I’ve progresses past these items now.

Once I got the Pairing Enabled set properly (had to use a REST call directly). Then I had to switch my item definition to Switchable. At that point, only the first item was returned successfully. So I deduced that there was a problem with the Groups listed in the parenthesis that must be causing a problem. Here is an updated example of my Items (switched to Groups).

Switch Light_Toy_Room “Switch [%s]” [ “he:Toy Room Lights” ] {zwave_device_222e6520_node2_switch_binary} (various groups)

Group:Switch:OR(ON,OFF) Lights_Kids_Rooms “Kids Room Lights” [“Switchable”]
Group:Switch:OR(ON,OFF) Lights_Family_Room “Family Room Lights” [“Switchable”]
Group:Switch:OR(ON,OFF) Lights_Dining_Room “Dining Room Lights” [“Switchable”]

Then I referenced these groups in the Switch Item definitions lower in the file.

At this point, I have 9 Lights defined and surfaced via HE.

My last part is that the Item mappings (zwave) appear to have been switched or jumbled in some manner. I’m not sure if the Controller is borked, or what, but that’s where I am now.

Latest Log
2016-10-05 15:37:24.754 [DEBUG] [ulation.internal.HueEmulationServlet] - PUT /api/7GCr2jRdiDfI8lsJrfDi1GjoQhcIznW9GvIbGuac/lights/Lights_Family_Room/state
2016-10-05 15:37:24.785 [DEBUG] [ulation.internal.HueEmulationServlet] - State [on: true bri: -1 hue: 0 sat: 0 xy: {0.0 0.0 } ct: 500 alert: none effect: none colormode: ct reachable: true
2016-10-05 15:37:24.898 [DEBUG] [ulation.internal.HueEmulationServlet] - GET /api/7GCr2jRdiDfI8lsJrfDi1GjoQhcIznW9GvIbGuac/lights/Lights_Family_Room
2016-10-05 15:37:39.940 [DEBUG] [ulation.internal.HueEmulationServlet] - PUT /api/7GCr2jRdiDfI8lsJrfDi1GjoQhcIznW9GvIbGuac/lights/Lights_Dining_Room/state
2016-10-05 15:37:39.945 [DEBUG] [ulation.internal.HueEmulationServlet] - State [on: true bri: -1 hue: 0 sat: 0 xy: {0.0 0.0 } ct: 500 alert: none effect: none colormode: ct reachable: true
2016-10-05 15:37:40.097 [DEBUG] [ulation.internal.HueEmulationServlet] - GET /api/7GCr2jRdiDfI8lsJrfDi1GjoQhcIznW9GvIbGuac/lights/Lights_Dining_Room

I ended up resetting my Z-Wave controller andthe ID’S returned to normal.

Case closed.

Hmm im am still seeing the 500 errors when i try to add the devices.

I get data from

Any ideas?

1 0 urn:schemas-upnp-org:device:Basic:1 openHAB Hue Emulation Royal Philips Electronics http://www.philips.com Philips hue Personal Wireless Lighting Philips hue bridge 2015 929000226503 http://www.meethue.com 0017880ae670 uuid:04a6034d-c314-4c71-9dcb-fae2d9a2a8c3 (null) (null) (null) (null) (null) index.html image/png 48 48 24 hue_logo_0.png image/png 120 120 24 hue_logo_3.png