Skip to content
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
12 changes: 8 additions & 4 deletions homeassistant/components/homematicip_cloud/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

_LOGGER = logging.getLogger(__name__)

HMIP_COVER_OPEN = 0
HMIP_COVER_CLOSED = 1


async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None):
Expand Down Expand Up @@ -47,23 +50,24 @@ def current_cover_position(self):
async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
position = kwargs[ATTR_POSITION]
level = position / 100.0
# HmIP cover is closed:1 -> open:0
level = 1 - position / 100.0
await self._device.set_shutter_level(level)

@property
def is_closed(self):
"""Return if the cover is closed."""
if self._device.shutterLevel is not None:
return self._device.shutterLevel == 0
return self._device.shutterLevel == HMIP_COVER_CLOSED
return None

async def async_open_cover(self, **kwargs):
"""Open the cover."""
await self._device.set_shutter_level(1)
await self._device.set_shutter_level(HMIP_COVER_OPEN)

async def async_close_cover(self, **kwargs):
"""Close the cover."""
await self._device.set_shutter_level(0)
await self._device.set_shutter_level(HMIP_COVER_CLOSED)

async def async_stop_cover(self, **kwargs):
"""Stop the device if in motion."""
Expand Down