mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Use the action field enums in lcn (#194878)
This commit is contained in:
@@ -8,10 +8,10 @@ from typing import Any, override
|
||||
import pypck
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
CoverServiceArgument,
|
||||
)
|
||||
from homeassistant.const import CONF_DOMAIN, CONF_ENTITIES
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -249,7 +249,7 @@ class LcnRelayCover(LcnEntity, CoverEntity):
|
||||
@override
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position."""
|
||||
position = kwargs[ATTR_POSITION]
|
||||
position = kwargs[CoverServiceArgument.POSITION]
|
||||
if not await self.device_connection.control_motor_relays_position(
|
||||
self.motor.value, position, mode=self.positioning_mode
|
||||
):
|
||||
|
||||
@@ -8,12 +8,11 @@ from typing import Any, override
|
||||
import pypck
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
ATTR_TRANSITION,
|
||||
DOMAIN as LIGHT_DOMAIN,
|
||||
ColorMode,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
LightServiceArgument,
|
||||
)
|
||||
from homeassistant.const import CONF_DOMAIN, CONF_ENTITIES
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -105,16 +104,18 @@ class LcnOutputLight(LcnEntity, LightEntity):
|
||||
@override
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
if LightServiceArgument.TRANSITION in kwargs:
|
||||
transition = pypck.lcn_defs.time_to_ramp_value(
|
||||
kwargs[ATTR_TRANSITION] * 1000
|
||||
kwargs[LightServiceArgument.TRANSITION] * 1000
|
||||
)
|
||||
else:
|
||||
transition = self._transition
|
||||
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
if LightServiceArgument.BRIGHTNESS in kwargs:
|
||||
percent = int(
|
||||
brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS])
|
||||
brightness_to_value(
|
||||
BRIGHTNESS_SCALE, kwargs[LightServiceArgument.BRIGHTNESS]
|
||||
)
|
||||
)
|
||||
if not await self.device_connection.dim_output(
|
||||
self.output.value, percent, transition
|
||||
@@ -134,9 +135,9 @@ class LcnOutputLight(LcnEntity, LightEntity):
|
||||
@override
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
if LightServiceArgument.TRANSITION in kwargs:
|
||||
transition = pypck.lcn_defs.time_to_ramp_value(
|
||||
kwargs[ATTR_TRANSITION] * 1000
|
||||
kwargs[LightServiceArgument.TRANSITION] * 1000
|
||||
)
|
||||
else:
|
||||
transition = self._transition
|
||||
|
||||
Reference in New Issue
Block a user