Fix single channel controllers with flux_led (#57458)

pull/57546/head
J. Nick Koston 2021-10-12 18:40:18 -10:00 committed by GitHub
parent 2adb9a8bec
commit f41aedc0f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 24 deletions

View File

@ -30,14 +30,12 @@ from homeassistant.components.light import (
ATTR_RGB_COLOR,
ATTR_RGBW_COLOR,
ATTR_RGBWW_COLOR,
ATTR_WHITE,
COLOR_MODE_BRIGHTNESS,
COLOR_MODE_COLOR_TEMP,
COLOR_MODE_ONOFF,
COLOR_MODE_RGB,
COLOR_MODE_RGBW,
COLOR_MODE_RGBWW,
COLOR_MODE_WHITE,
EFFECT_COLORLOOP,
EFFECT_RANDOM,
PLATFORM_SCHEMA,
@ -102,7 +100,7 @@ FLUX_COLOR_MODE_TO_HASS: Final = {
FLUX_COLOR_MODE_RGBW: COLOR_MODE_RGBW,
FLUX_COLOR_MODE_RGBWW: COLOR_MODE_RGBWW,
FLUX_COLOR_MODE_CCT: COLOR_MODE_COLOR_TEMP,
FLUX_COLOR_MODE_DIM: COLOR_MODE_WHITE,
FLUX_COLOR_MODE_DIM: COLOR_MODE_BRIGHTNESS,
}
@ -406,10 +404,6 @@ class FluxLight(FluxEntity, CoordinatorEntity, LightEntity):
rgbcw = kwargs[ATTR_RGBWW_COLOR]
await self._device.async_set_levels(*rgbcw_to_rgbwc(rgbcw))
return
# Handle switch to White Color Mode
if ATTR_WHITE in kwargs:
await self._device.async_set_levels(w=kwargs[ATTR_WHITE])
return
if ATTR_EFFECT in kwargs:
effect = kwargs[ATTR_EFFECT]
# Random color effect
@ -455,8 +449,8 @@ class FluxLight(FluxEntity, CoordinatorEntity, LightEntity):
rgbwc = self.rgbwc_color
await self._device.async_set_levels(*rgbww_brightness(rgbwc, brightness))
return
# Handle White Color Mode and Brightness Only Color Mode
if self.color_mode in (COLOR_MODE_WHITE, COLOR_MODE_BRIGHTNESS):
# Handle Brightness Only Color Mode
if self.color_mode == COLOR_MODE_BRIGHTNESS:
await self._device.async_set_levels(w=brightness)
return
raise ValueError(f"Unsupported color mode {self.color_mode}")

View File

@ -3,7 +3,7 @@
"name": "Flux LED/MagicHome",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/flux_led",
"requirements": ["flux_led==0.24.3"],
"requirements": ["flux_led==0.24.4"],
"codeowners": ["@icemanch"],
"iot_class": "local_polling",
"dhcp": [

View File

@ -649,7 +649,7 @@ fjaraskupan==1.0.1
flipr-api==1.4.1
# homeassistant.components.flux_led
flux_led==0.24.3
flux_led==0.24.4
# homeassistant.components.homekit
fnvhash==0.1.0

View File

@ -381,7 +381,7 @@ fjaraskupan==1.0.1
flipr-api==1.4.1
# homeassistant.components.flux_led
flux_led==0.24.3
flux_led==0.24.4
# homeassistant.components.homekit
fnvhash==0.1.0

View File

@ -38,7 +38,6 @@ from homeassistant.components.light import (
ATTR_RGBW_COLOR,
ATTR_RGBWW_COLOR,
ATTR_SUPPORTED_COLOR_MODES,
ATTR_WHITE,
DOMAIN as LIGHT_DOMAIN,
)
from homeassistant.const import (
@ -633,8 +632,8 @@ async def test_white_light(hass: HomeAssistant) -> None:
assert state.state == STATE_ON
attributes = state.attributes
assert attributes[ATTR_BRIGHTNESS] == 128
assert attributes[ATTR_COLOR_MODE] == "white"
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["white"]
assert attributes[ATTR_COLOR_MODE] == "brightness"
assert attributes[ATTR_SUPPORTED_COLOR_MODES] == ["brightness"]
await hass.services.async_call(
LIGHT_DOMAIN, "turn_off", {ATTR_ENTITY_ID: entity_id}, blocking=True
@ -659,15 +658,6 @@ async def test_white_light(hass: HomeAssistant) -> None:
bulb.async_set_levels.assert_called_with(w=100)
bulb.async_set_levels.reset_mock()
await hass.services.async_call(
LIGHT_DOMAIN,
"turn_on",
{ATTR_ENTITY_ID: entity_id, ATTR_WHITE: 100},
blocking=True,
)
bulb.async_set_levels.assert_called_with(w=100)
bulb.async_set_levels.reset_mock()
async def test_rgb_light_custom_effects(hass: HomeAssistant) -> None:
"""Test an rgb light with a custom effect."""