Philips Hue - bad request with API v2

Hey folks. I’ll raise a bug too, but I was wondering if anyone else had seen the same thing?

Since installing 2021.12, I’ve been getting the below error(s) when triggering my automations to turn on the lights. Other errors are similar, but include different scripts that were called and different Hue api v2 URLS.

Thanks in advance … hoping it’s not just me! haha.

Logger: homeassistant.components.script.turn_on_hallway_lights
Source: components/hue/bridge.py:132 
Integration: Scripts (documentation, issues) 
First occurred: 7:03:51 am (1 occurrences) 
Last logged: 7:03:51 am

Turn on the Hallway Lights: Error executing script. Unexpected error for call_service at pos 1: 400, message='Bad Request', url=URL('https://192.168.1.72/clip/v2/resource/light/e5b94e29-18ef-4f3d-ad1e-63b7df075b40')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 494, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/group.py", line 175, in async_turn_on
    await self.bridge.async_request_call(
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 132, in async_request_call
    return await task(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/lights.py", line 85, in set_state
    await self._send_put(id, update_obj)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 137, in _send_put
    await self._bridge.request("put", endpoint, json=data)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 152, in request
    async with self.create_request(method, path, **kwargs) as resp:
  File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
    return await self.gen.__anext__()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 182, in create_request
    res.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://192.168.1.72/clip/v2/resource/light/e5b94e29-18ef-4f3d-ad1e-63b7df075b40')

1 Like

I have started to see this issue in 2021.12.0 and it is still present in 2021.12.1 using the Circadian Lighting custom component. I’ve opened an issue on the component page but this makes me think it may be a core issue.

So it turned out for me that in night mode via the adaptive lighting component, I had the min colour temp too low - it was set at a 1000 Kelvin. It seems that this in turn was lower than the Hues could go and would cause a 400 error. I upped the night time colour temp to 2000 and the error is gone, everything works again. Woo!

Big thanks to Marcel van der Veldt for helping me out via GitHub. :beer::beer::beer:

Same issue for me. Even making the call directly. Usually happening for rooms specifically.

Facing the same issue since my 2021.12 update. Is there any way to troubleshoot this problem?

I have a script which turns multiple Hue lights on by only setting the brightness. This now fails because of the 400 Baf Gateway response.
I’m kinda clueless as to what could go wrong there.