mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Use the action field enums in govee_light_local (#195751)
This commit is contained in:
@@ -6,13 +6,10 @@ from typing import Any, override
|
||||
from govee_local_api import GoveeDevice, GoveeLightFeatures
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
ATTR_RGB_COLOR,
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
LightServiceArgument,
|
||||
filter_supported_color_modes,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@@ -175,24 +172,26 @@ class GoveeLight(CoordinatorEntity[GoveeLocalApiCoordinator], LightEntity):
|
||||
@override
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
brightness: int = int((float(kwargs[ATTR_BRIGHTNESS]) / 255.0) * 100.0)
|
||||
if LightServiceArgument.BRIGHTNESS in kwargs:
|
||||
brightness: int = int(
|
||||
(float(kwargs[LightServiceArgument.BRIGHTNESS]) / 255.0) * 100.0
|
||||
)
|
||||
await self.coordinator.set_brightness(self._device, brightness)
|
||||
|
||||
if ATTR_RGB_COLOR in kwargs:
|
||||
if LightServiceArgument.RGB_COLOR in kwargs:
|
||||
self._attr_color_mode = ColorMode.RGB
|
||||
self._attr_effect = None
|
||||
self._last_color_state = None
|
||||
red, green, blue = kwargs[ATTR_RGB_COLOR]
|
||||
red, green, blue = kwargs[LightServiceArgument.RGB_COLOR]
|
||||
await self.coordinator.set_rgb_color(self._device, red, green, blue)
|
||||
elif ATTR_COLOR_TEMP_KELVIN in kwargs:
|
||||
elif LightServiceArgument.COLOR_TEMP_KELVIN in kwargs:
|
||||
self._attr_color_mode = ColorMode.COLOR_TEMP
|
||||
self._attr_effect = None
|
||||
self._last_color_state = None
|
||||
temperature: float = kwargs[ATTR_COLOR_TEMP_KELVIN]
|
||||
temperature: float = kwargs[LightServiceArgument.COLOR_TEMP_KELVIN]
|
||||
await self.coordinator.set_temperature(self._device, int(temperature))
|
||||
elif ATTR_EFFECT in kwargs:
|
||||
effect = kwargs[ATTR_EFFECT]
|
||||
elif LightServiceArgument.EFFECT in kwargs:
|
||||
effect = kwargs[LightServiceArgument.EFFECT]
|
||||
if effect and self._attr_effect_list and effect in self._attr_effect_list:
|
||||
if effect == _NONE_SCENE:
|
||||
self._attr_effect = None
|
||||
|
||||
Reference in New Issue
Block a user