Fixed Homematic cover (#3116)

pull/3132/head
Daniel Perna 2016-09-02 06:32:12 +02:00 committed by Teagan Glenn
parent 06df31bb5b
commit 0c310c166a
1 changed files with 5 additions and 5 deletions

View File

@ -11,7 +11,7 @@ properly configured.
import logging
from homeassistant.const import STATE_UNKNOWN
from homeassistant.components.cover import CoverDevice,\
ATTR_CURRENT_POSITION
ATTR_POSITION
import homeassistant.components.homematic as homematic
_LOGGER = logging.getLogger(__name__)
@ -41,16 +41,16 @@ class HMCover(homematic.HMDevice, CoverDevice):
None is unknown, 0 is closed, 100 is fully open.
"""
if self.available:
return int((1 - self._hm_get_state()) * 100)
return int(self._hm_get_state() * 100)
return None
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
if self.available:
if ATTR_CURRENT_POSITION in kwargs:
position = float(kwargs[ATTR_CURRENT_POSITION])
if ATTR_POSITION in kwargs:
position = float(kwargs[ATTR_POSITION])
position = min(100, max(0, position))
level = (100 - position) / 100.0
level = position / 100.0
self._hmdevice.set_level(level, self._channel)
@property