Skip to content

Commit

Permalink
Fix proper setting of cover position
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 committed Sep 21, 2018
1 parent b1984d5 commit c959bec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions homeassistant/components/cover/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ def async_update_callback(self, reason):
@property
def current_cover_position(self):
"""Return the current position of the cover."""
if self.is_closed:
return 0
return int(self._cover.brightness / 255 * 100)

@property
def is_closed(self):
"""Return if the cover is closed."""
return self.current_cover_position == 0
return not self._cover.state

@property
def name(self):
Expand Down Expand Up @@ -108,16 +110,22 @@ def should_poll(self):

async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
data = {'bri': int(kwargs.get(ATTR_POSITION) / 100 * 255)}
position = kwargs[ATTR_POSITION]
data = {'on': False}
if position > 0:
data['on'] = True
data['bri'] = int(position / 100 * 255)
await self._cover.async_set_state(data)

async def async_open_cover(self, **kwargs):
"""Open cover."""
await self.async_set_cover_position(100)
data = {ATTR_POSITION: 100}
await self.async_set_cover_position(**data)

async def async_close_cover(self, **kwargs):
"""Close cover."""
await self.async_set_cover_position(0)
data = {ATTR_POSITION: 0}
await self.async_set_cover_position(**data)

@property
def device_info(self):
Expand Down

0 comments on commit c959bec

Please sign in to comment.