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