mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Use the action field enums in motion_blinds (#196016)
This commit is contained in:
@@ -6,11 +6,10 @@ from typing import Any, override
|
||||
from motionblinds import BlindType
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
CoverServiceArgument,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -194,7 +193,7 @@ class MotionBaseDevice(MotionCoordinatorEntity, 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]
|
||||
async with self._api_lock:
|
||||
await self.hass.async_add_executor_job(
|
||||
self._blind.Set_position,
|
||||
@@ -307,7 +306,7 @@ class MotionTiltDevice(MotionPositionDevice):
|
||||
@override
|
||||
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover tilt to a specific position."""
|
||||
angle = kwargs[ATTR_TILT_POSITION] * 180 / 100
|
||||
angle = kwargs[CoverServiceArgument.TILT_POSITION] * 180 / 100
|
||||
async with self._api_lock:
|
||||
await self.hass.async_add_executor_job(self._blind.Set_angle, 180 - angle)
|
||||
|
||||
@@ -392,7 +391,7 @@ class MotionTiltOnlyDevice(MotionTiltDevice):
|
||||
@override
|
||||
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover tilt to a specific position."""
|
||||
angle = kwargs[ATTR_TILT_POSITION]
|
||||
angle = kwargs[CoverServiceArgument.TILT_POSITION]
|
||||
if self._blind.position is None:
|
||||
angle = angle * 180 / 100
|
||||
async with self._api_lock:
|
||||
@@ -497,7 +496,7 @@ class MotionTDBUDevice(MotionBaseDevice):
|
||||
@override
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific scaled position."""
|
||||
position = kwargs[ATTR_POSITION]
|
||||
position = kwargs[CoverServiceArgument.POSITION]
|
||||
async with self._api_lock:
|
||||
await self.hass.async_add_executor_job(
|
||||
self._blind.Set_scaled_position, 100 - position, self._motor_key
|
||||
|
||||
Reference in New Issue
Block a user