Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove white_value support from light #76926

Merged
merged 4 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/fibaro/__init__.py
Expand Up @@ -24,7 +24,6 @@
CONF_PASSWORD,
CONF_URL,
CONF_USERNAME,
CONF_WHITE_VALUE,
Platform,
)
from homeassistant.core import HomeAssistant
Expand All @@ -45,6 +44,7 @@
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 = [
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/flux/switch.py
Expand Up @@ -15,7 +15,6 @@
ATTR_COLOR_TEMP,
ATTR_RGB_COLOR,
ATTR_TRANSITION,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN as LIGHT_DOMAIN,
VALID_TRANSITION,
Expand Down Expand Up @@ -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)
Expand Down
51 changes: 0 additions & 51 deletions homeassistant/components/light/__init__.py
Expand Up @@ -59,7 +59,6 @@ class LightEntityFeature(IntEnum):
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"
Expand Down Expand Up @@ -202,7 +201,6 @@ def get_supported_color_modes(hass: HomeAssistant, entity_id: str) -> set | None
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
Expand Down Expand Up @@ -274,7 +272,6 @@ def get_supported_color_modes(hass: HomeAssistant, entity_id: str) -> set | None
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,
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -421,16 +416,6 @@ async def async_handle_light_on_service(light, call):
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:
Expand Down Expand Up @@ -544,9 +529,6 @@ async def async_handle_light_on_service(light, call):
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:
Expand Down Expand Up @@ -786,12 +768,6 @@ def _light_internal_color_mode(self) -> str:
# 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:
Expand Down Expand Up @@ -828,19 +804,6 @@ def rgbw_color(self) -> tuple[int, int, int, int] | None:
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
Expand All @@ -867,11 +830,6 @@ def max_mireds(self) -> int:
# 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."""
Expand Down Expand Up @@ -982,13 +940,6 @@ def state_attributes(self):
# 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

Expand All @@ -1009,8 +960,6 @@ def _light_internal_supported_color_modes(self) -> set[ColorMode] | set[str]:
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}

Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/light/reproduce_state.py
Expand Up @@ -31,7 +31,6 @@
ATTR_RGBWW_COLOR,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN,
ColorMode,
Expand All @@ -46,7 +45,6 @@
ATTR_BRIGHTNESS_PCT,
ATTR_EFFECT,
ATTR_FLASH,
ATTR_WHITE_VALUE,
ATTR_TRANSITION,
]

Expand Down Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions homeassistant/components/light/services.yaml
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions homeassistant/components/light/significant_change.py
Expand Up @@ -6,13 +6,7 @@
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
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion homeassistant/components/mqtt/light/schema_json.py
Expand Up @@ -38,7 +38,6 @@
CONF_NAME,
CONF_OPTIMISTIC,
CONF_RGB,
CONF_WHITE_VALUE,
CONF_XY,
STATE_ON,
)
Expand Down Expand Up @@ -97,6 +96,8 @@
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."""
Expand Down
1 change: 0 additions & 1 deletion homeassistant/const.py
Expand Up @@ -262,7 +262,6 @@ class Platform(StrEnum):
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"

Expand Down
5 changes: 0 additions & 5 deletions pylint/plugins/hass_enforce_type_hints.py
Expand Up @@ -1360,10 +1360,6 @@ class 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],
Expand Down Expand Up @@ -1403,7 +1399,6 @@ class ClassTypeHintMatch:
"transition": "float | None",
"xy_color": "tuple[float, float] | None",
"white": "int | None",
"white_value": "int | None",
},
kwargs_type="Any",
return_type=None,
Expand Down
2 changes: 0 additions & 2 deletions tests/components/group/test_light.py
Expand Up @@ -25,7 +25,6 @@
ATTR_SUPPORTED_COLOR_MODES,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN as LIGHT_DOMAIN,
SERVICE_TOGGLE,
Expand Down Expand Up @@ -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

Expand Down
9 changes: 0 additions & 9 deletions tests/components/light/common.py
Expand Up @@ -18,7 +18,6 @@
ATTR_RGBWW_COLOR,
ATTR_TRANSITION,
ATTR_WHITE,
ATTR_WHITE_VALUE,
ATTR_XY_COLOR,
DOMAIN,
)
Expand Down Expand Up @@ -46,7 +45,6 @@ def turn_on(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
Expand All @@ -68,7 +66,6 @@ def turn_on(
hs_color,
color_temp,
kelvin,
white_value,
profile,
flash,
effect,
Expand All @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -158,7 +153,6 @@ def toggle(
hs_color=None,
color_temp=None,
kelvin=None,
white_value=None,
profile=None,
flash=None,
effect=None,
Expand All @@ -177,7 +171,6 @@ def toggle(
hs_color,
color_temp,
kelvin,
white_value,
profile,
flash,
effect,
Expand All @@ -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,
Expand All @@ -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),
Expand Down