Remove white_value support from light ()

pull/76986/head
Erik Montnemery 2022-08-18 14:21:05 +02:00 committed by GitHub
parent f0deaa33a0
commit 60c8d95a77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 19 additions and 291 deletions

View File

@ -24,7 +24,6 @@ from homeassistant.const import (
CONF_PASSWORD,
CONF_URL,
CONF_USERNAME,
CONF_WHITE_VALUE,
Platform,
)
from homeassistant.core import HomeAssistant
@ -45,6 +44,7 @@ CONF_DIMMING = "dimming"
CONF_GATEWAYS = "gateways"
CONF_PLUGINS = "plugins"
CONF_RESET_COLOR = "reset_color"
CONF_WHITE_VALUE = "white_value"
FIBARO_CONTROLLER = "fibaro_controller"
FIBARO_DEVICES = "fibaro_devices"
PLATFORMS = [

View File

@ -15,7 +15,6 @@ from homeassistant.components.light import (
ATTR_COLOR_TEMP,
ATTR_RGB_COLOR,
ATTR_TRANSITION,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN as LIGHT_DOMAIN,
VALID_TRANSITION,
@ -101,7 +100,6 @@ async def async_set_lights_xy(hass, lights, x_val, y_val, brightness, transition
service_data[ATTR_XY_COLOR] = [x_val, y_val]
if brightness is not None:
service_data[ATTR_BRIGHTNESS] = brightness
service_data[ATTR_WHITE_VALUE] = brightness
if transition is not None:
service_data[ATTR_TRANSITION] = transition
await hass.services.async_call(LIGHT_DOMAIN, SERVICE_TURN_ON, service_data)

View File

@ -59,7 +59,6 @@ SUPPORT_EFFECT = 4
SUPPORT_FLASH = 8
SUPPORT_COLOR = 16 # Deprecated, replaced by color modes
SUPPORT_TRANSITION = 32
SUPPORT_WHITE_VALUE = 128 # Deprecated, replaced by color modes
# Color mode of the light
ATTR_COLOR_MODE = "color_mode"
@ -202,7 +201,6 @@ ATTR_KELVIN = "kelvin"
ATTR_MIN_MIREDS = "min_mireds"
ATTR_MAX_MIREDS = "max_mireds"
ATTR_COLOR_NAME = "color_name"
ATTR_WHITE_VALUE = "white_value"
ATTR_WHITE = "white"
# Brightness of the light, 0..255 or percentage
@ -274,7 +272,6 @@ LIGHT_TURN_ON_SCHEMA = {
vol.Coerce(tuple), vol.ExactSequence((cv.small_float, cv.small_float))
),
vol.Exclusive(ATTR_WHITE, COLOR_GROUP): VALID_BRIGHTNESS,
ATTR_WHITE_VALUE: vol.All(vol.Coerce(int), vol.Range(min=0, max=255)),
ATTR_FLASH: VALID_FLASH,
ATTR_EFFECT: cv.string,
}
@ -341,8 +338,6 @@ def filter_turn_on_params(light, params):
params.pop(ATTR_FLASH, None)
if not supported_features & LightEntityFeature.TRANSITION:
params.pop(ATTR_TRANSITION, None)
if not supported_features & SUPPORT_WHITE_VALUE:
params.pop(ATTR_WHITE_VALUE, None)
supported_color_modes = (
light._light_internal_supported_color_modes # pylint:disable=protected-access
@ -421,16 +416,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
light._light_internal_supported_color_modes # pylint: disable=protected-access
)
supported_color_modes = light.supported_color_modes
# Backwards compatibility: if an RGBWW color is specified, convert to RGB + W
# for legacy lights
if ATTR_RGBW_COLOR in params:
if (
ColorMode.RGBW in legacy_supported_color_modes
and not supported_color_modes
):
rgbw_color = params.pop(ATTR_RGBW_COLOR)
params[ATTR_RGB_COLOR] = rgbw_color[0:3]
params[ATTR_WHITE_VALUE] = rgbw_color[3]
# If a color temperature is specified, emulate it if not supported by the light
if ATTR_COLOR_TEMP in params:
@ -544,9 +529,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
params[ATTR_WHITE] = params.pop(ATTR_BRIGHTNESS, params[ATTR_WHITE])
# Remove deprecated white value if the light supports color mode
if supported_color_modes:
params.pop(ATTR_WHITE_VALUE, None)
if params.get(ATTR_BRIGHTNESS) == 0 or params.get(ATTR_WHITE) == 0:
await async_handle_light_off_service(light, call)
else:
@ -786,12 +768,6 @@ class LightEntity(ToggleEntity):
# Add warning in 2021.6, remove in 2021.10
supported = self._light_internal_supported_color_modes
if (
ColorMode.RGBW in supported
and self.white_value is not None
and self.hs_color is not None
):
return ColorMode.RGBW
if ColorMode.HS in supported and self.hs_color is not None:
return ColorMode.HS
if ColorMode.COLOR_TEMP in supported and self.color_temp is not None:
@ -828,19 +804,6 @@ class LightEntity(ToggleEntity):
def _light_internal_rgbw_color(self) -> tuple[int, int, int, int] | None:
"""Return the rgbw color value [int, int, int, int]."""
rgbw_color = self.rgbw_color
if (
rgbw_color is None
and self.hs_color is not None
and self.white_value is not None
):
# Backwards compatibility for rgbw_color added in 2021.4
# Add warning in 2021.6, remove in 2021.10
r, g, b = color_util.color_hs_to_RGB( # pylint: disable=invalid-name
*self.hs_color
)
w = self.white_value # pylint: disable=invalid-name
rgbw_color = (r, g, b, w)
return rgbw_color
@property
@ -867,11 +830,6 @@ class LightEntity(ToggleEntity):
# https://developers.meethue.com/documentation/core-concepts
return self._attr_max_mireds
@property
def white_value(self) -> int | None:
"""Return the white value of this light between 0..255."""
return None
@property
def effect_list(self) -> list[str] | None:
"""Return the list of supported effects."""
@ -982,13 +940,6 @@ class LightEntity(ToggleEntity):
# Add warning in 2021.6, remove in 2021.10
data[ATTR_COLOR_TEMP] = self.color_temp
if supported_features & SUPPORT_WHITE_VALUE and not self.supported_color_modes:
# Backwards compatibility
# Add warning in 2021.6, remove in 2021.10
data[ATTR_WHITE_VALUE] = self.white_value
if self.hs_color is not None:
data.update(self._light_internal_convert_color(ColorMode.HS))
if supported_features & LightEntityFeature.EFFECT:
data[ATTR_EFFECT] = self.effect
@ -1009,8 +960,6 @@ class LightEntity(ToggleEntity):
supported_color_modes.add(ColorMode.COLOR_TEMP)
if supported_features & SUPPORT_COLOR:
supported_color_modes.add(ColorMode.HS)
if supported_features & SUPPORT_WHITE_VALUE:
supported_color_modes.add(ColorMode.RGBW)
if supported_features & SUPPORT_BRIGHTNESS and not supported_color_modes:
supported_color_modes = {ColorMode.BRIGHTNESS}

View File

@ -31,7 +31,6 @@ from . import (
ATTR_RGBWW_COLOR,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN,
ColorMode,
@ -46,7 +45,6 @@ ATTR_GROUP = [
ATTR_BRIGHTNESS_PCT,
ATTR_EFFECT,
ATTR_FLASH,
ATTR_WHITE_VALUE,
ATTR_TRANSITION,
]
@ -157,8 +155,6 @@ async def _async_reproduce_state(
state.attributes.get(ATTR_COLOR_MODE, ColorMode.UNKNOWN)
!= ColorMode.UNKNOWN
):
# Remove deprecated white value if we got a valid color mode
service_data.pop(ATTR_WHITE_VALUE, None)
color_mode = state.attributes[ATTR_COLOR_MODE]
if color_mode_attr := COLOR_MODE_TO_ATTRIBUTE.get(color_mode):
if color_mode_attr.state_attr not in state.attributes:

View File

@ -531,14 +531,6 @@ toggle:
max: 6500
step: 100
unit_of_measurement: K
white_value:
name: White level
description: Number indicating level of white.
advanced: true
selector:
number:
min: 0
max: 255
brightness:
name: Brightness value
description: Number indicating brightness, where 0 turns the light

View File

@ -6,13 +6,7 @@ from typing import Any
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.significant_change import check_absolute_change
from . import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_WHITE_VALUE,
)
from . import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR
@callback
@ -56,12 +50,4 @@ def async_check_significant_change(
):
return True
if check_absolute_change(
# Range 0..255
old_attrs.get(ATTR_WHITE_VALUE),
new_attrs.get(ATTR_WHITE_VALUE),
5,
):
return True
return False

View File

@ -38,7 +38,6 @@ from homeassistant.const import (
CONF_NAME,
CONF_OPTIMISTIC,
CONF_RGB,
CONF_WHITE_VALUE,
CONF_XY,
STATE_ON,
)
@ -97,6 +96,8 @@ CONF_FLASH_TIME_SHORT = "flash_time_short"
CONF_MAX_MIREDS = "max_mireds"
CONF_MIN_MIREDS = "min_mireds"
CONF_WHITE_VALUE = "white_value"
def valid_color_configuration(config):
"""Test color_mode is not combined with deprecated config."""

View File

@ -262,7 +262,6 @@ CONF_WHILE: Final = "while"
CONF_WHITELIST: Final = "whitelist"
CONF_ALLOWLIST_EXTERNAL_DIRS: Final = "allowlist_external_dirs"
LEGACY_CONF_WHITELIST_EXTERNAL_DIRS: Final = "whitelist_external_dirs"
CONF_WHITE_VALUE: Final = "white_value"
CONF_XY: Final = "xy"
CONF_ZONE: Final = "zone"

View File

@ -1378,10 +1378,6 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
function_name="max_mireds",
return_type="int",
),
TypeHintMatch(
function_name="white_value",
return_type=["int", None],
),
TypeHintMatch(
function_name="effect_list",
return_type=["list[str]", None],
@ -1421,7 +1417,6 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
"transition": "float | None",
"xy_color": "tuple[float, float] | None",
"white": "int | None",
"white_value": "int | None",
},
kwargs_type="Any",
return_type=None,

View File

@ -25,7 +25,6 @@ from homeassistant.components.light import (
ATTR_SUPPORTED_COLOR_MODES,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN as LIGHT_DOMAIN,
SERVICE_TOGGLE,
@ -78,7 +77,6 @@ async def test_default_state(hass):
assert state.attributes.get(ATTR_BRIGHTNESS) is None
assert state.attributes.get(ATTR_HS_COLOR) is None
assert state.attributes.get(ATTR_COLOR_TEMP) is None
assert state.attributes.get(ATTR_WHITE_VALUE) is None
assert state.attributes.get(ATTR_EFFECT_LIST) is None
assert state.attributes.get(ATTR_EFFECT) is None

View File

@ -18,7 +18,6 @@ from homeassistant.components.light import (
ATTR_RGBWW_COLOR,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN,
)
@ -46,7 +45,6 @@ def turn_on(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
@ -68,7 +66,6 @@ def turn_on(
hs_color,
color_temp,
kelvin,
white_value,
profile,
flash,
effect,
@ -90,7 +87,6 @@ async def async_turn_on(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
@ -113,7 +109,6 @@ async def async_turn_on(
(ATTR_HS_COLOR, hs_color),
(ATTR_COLOR_TEMP, color_temp),
(ATTR_KELVIN, kelvin),
(ATTR_WHITE_VALUE, white_value),
(ATTR_FLASH, flash),
(ATTR_EFFECT, effect),
(ATTR_COLOR_NAME, color_name),
@ -158,7 +153,6 @@ def toggle(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
@ -177,7 +171,6 @@ def toggle(
hs_color,
color_temp,
kelvin,
white_value,
profile,
flash,
effect,
@ -196,7 +189,6 @@ async def async_toggle(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
@ -216,7 +208,6 @@ async def async_toggle(
(ATTR_HS_COLOR, hs_color),
(ATTR_COLOR_TEMP, color_temp),
(ATTR_KELVIN, kelvin),
(ATTR_WHITE_VALUE, white_value),
(ATTR_FLASH, flash),
(ATTR_EFFECT, effect),
(ATTR_COLOR_NAME, color_name),

View File

@ -48,7 +48,6 @@ async def test_methods(hass):
light.ATTR_XY_COLOR: "xy_color_val",
light.ATTR_PROFILE: "profile_val",
light.ATTR_COLOR_NAME: "color_name_val",
light.ATTR_WHITE_VALUE: "white_val",
},
blocking=True,
)
@ -65,7 +64,6 @@ async def test_methods(hass):
assert call.data.get(light.ATTR_XY_COLOR) == "xy_color_val"
assert call.data.get(light.ATTR_PROFILE) == "profile_val"
assert call.data.get(light.ATTR_COLOR_NAME) == "color_name_val"
assert call.data.get(light.ATTR_WHITE_VALUE) == "white_val"
# Test turn_off
turn_off_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_OFF)
@ -125,7 +123,6 @@ async def test_services(hass, mock_light_profiles, enable_custom_integrations):
light.SUPPORT_COLOR
| light.LightEntityFeature.EFFECT
| light.LightEntityFeature.TRANSITION
| light.SUPPORT_WHITE_VALUE
)
ent3.supported_features = (
light.LightEntityFeature.FLASH | light.LightEntityFeature.TRANSITION
@ -220,7 +217,6 @@ async def test_services(hass, mock_light_profiles, enable_custom_integrations):
ATTR_ENTITY_ID: ent2.entity_id,
light.ATTR_EFFECT: "fun_effect",
light.ATTR_RGB_COLOR: (255, 255, 255),
light.ATTR_WHITE_VALUE: 255,
},
blocking=True,
)
@ -246,7 +242,6 @@ async def test_services(hass, mock_light_profiles, enable_custom_integrations):
assert data == {
light.ATTR_EFFECT: "fun_effect",
light.ATTR_HS_COLOR: (0, 0),
light.ATTR_WHITE_VALUE: 255,
}
_, data = ent3.last_call("turn_on")
@ -271,7 +266,6 @@ async def test_services(hass, mock_light_profiles, enable_custom_integrations):
ATTR_ENTITY_ID: ent2.entity_id,
light.ATTR_BRIGHTNESS: 0,
light.ATTR_RGB_COLOR: (255, 255, 255),
light.ATTR_WHITE_VALUE: 0,
},
blocking=True,
)
@ -427,13 +421,6 @@ async def test_services(hass, mock_light_profiles, enable_custom_integrations):
},
blocking=True,
)
with pytest.raises(vol.MultipleInvalid):
await hass.services.async_call(
light.DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: ent2.entity_id, light.ATTR_WHITE_VALUE: "high"},
blocking=True,
)
_, data = ent1.last_call("turn_on")
assert data == {}
@ -1104,8 +1091,6 @@ async def test_light_backwards_compatibility_supported_color_modes(
platform.ENTITIES.append(platform.MockLight("Test_2", light_state))
platform.ENTITIES.append(platform.MockLight("Test_3", light_state))
platform.ENTITIES.append(platform.MockLight("Test_4", light_state))
platform.ENTITIES.append(platform.MockLight("Test_5", light_state))
platform.ENTITIES.append(platform.MockLight("Test_6", light_state))
entity0 = platform.ENTITIES[0]
@ -1120,22 +1105,9 @@ async def test_light_backwards_compatibility_supported_color_modes(
entity4 = platform.ENTITIES[4]
entity4.supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_WHITE_VALUE
)
entity5 = platform.ENTITIES[5]
entity5.supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_COLOR_TEMP
)
entity6 = platform.ENTITIES[6]
entity6.supported_features = (
light.SUPPORT_BRIGHTNESS
| light.SUPPORT_COLOR
| light.SUPPORT_COLOR_TEMP
| light.SUPPORT_WHITE_VALUE
)
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
await hass.async_block_till_done()
@ -1168,16 +1140,6 @@ async def test_light_backwards_compatibility_supported_color_modes(
assert state.attributes["color_mode"] == light.ColorMode.UNKNOWN
state = hass.states.get(entity4.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.HS,
light.ColorMode.RGBW,
]
if light_state == STATE_OFF:
assert "color_mode" not in state.attributes
else:
assert state.attributes["color_mode"] == light.ColorMode.UNKNOWN
state = hass.states.get(entity5.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.COLOR_TEMP,
light.ColorMode.HS,
@ -1187,17 +1149,6 @@ async def test_light_backwards_compatibility_supported_color_modes(
else:
assert state.attributes["color_mode"] == light.ColorMode.UNKNOWN
state = hass.states.get(entity6.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.COLOR_TEMP,
light.ColorMode.HS,
light.ColorMode.RGBW,
]
if light_state == STATE_OFF:
assert "color_mode" not in state.attributes
else:
assert state.attributes["color_mode"] == light.ColorMode.UNKNOWN
async def test_light_backwards_compatibility_color_mode(
hass, enable_custom_integrations
@ -1211,8 +1162,6 @@ async def test_light_backwards_compatibility_color_mode(
platform.ENTITIES.append(platform.MockLight("Test_2", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_3", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_4", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_5", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_6", STATE_ON))
entity0 = platform.ENTITIES[0]
@ -1230,17 +1179,10 @@ async def test_light_backwards_compatibility_color_mode(
entity4 = platform.ENTITIES[4]
entity4.supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_WHITE_VALUE
)
entity4.hs_color = (240, 100)
entity4.white_value = 100
entity5 = platform.ENTITIES[5]
entity5.supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_COLOR_TEMP
)
entity5.hs_color = (240, 100)
entity5.color_temp = 100
entity4.hs_color = (240, 100)
entity4.color_temp = 100
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
await hass.async_block_till_done()
@ -1265,13 +1207,6 @@ async def test_light_backwards_compatibility_color_mode(
assert state.attributes["color_mode"] == light.ColorMode.HS
state = hass.states.get(entity4.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.HS,
light.ColorMode.RGBW,
]
assert state.attributes["color_mode"] == light.ColorMode.RGBW
state = hass.states.get(entity5.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.COLOR_TEMP,
light.ColorMode.HS,
@ -1281,38 +1216,26 @@ async def test_light_backwards_compatibility_color_mode(
async def test_light_service_call_rgbw(hass, enable_custom_integrations):
"""Test backwards compatibility for rgbw functionality in service calls."""
"""Test rgbw functionality in service calls."""
platform = getattr(hass.components, "test.light")
platform.init(empty=True)
platform.ENTITIES.append(platform.MockLight("Test_legacy_white_value", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_rgbw", STATE_ON))
entity0 = platform.ENTITIES[0]
entity0.supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_WHITE_VALUE
)
entity1 = platform.ENTITIES[1]
entity1.supported_color_modes = {light.ColorMode.RGBW}
entity0.supported_color_modes = {light.ColorMode.RGBW}
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
await hass.async_block_till_done()
state = hass.states.get(entity0.entity_id)
assert state.attributes["supported_color_modes"] == [
light.ColorMode.HS,
light.ColorMode.RGBW,
]
state = hass.states.get(entity1.entity_id)
assert state.attributes["supported_color_modes"] == [light.ColorMode.RGBW]
await hass.services.async_call(
"light",
"turn_on",
{
"entity_id": [entity0.entity_id, entity1.entity_id],
"entity_id": [entity0.entity_id, entity0.entity_id],
"brightness_pct": 100,
"rgbw_color": (10, 20, 30, 40),
},
@ -1320,8 +1243,6 @@ async def test_light_service_call_rgbw(hass, enable_custom_integrations):
)
_, data = entity0.last_call("turn_on")
assert data == {"brightness": 255, "hs_color": (210.0, 66.667), "white_value": 40}
_, data = entity1.last_call("turn_on")
assert data == {"brightness": 255, "rgbw_color": (10, 20, 30, 40)}
@ -1330,47 +1251,21 @@ async def test_light_state_rgbw(hass, enable_custom_integrations):
platform = getattr(hass.components, "test.light")
platform.init(empty=True)
platform.ENTITIES.append(platform.MockLight("Test_legacy_white_value", STATE_ON))
platform.ENTITIES.append(platform.MockLight("Test_rgbw", STATE_ON))
entity0 = platform.ENTITIES[0]
legacy_supported_features = (
light.SUPPORT_BRIGHTNESS | light.SUPPORT_COLOR | light.SUPPORT_WHITE_VALUE
)
entity0.supported_features = legacy_supported_features
entity0.hs_color = (210.0, 66.667)
entity0.supported_color_modes = {light.ColorMode.RGBW}
entity0.color_mode = light.ColorMode.RGBW
entity0.hs_color = "Invalid" # Should be ignored
entity0.rgb_color = "Invalid" # Should be ignored
entity0.rgbw_color = (1, 2, 3, 4)
entity0.rgbww_color = "Invalid" # Should be ignored
entity0.white_value = 40
entity0.xy_color = "Invalid" # Should be ignored
entity1 = platform.ENTITIES[1]
entity1.supported_color_modes = {light.ColorMode.RGBW}
entity1.color_mode = light.ColorMode.RGBW
entity1.hs_color = "Invalid" # Should be ignored
entity1.rgb_color = "Invalid" # Should be ignored
entity1.rgbw_color = (1, 2, 3, 4)
entity1.rgbww_color = "Invalid" # Should be ignored
entity1.white_value = "Invalid" # Should be ignored
entity1.xy_color = "Invalid" # Should be ignored
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
await hass.async_block_till_done()
state = hass.states.get(entity0.entity_id)
assert state.attributes == {
"color_mode": light.ColorMode.RGBW,
"friendly_name": "Test_legacy_white_value",
"supported_color_modes": [light.ColorMode.HS, light.ColorMode.RGBW],
"supported_features": legacy_supported_features,
"hs_color": (210.0, 66.667),
"rgb_color": (84, 169, 255),
"rgbw_color": (84, 169, 255, 40),
"white_value": 40,
"xy_color": (0.173, 0.207),
}
state = hass.states.get(entity1.entity_id)
assert state.attributes == {
"color_mode": light.ColorMode.RGBW,
"friendly_name": "Test_rgbw",
@ -1397,7 +1292,6 @@ async def test_light_state_rgbww(hass, enable_custom_integrations):
entity0.rgb_color = "Invalid" # Should be ignored
entity0.rgbw_color = "Invalid" # Should be ignored
entity0.rgbww_color = (1, 2, 3, 4, 5)
entity0.white_value = "Invalid" # Should be ignored
entity0.xy_color = "Invalid" # Should be ignored
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
@ -2264,7 +2158,6 @@ async def test_services_filter_parameters(
light.ATTR_EFFECT: "fun_effect",
light.ATTR_FLASH: "short",
light.ATTR_TRANSITION: 10,
light.ATTR_WHITE_VALUE: 0,
},
blocking=True,
)
@ -2353,7 +2246,6 @@ async def test_services_filter_parameters(
light.ATTR_EFFECT: "fun_effect",
light.ATTR_FLASH: "short",
light.ATTR_TRANSITION: 10,
light.ATTR_WHITE_VALUE: 0,
},
blocking=True,
)

View File

@ -9,7 +9,6 @@ from homeassistant.helpers.state import async_reproduce_state
from tests.common import async_mock_service
VALID_BRIGHTNESS = {"brightness": 180}
VALID_WHITE_VALUE = {"white_value": 200}
VALID_FLASH = {"flash": "short"}
VALID_EFFECT = {"effect": "random"}
VALID_TRANSITION = {"transition": 15}
@ -28,7 +27,6 @@ async def test_reproducing_states(hass, caplog):
"""Test reproducing Light states."""
hass.states.async_set("light.entity_off", "off", {})
hass.states.async_set("light.entity_bright", "on", VALID_BRIGHTNESS)
hass.states.async_set("light.entity_white", "on", VALID_WHITE_VALUE)
hass.states.async_set("light.entity_flash", "on", VALID_FLASH)
hass.states.async_set("light.entity_effect", "on", VALID_EFFECT)
hass.states.async_set("light.entity_trans", "on", VALID_TRANSITION)
@ -49,7 +47,6 @@ async def test_reproducing_states(hass, caplog):
[
State("light.entity_off", "off"),
State("light.entity_bright", "on", VALID_BRIGHTNESS),
State("light.entity_white", "on", VALID_WHITE_VALUE),
State("light.entity_flash", "on", VALID_FLASH),
State("light.entity_effect", "on", VALID_EFFECT),
State("light.entity_trans", "on", VALID_TRANSITION),
@ -79,8 +76,7 @@ async def test_reproducing_states(hass, caplog):
[
State("light.entity_xy", "off"),
State("light.entity_off", "on", VALID_BRIGHTNESS),
State("light.entity_bright", "on", VALID_WHITE_VALUE),
State("light.entity_white", "on", VALID_FLASH),
State("light.entity_bright", "on", VALID_FLASH),
State("light.entity_flash", "on", VALID_EFFECT),
State("light.entity_effect", "on", VALID_TRANSITION),
State("light.entity_trans", "on", VALID_COLOR_NAME),
@ -93,7 +89,7 @@ async def test_reproducing_states(hass, caplog):
],
)
assert len(turn_on_calls) == 12
assert len(turn_on_calls) == 11
expected_calls = []
@ -101,14 +97,10 @@ async def test_reproducing_states(hass, caplog):
expected_off["entity_id"] = "light.entity_off"
expected_calls.append(expected_off)
expected_bright = dict(VALID_WHITE_VALUE)
expected_bright = dict(VALID_FLASH)
expected_bright["entity_id"] = "light.entity_bright"
expected_calls.append(expected_bright)
expected_white = dict(VALID_FLASH)
expected_white["entity_id"] = "light.entity_white"
expected_calls.append(expected_white)
expected_flash = dict(VALID_EFFECT)
expected_flash["entity_id"] = "light.entity_flash"
expected_calls.append(expected_flash)
@ -181,7 +173,6 @@ async def test_filter_color_modes(hass, caplog, color_mode):
"""Test filtering of parameters according to color mode."""
hass.states.async_set("light.entity", "off", {})
all_colors = {
**VALID_WHITE_VALUE,
**VALID_COLOR_NAME,
**VALID_COLOR_TEMP,
**VALID_HS_COLOR,
@ -210,7 +201,6 @@ async def test_filter_color_modes(hass, caplog, color_mode):
light.ColorMode.UNKNOWN: {
**VALID_BRIGHTNESS,
**VALID_HS_COLOR,
**VALID_WHITE_VALUE,
},
light.ColorMode.WHITE: {
**VALID_BRIGHTNESS,

View File

@ -4,7 +4,6 @@ from homeassistant.components.light import (
ATTR_COLOR_TEMP,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_WHITE_VALUE,
)
from homeassistant.components.light.significant_change import (
async_check_significant_change,
@ -32,14 +31,6 @@ async def test_significant_change():
None, "on", {ATTR_COLOR_TEMP: 60}, "on", {ATTR_COLOR_TEMP: 65}
)
# White value
assert not async_check_significant_change(
None, "on", {ATTR_WHITE_VALUE: 60}, "on", {ATTR_WHITE_VALUE: 64}
)
assert async_check_significant_change(
None, "on", {ATTR_WHITE_VALUE: 60}, "on", {ATTR_WHITE_VALUE: 65}
)
# Effect
for eff1, eff2, expected in (
(None, None, False),

View File

@ -1181,6 +1181,8 @@ ABBREVIATIONS_WHITE_LIST = [
"CONF_SCHEMA",
"CONF_SWING_MODE_LIST",
"CONF_TEMP_STEP",
# Removed
"CONF_WHITE_VALUE",
]

View File

@ -32,7 +32,6 @@ async def test_default_state(hass):
assert state.attributes.get("brightness") is None
assert state.attributes.get("hs_color") is None
assert state.attributes.get("color_temp") is None
assert state.attributes.get("white_value") is None
assert state.attributes.get("effect_list") is None
assert state.attributes.get("effect") is None
assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ColorMode.ONOFF]

View File

@ -7,7 +7,6 @@ from homeassistant.components.light import (
ATTR_EFFECT_LIST,
ATTR_HS_COLOR,
ATTR_SUPPORTED_COLOR_MODES,
ATTR_WHITE_VALUE,
DOMAIN as LIGHT_DOMAIN,
ColorMode,
)
@ -50,7 +49,6 @@ async def test_default_state(hass: HomeAssistant) -> None:
assert state.attributes.get(ATTR_BRIGHTNESS) is None
assert state.attributes.get(ATTR_HS_COLOR) is None
assert state.attributes.get(ATTR_COLOR_TEMP) is None
assert state.attributes.get(ATTR_WHITE_VALUE) is None
assert state.attributes.get(ATTR_EFFECT_LIST) is None
assert state.attributes.get(ATTR_EFFECT) is None
assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [ColorMode.ONOFF]

View File

@ -574,7 +574,6 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota):
)
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert "white_value" not in state.attributes
# Setting white > 0 should clear the color
assert "rgb_color" not in state.attributes
assert state.attributes.get("color_mode") == "color_temp"
@ -593,7 +592,6 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota):
state = hass.states.get("light.test")
assert state.state == STATE_ON
# Setting white to 0 should clear the color_temp
assert "white_value" not in state.attributes
assert "color_temp" not in state.attributes
assert state.attributes.get("hs_color") == (30, 100)
assert state.attributes.get("color_mode") == "hs"
@ -686,7 +684,6 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(hass, mqtt_mock, setup_tasm
)
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert "white_value" not in state.attributes
# Setting white > 0 should clear the color
assert "rgb_color" not in state.attributes
assert state.attributes.get("color_mode") == "color_temp"
@ -704,8 +701,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(hass, mqtt_mock, setup_tasm
)
state = hass.states.get("light.test")
assert state.state == STATE_ON
# Setting white to 0 should clear the white_value and color_temp
assert not state.attributes.get("white_value")
# Setting white to 0 should clear the color_temp
assert not state.attributes.get("color_temp")
assert state.attributes.get("color_mode") == "hs"
@ -904,16 +900,6 @@ async def test_sending_mqtt_commands_rgbw_legacy(hass, mqtt_mock, setup_tasmota)
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", white_value=128)
# white_value should be ignored
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON",
0,
False,
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
@ -1011,16 +997,6 @@ async def test_sending_mqtt_commands_rgbw(hass, mqtt_mock, setup_tasmota):
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", white_value=128)
# white_value should be ignored
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON",
0,
False,
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
@ -1096,16 +1072,6 @@ async def test_sending_mqtt_commands_rgbww(hass, mqtt_mock, setup_tasmota):
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", white_value=128)
# white_value should be ignored
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",
"NoDelay;Power1 ON",
0,
False,
)
mqtt_mock.async_publish.reset_mock()
await common.async_turn_on(hass, "light.test", effect="Random")
mqtt_mock.async_publish.assert_called_once_with(
"tasmota_49A3BC/cmnd/Backlog",

View File

@ -90,19 +90,6 @@ OPTIMISTIC_HS_COLOR_LIGHT_CONFIG = {
}
OPTIMISTIC_WHITE_VALUE_LIGHT_CONFIG = {
**OPTIMISTIC_ON_OFF_LIGHT_CONFIG,
"set_white_value": {
"service": "test.automation",
"data_template": {
"action": "set_white_value",
"caller": "{{ this.entity_id }}",
"white_value": "{{white_value}}",
},
},
}
async def async_setup_light(hass, count, light_config):
"""Do setup of light integration."""
config = {"light": {"platform": "template", "lights": light_config}}

View File

@ -49,7 +49,6 @@ class MockLight(MockToggleEntity, LightEntity):
rgbw_color = None
rgbww_color = None
xy_color = None
white_value = None
def turn_on(self, **kwargs):
"""Turn the entity on."""
@ -63,7 +62,6 @@ class MockLight(MockToggleEntity, LightEntity):
"rgbw_color",
"rgbww_color",
"color_temp",
"white_value",
]:
setattr(self, key, value)
if key == "white":