Use the action field enums in modern_forms (#196014)

This commit is contained in:
epenet
2026-12-02 13:17:25 +00:00
committed by GitHub
parent 85033b7e52
commit 6f282dcb12
+5 -10
View File
@@ -5,12 +5,7 @@ from typing import Any, override
from aiomodernforms.const import LIGHT_POWER_OFF, LIGHT_POWER_ON
from aiomodernforms.models import Light
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP_KELVIN,
ColorMode,
LightEntity,
)
from homeassistant.components.light import ColorMode, LightEntity, LightServiceArgument
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@@ -143,12 +138,12 @@ class ModernFormsLightEntity(ModernFormsDeviceEntity, LightEntity):
"""Turn on the light."""
data: dict[str, Any] = {OPT_ON: LIGHT_POWER_ON}
if ATTR_BRIGHTNESS in kwargs:
if LightServiceArgument.BRIGHTNESS in kwargs:
data[OPT_BRIGHTNESS] = ranged_value_to_percentage(
BRIGHTNESS_RANGE, kwargs[ATTR_BRIGHTNESS]
BRIGHTNESS_RANGE, kwargs[LightServiceArgument.BRIGHTNESS]
)
if ATTR_COLOR_TEMP_KELVIN in kwargs:
data[OPT_COLOR_TEMP_KELVIN] = kwargs[ATTR_COLOR_TEMP_KELVIN]
if LightServiceArgument.COLOR_TEMP_KELVIN in kwargs:
data[OPT_COLOR_TEMP_KELVIN] = kwargs[LightServiceArgument.COLOR_TEMP_KELVIN]
await self._async_control_light(**data)