Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cover implementation for devices with only cycle command #184

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
)

from .const import DOMAIN
from .switch import COMMAND_CYCLE
from .tahoma_device import TahomaDevice

_LOGGER = logging.getLogger(__name__)

ATTR_LOCK_ORIG = "lock_originator"
ATTR_MEM_POS = "memorized_position"

COMMAND_CYCLE = "cycle"
COMMAND_CLOSE = "close"
COMMAND_CLOSE_SLATS = "closeSlats"
COMMAND_DOWN = "down"
Expand Down Expand Up @@ -211,7 +211,9 @@ def icon(self):

async def async_open_cover(self, **_):
"""Open the cover."""
await self.async_execute_command(self.select_command(COMMAND_OPEN, COMMAND_UP))
await self.async_execute_command(
self.select_command(COMMAND_OPEN, COMMAND_UP, COMMAND_CYCLE)
)

async def async_open_cover_tilt(self, **_):
"""Open the cover tilt."""
Expand All @@ -220,7 +222,7 @@ async def async_open_cover_tilt(self, **_):
async def async_close_cover(self, **_):
"""Close the cover."""
await self.async_execute_command(
self.select_command(COMMAND_CLOSE, COMMAND_DOWN)
self.select_command(COMMAND_CLOSE, COMMAND_DOWN, COMMAND_CYCLE)
)

async def async_close_cover_tilt(self, **_):
Expand Down Expand Up @@ -261,20 +263,13 @@ def supported_features(self):
):
supported_features |= SUPPORT_SET_POSITION

if self.has_command(COMMAND_OPEN, COMMAND_UP):
if self.has_command(COMMAND_OPEN, COMMAND_UP, COMMAND_CYCLE):
supported_features |= SUPPORT_OPEN

if self.has_command(COMMAND_STOP_IDENTIFY, COMMAND_STOP, COMMAND_MY):
supported_features |= SUPPORT_STOP

if self.has_command(COMMAND_CLOSE, COMMAND_DOWN):
if self.has_command(COMMAND_CLOSE, COMMAND_DOWN, COMMAND_CYCLE):
supported_features |= SUPPORT_CLOSE

return supported_features

async def async_toggle(self):
"""Toggle the entity."""
if self.has_command(COMMAND_CYCLE):
await self.async_execute_command(COMMAND_CYCLE)
else:
super().toggle()