From f41aedc0f9ea35dd8f5b129ef4be8c1ce804ac7e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 12 Oct 2021 18:40:18 -1000 Subject: [PATCH] Fix single channel controllers with flux_led (#57458) --- homeassistant/components/flux_led/light.py | 12 +++--------- homeassistant/components/flux_led/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/flux_led/test_light.py | 14 ++------------ 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/flux_led/light.py b/homeassistant/components/flux_led/light.py index b587abcc7e6..885145c4b5c 100644 --- a/homeassistant/components/flux_led/light.py +++ b/homeassistant/components/flux_led/light.py @@ -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}") diff --git a/homeassistant/components/flux_led/manifest.json b/homeassistant/components/flux_led/manifest.json index dbff7aaac89..81648541106 100644 --- a/homeassistant/components/flux_led/manifest.json +++ b/homeassistant/components/flux_led/manifest.json @@ -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": [ diff --git a/requirements_all.txt b/requirements_all.txt index 57874bea5fd..874157d517b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 89e78f0af10..9a55702ad97 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/flux_led/test_light.py b/tests/components/flux_led/test_light.py index 1ddd79070b3..2931944343f 100644 --- a/tests/components/flux_led/test_light.py +++ b/tests/components/flux_led/test_light.py @@ -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."""