Alexa & Hue emulation group dimming not working

Hi there,

I’ve setup Home Assistant with Hue emulation & Alexa. This works fine except for dimming group.

Saying, alexa lights 50% will have her say that the device is not responding. From the logs:

17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights to 192.168.1.21 (auth: True)
17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights/state to 192.168.1.21 (auth: True)
17-03-16 17:53:42 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_server.py", line 62, in handle_request
    resp = yield from self._handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 270, in _handle
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/src/app/homeassistant/components/http/__init__.py", line 417, in handle
    result = yield from result
  File "/usr/src/app/homeassistant/components/emulated_hue/hue_api.py", line 157, in put
    parsed = parse_hue_api_put_light_body(request_json, entity)
  File "/usr/src/app/homeassistant/components/emulated_hue/hue_api.py", line 299, in parse_hue_api_put_light_body
    return (result, brightness) if report_brightness else (result, None)
UnboundLocalError: local variable 'report_brightness' referenced before assignment
17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /description.xml to 192.168.1.21 (auth: True)
17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /description.xml to 192.168.1.21 (auth: True)
17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights to 192.168.1.21 (auth: True)
17-03-16 17:53:42 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights to 192.168.1.21 (auth: True)
17-03-16 17:53:44 INFO (MainThread) [homeassistant.components.http] Serving /description.xml to 192.168.1.2 (auth: True)
17-03-16 17:53:44 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights to 192.168.1.21 (auth: True)
17-03-16 17:53:44 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights/state to 192.168.1.21 (auth: True)
17-03-16 17:53:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_server.py", line 62, in handle_request
    resp = yield from self._handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 270, in _handle
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/src/app/homeassistant/components/http/__init__.py", line 417, in handle
    result = yield from result
  File "/usr/src/app/homeassistant/components/emulated_hue/hue_api.py", line 157, in put
    parsed = parse_hue_api_put_light_body(request_json, entity)
  File "/usr/src/app/homeassistant/components/emulated_hue/hue_api.py", line 299, in parse_hue_api_put_light_body
    return (result, brightness) if report_brightness else (result, None)
UnboundLocalError: local variable 'report_brightness' referenced before assignment

On or Off works without a problem:

17-03-16 18:04:02 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights/state to 192.168.1.21 (auth: True)
17-03-16 18:04:02 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_data=entity_id=group.all_lights, service=turn_on, service_call_id=140314911787776-27, domain=homeassistant>
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_data=entity_id=['light.kitchen', 'light.livingroom', 'light.mainlight'], service=turn_on, service_call_id=140314911787776-28, domain=light>
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state light.kitchen=off; supported_features=63, friendly_name=Kitchen @ 2017-03-16T18:03:14.494564+01:00>, new_state=<state light.kitchen=on; supported_features=63, rgb_color=[255, 255, 255], brightness=127, color_temp=154, friendly_name=Kitchen @ 2017-03-16T18:04:03.009912+01:00>, entity_id=light.kitchen>
17-03-16 18:04:03 INFO (Thread-17) [limitlessled.pipeline] Starting a new pipeline on group 2 (Kitchen) @ 192.168.1.22
17-03-16 18:04:03 INFO (Thread-17) [limitlessled.pipeline]  -> Running stage 'on()' on group 2 (Kitchen) @ 192.168.1.22
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state group.all_lights=off; auto=True, order=0, entity_id=('light.kitchen', 'light.mainlight', 'light.livingroom'), hidden=True, friendly_name=all lights @ 2017-03-16T18:03:14.509613+01:00>, new_state=<state group.all_lights=on; auto=True, order=0, entity_id=('light.kitchen', 'light.mainlight', 'light.livingroom'), hidden=True, friendly_name=all lights @ 2017-03-16T18:04:03.014509+01:00>, entity_id=group.all_lights>
17-03-16 18:04:03 INFO (Thread-16) [limitlessled.pipeline] Starting a new pipeline on group 1 (Livingroom) @ 192.168.1.22
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state light.livingroom=off; supported_features=63, friendly_name=Livingroom @ 2017-03-16T18:03:14.503264+01:00>, new_state=<state light.livingroom=on; supported_features=63, rgb_color=[255, 255, 255], brightness=127, color_temp=154, friendly_name=Livingroom @ 2017-03-16T18:04:03.023355+01:00>, entity_id=light.livingroom>
17-03-16 18:04:03 INFO (Thread-16) [limitlessled.pipeline]  -> Running stage 'on()' on group 1 (Livingroom) @ 192.168.1.22
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state light.mainlight=off; supported_features=63, friendly_name=Mainlight @ 2017-03-16T18:03:14.506723+01:00>, new_state=<state light.mainlight=on; supported_features=63, rgb_color=[255, 255, 255], brightness=255, color_temp=154, friendly_name=Mainlight @ 2017-03-16T18:04:03.028887+01:00>, entity_id=light.mainlight>
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140314911787776-28>
17-03-16 18:04:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=140314911787776-27>
17-03-16 18:04:03 INFO (Thread-18) [limitlessled.pipeline] Starting a new pipeline on group 3 (Mainlight) @ 192.168.1.22
17-03-16 18:04:03 INFO (Thread-18) [limitlessled.pipeline]  -> Running stage 'on()' on group 3 (Mainlight) @ 192.168.1.22
17-03-16 18:04:03 INFO (MainThread) [homeassistant.components.http] Serving /api/mt88AMOlIDhyLRBHFA9NwfDoFgvdPhW4cWdc68eR/lights/group.all_lights to 192.168.1.21 (auth: True)
17-03-16 18:04:03 INFO (Thread-17) [limitlessled.pipeline]  -> Running stage 'white()' on group 2 (Kitchen) @ 192.168.1.22
17-03-16 18:04:03 INFO (Thread-16) [limitlessled.pipeline]  -> Running stage 'white()' on group 1 (Livingroom) @ 192.168.1.22
17-03-16 18:04:03 INFO (Thread-18) [limitlessled.pipeline]  -> Running stage 'white()' on group 3 (Mainlight) @ 192.168.1.22
17-03-16 18:04:04 INFO (Thread-17) [limitlessled.pipeline]  -> Running stage 'transition(0, temperature=0.0, brightness=0.4980392156862745)' on group 2 (Kitchen) @ 192.168.1.22
17-03-16 18:04:04 INFO (Thread-16) [limitlessled.pipeline]  -> Running stage 'transition(0, temperature=0.0, brightness=0.4980392156862745)' on group 1 (Livingroom) @ 192.168.1.22
17-03-16 18:04:04 INFO (Thread-18) [limitlessled.pipeline]  -> Running stage 'transition(0, temperature=0.0, brightness=1.0)' on group 3 (Mainlight) @ 192.168.1.22
17-03-16 18:04:06 INFO (Thread-17) [limitlessled.pipeline] Finished pipeline on group 2 (Kitchen) @ 192.168.1.22
17-03-16 18:04:06 INFO (Thread-16) [limitlessled.pipeline] Finished pipeline on group 1 (Livingroom) @ 192.168.1.22
17-03-16 18:04:06 INFO (Thread-18) [limitlessled.pipeline] Finished pipeline on group 3 (Mainlight) @ 192.168.1.22

Does dimming the light using the slider work correctly?

Actually I’m not sure as I only tested the standard ‘all lights’ group. However I found a open git issue

https://github.com/home-assistant/home-assistant/issues/4066

As a workaround I created groups in Alexa and that works fine.