mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Use the action field enums in wmspro (#194871)
This commit is contained in:
@@ -10,10 +10,9 @@ from wmspro.const import (
|
||||
)
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverServiceArgument,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -78,7 +77,7 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position."""
|
||||
action = self._dest.action(self._drive_action_desc)
|
||||
await action(percentage=100 - kwargs[ATTR_POSITION])
|
||||
await action(percentage=100 - kwargs[CoverServiceArgument.POSITION])
|
||||
|
||||
@property
|
||||
@override
|
||||
@@ -163,7 +162,7 @@ class WebControlProSlatRotate(WebControlProSlat):
|
||||
@override
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position and tilt for open/close."""
|
||||
target_position = kwargs[ATTR_POSITION]
|
||||
target_position = kwargs[CoverServiceArgument.POSITION]
|
||||
if target_position == 0:
|
||||
await self.async_close_cover()
|
||||
elif target_position == 100:
|
||||
@@ -189,7 +188,7 @@ class WebControlProSlatRotate(WebControlProSlat):
|
||||
action = self._dest.action(self._tilt_action_desc)
|
||||
rotation = percentage_to_ranged_value(
|
||||
(action.minValue, action.maxValue),
|
||||
100 - kwargs[ATTR_TILT_POSITION],
|
||||
100 - kwargs[CoverServiceArgument.TILT_POSITION],
|
||||
)
|
||||
await action(rotation=rotation)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from wmspro.const import (
|
||||
WMS_WebControl_pro_API_responseType,
|
||||
)
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
from homeassistant.components.light import ColorMode, LightEntity, LightServiceArgument
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.util.color import brightness_to_value, value_to_brightness
|
||||
@@ -86,12 +86,14 @@ class WebControlProDimmer(WebControlProLight):
|
||||
@override
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the dimmer on."""
|
||||
if ATTR_BRIGHTNESS not in kwargs:
|
||||
if LightServiceArgument.BRIGHTNESS not in kwargs:
|
||||
await super().async_turn_on(**kwargs)
|
||||
return
|
||||
|
||||
action = self._dest.action(ACTION_DESC.LightDimming)
|
||||
await action(
|
||||
percentage=brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS]),
|
||||
percentage=brightness_to_value(
|
||||
BRIGHTNESS_SCALE, kwargs[LightServiceArgument.BRIGHTNESS]
|
||||
),
|
||||
responseType=WMS_WebControl_pro_API_responseType.Detailed,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user