mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 22:34:04 +02:00
suggested fix for HA2025 deprecation warnings (#1168)
* suggested fix for HA2025 deprecation warnings * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bas Nijholt <bas@nijho.lt>
This commit is contained in:
parent
ff84a46aed
commit
6cb99e80b0
1 changed files with 14 additions and 35 deletions
|
|
@ -16,7 +16,6 @@ import ulid_transform
|
|||
import voluptuous as vol
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
ATTR_FLASH,
|
||||
|
|
@ -24,17 +23,8 @@ from homeassistant.components.light import (
|
|||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
ATTR_TRANSITION,
|
||||
ATTR_XY_COLOR,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
COLOR_MODE_RGB,
|
||||
COLOR_MODE_RGBW,
|
||||
COLOR_MODE_RGBWW,
|
||||
COLOR_MODE_XY,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_COLOR,
|
||||
SUPPORT_COLOR_TEMP,
|
||||
SUPPORT_TRANSITION,
|
||||
ColorMode,
|
||||
LightEntityFeature,
|
||||
is_on,
|
||||
preprocess_turn_on_alternatives,
|
||||
)
|
||||
|
|
@ -179,13 +169,6 @@ if TYPE_CHECKING:
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
_SUPPORT_OPTS = {
|
||||
"brightness": SUPPORT_BRIGHTNESS,
|
||||
"color_temp": SUPPORT_COLOR_TEMP,
|
||||
"color": SUPPORT_COLOR,
|
||||
"transition": SUPPORT_TRANSITION,
|
||||
}
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -651,17 +634,19 @@ def _supported_features(hass: HomeAssistant, light: str) -> set[str]:
|
|||
assert state is not None
|
||||
supported_features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
|
||||
assert isinstance(supported_features, int)
|
||||
supported = {
|
||||
key for key, value in _SUPPORT_OPTS.items() if supported_features & value
|
||||
}
|
||||
|
||||
supported = set()
|
||||
|
||||
if supported_features & LightEntityFeature.TRANSITION:
|
||||
supported.add("transition")
|
||||
|
||||
supported_color_modes = state.attributes.get(ATTR_SUPPORTED_COLOR_MODES, set())
|
||||
color_modes = {
|
||||
COLOR_MODE_RGB,
|
||||
COLOR_MODE_RGBW,
|
||||
COLOR_MODE_RGBWW,
|
||||
COLOR_MODE_XY,
|
||||
COLOR_MODE_HS,
|
||||
ColorMode.RGB,
|
||||
ColorMode.RGBW,
|
||||
ColorMode.RGBWW,
|
||||
ColorMode.XY,
|
||||
ColorMode.HS,
|
||||
}
|
||||
|
||||
# Adding brightness when color mode is supported, see
|
||||
|
|
@ -672,10 +657,10 @@ def _supported_features(hass: HomeAssistant, light: str) -> set[str]:
|
|||
supported.update({"color", "brightness"})
|
||||
break
|
||||
|
||||
if COLOR_MODE_COLOR_TEMP in supported_color_modes:
|
||||
if ColorMode.COLOR_TEMP in supported_color_modes:
|
||||
supported.update({"color_temp", "brightness"})
|
||||
|
||||
if COLOR_MODE_BRIGHTNESS in supported_color_modes:
|
||||
if ColorMode.BRIGHTNESS in supported_color_modes:
|
||||
supported.add("brightness")
|
||||
|
||||
return supported
|
||||
|
|
@ -2009,12 +1994,6 @@ class AdaptiveLightingManager:
|
|||
context.id,
|
||||
)
|
||||
service_data = {ATTR_ENTITY_ID: skipped, **service_data_copy[CONF_PARAMS]}
|
||||
if (
|
||||
ATTR_COLOR_TEMP in service_data
|
||||
and ATTR_COLOR_TEMP_KELVIN in service_data
|
||||
):
|
||||
# ATTR_COLOR_TEMP and ATTR_COLOR_TEMP_KELVIN are mutually exclusive
|
||||
del service_data[ATTR_COLOR_TEMP]
|
||||
await self.hass.services.async_call(
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue