Skip to content

Commit

Permalink
Remove setPosition (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne authored May 31, 2021
1 parent 1935646 commit 39f485e
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Support for TaHoma cover - shutters etc."""
import logging

from homeassistant.components.cover import (
ATTR_POSITION,
ATTR_TILT_POSITION,
Expand Down Expand Up @@ -28,8 +26,6 @@
from .const import DOMAIN
from .tahoma_entity import TahomaEntity

_LOGGER = logging.getLogger(__name__)

ATTR_OBSTRUCTION_DETECTED = "obstruction-detected"

COMMAND_CYCLE = "cycle"
Expand All @@ -41,10 +37,9 @@
COMMAND_OPEN = "open"
COMMAND_OPEN_SLATS = "openSlats"
COMMAND_SET_CLOSURE = "setClosure"
COMMAND_SET_CLOSURE_AND_LINEAR_SPEED = "setClosureAndLinearSpeed"
COMMAND_SET_DEPLOYMENT = "setDeployment"
COMMAND_SET_ORIENTATION = "setOrientation"
COMMAND_SET_POSITION = "setPosition"
COMMAND_SET_POSITION_AND_LINEAR_SPEED = "setPositionAndLinearSpeed"
COMMAND_STOP = "stop"
COMMAND_STOP_IDENTIFY = "stopIdentify"
COMMAND_UNDEPLOY = "undeploy"
Expand All @@ -56,10 +51,7 @@
COMMANDS_OPEN_TILT = [COMMAND_OPEN_SLATS]
COMMANDS_CLOSE = [COMMAND_CLOSE, COMMAND_DOWN, COMMAND_CYCLE]
COMMANDS_CLOSE_TILT = [COMMAND_CLOSE_SLATS]
COMMANDS_SET_POSITION = [
COMMAND_SET_POSITION,
COMMAND_SET_CLOSURE,
]

COMMANDS_SET_TILT_POSITION = [COMMAND_SET_ORIENTATION]

CORE_CLOSURE_STATE = "core:ClosureState"
Expand Down Expand Up @@ -181,16 +173,14 @@ async def async_set_cover_position(self, **kwargs):
await self.async_execute_command(COMMAND_SET_DEPLOYMENT, position)
else:
position = 100 - kwargs.get(ATTR_POSITION, 0)
await self.async_execute_command(
self.select_command(*COMMANDS_SET_POSITION), position
)
await self.async_execute_command(COMMAND_SET_CLOSURE, position)

async def async_set_cover_position_low_speed(self, **kwargs):
"""Move the cover to a specific position with a low speed."""
position = 100 - kwargs.get(ATTR_POSITION, 0)

await self.async_execute_command(
COMMAND_SET_POSITION_AND_LINEAR_SPEED, position, "lowspeed"
COMMAND_SET_CLOSURE_AND_LINEAR_SPEED, position, "lowspeed"
)

async def async_set_cover_tilt_position(self, **kwargs):
Expand Down Expand Up @@ -269,7 +259,7 @@ async def async_close_cover_tilt(self, **_):
async def async_stop_cover(self, **_):
"""Stop the cover."""
await self.async_cancel_or_stop_cover(
COMMANDS_OPEN + COMMANDS_SET_POSITION + COMMANDS_CLOSE,
COMMANDS_OPEN + [COMMAND_SET_CLOSURE] + COMMANDS_CLOSE,
COMMANDS_STOP,
)

Expand Down Expand Up @@ -370,7 +360,7 @@ def supported_features(self):
if self.has_command(*COMMANDS_SET_TILT_POSITION):
supported_features |= SUPPORT_SET_TILT_POSITION

if self.has_command(*COMMANDS_SET_POSITION) or self.has_command(
if self.has_command(COMMAND_SET_CLOSURE) or self.has_command(
COMMAND_SET_DEPLOYMENT
):
supported_features |= SUPPORT_SET_POSITION
Expand All @@ -384,7 +374,7 @@ def supported_features(self):
if self.has_command(*COMMANDS_CLOSE) or self.has_command(COMMAND_UNDEPLOY):
supported_features |= SUPPORT_CLOSE

if self.has_command(COMMAND_SET_POSITION_AND_LINEAR_SPEED):
if self.has_command(COMMAND_SET_CLOSURE_AND_LINEAR_SPEED):
supported_features |= SUPPORT_COVER_POSITION_LOW_SPEED

if self.has_command(COMMAND_MY):
Expand Down

0 comments on commit 39f485e

Please sign in to comment.