From c959becfe1dc0e554add96eb3376890683320b2f Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Fri, 21 Sep 2018 17:43:05 +0200 Subject: [PATCH] Fix proper setting of cover position --- homeassistant/components/cover/deconz.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/cover/deconz.py b/homeassistant/components/cover/deconz.py index e1c4db0ec68faf..ad75f022d551e5 100644 --- a/homeassistant/components/cover/deconz.py +++ b/homeassistant/components/cover/deconz.py @@ -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): @@ -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):