home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.81k forks source link

Flux in mired mode not working with Philips Hue in 2021.12 #62842

Closed fabianschaefer closed 2 years ago

fabianschaefer commented 2 years ago

The problem

Since updating to Version 2021.12.5 (I directly updated to .5 from the last major release) Flux stopped working in mired mode. The issue only appears during night times when Flux return mired values >500. It looks like the light.turn_on function only accepts values up to 500. It worked before this update, so it might be caused by the new Philips Hue component which checks if this value is within the accepted range. So either Flux needs to be fixed in order to not return mired values over 500 or the Hue Integration should allow such values.

What version of Home Assistant Core has the issue?

core-2021.12.5

What was the last working version of Home Assistant Core?

core-2021.11

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips Hue, Flux

Link to integration documentation on our website

https://www.home-assistant.io/integrations/flux/ https://www.home-assistant.io/integrations/hue/

Example YAML snippet

switch:
  - platform: flux
    lights:
      - light.bedroom
    name: bedroom_flux
    disable_brightness_adjust: true
    mode: mired
    transition: 5

Anything in the logs that might be useful for us?

Logger: homeassistant.core
Source: components/hue/bridge.py:117 
First occurred: 26. Dezember 2021, 23:12:35 (38 occurrences) 
Last logged: 00:33:09

Error executing service: <ServiceCall light.turn_on (c:a377793f3fcc94ca2e7f6b03ada72aaa): entity_id=['light.bedroom'], params=color_temp=526, transition=5.0>

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1511, in catch_exceptions
    await coro_or_task
  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 177, in async_turn_on
    await self.bridge.async_request_call(
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 117, in async_request_call
    return await task(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/lights.py", line 80, in set_state
    await self.update(id, update_obj)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 146, in update
    await self._bridge.request("put", endpoint, json=data)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 182, in request
    resp.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.2.101/clip/v2/resource/light/cbf2251c-3119-406f-bd25-4661869d417c')

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

flux documentation flux source (message by IssueLinks)

marcelveldt commented 2 years ago

Hmm, I think the Flux integration should be fixed as it sends values outside the range of the light. I can put a fix in the Hue integration but maybe other integrations are impacted by this too.

The min/max values are reported for each light as state attributes so can easily be checked.

fabianschaefer commented 2 years ago

@marcelveldt I’m with you, that the root cause should be fixed in Flux. But would it make sense to make sure that no higher/lower value than the max/min value is sent to the Hue API. That would make the Hue integration a bit more robust and will make sure it can even handle invalid inputs. Something similar is already implemented with other parameters like brightness. If I call the light.turn_on with a brightness value of >255, it will just set it to the maximum instead of throwing an error.