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
26 changes: 10 additions & 16 deletions homeassistant/components/tahoma/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
ATTR_LOCK_LEVEL = 'lock_level'
ATTR_LOCK_ORIG = 'lock_originator'

HORIZONTAL_AWNING = 'io:HorizontalAwningIOComponent'

TAHOMA_DEVICE_CLASSES = {
'io:ExteriorVenetianBlindIOComponent': DEVICE_CLASS_BLIND,
'io:HorizontalAwningIOComponent': DEVICE_CLASS_AWNING,
HORIZONTAL_AWNING: DEVICE_CLASS_AWNING,
'io:RollerShutterGenericIOComponent': DEVICE_CLASS_SHUTTER,
'io:RollerShutterUnoIOComponent': DEVICE_CLASS_SHUTTER,
'io:RollerShutterVeluxIOComponent': DEVICE_CLASS_SHUTTER,
Expand Down Expand Up @@ -130,18 +132,16 @@ def update(self):
# _position: 0 is closed, 100 is fully open.
# 'core:ClosureState': 100 is closed, 0 is fully open.
if self._closure is not None:
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
if self.tahoma_device.type == HORIZONTAL_AWNING:
self._position = self._closure
self._closed = self._position == 0
else:
self._position = 100 - self._closure
self._closed = self._position == 100
if self._position <= 5:
self._position = 0
if self._position >= 95:
self._position = 100
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
self._closed = self._position == 0
else:
self._closed = self._position == 100
else:
self._position = None
if 'core:OpenClosedState' in self.tahoma_device.active_states:
Expand All @@ -160,7 +160,7 @@ def current_cover_position(self):

def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
if self.tahoma_device.type == HORIZONTAL_AWNING:
self.apply_action('setPosition', kwargs.get(ATTR_POSITION, 0))
else:
self.apply_action('setPosition',
Expand Down Expand Up @@ -206,17 +206,11 @@ def icon(self):

def open_cover(self, **kwargs):
"""Open the cover."""
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
self.apply_action('close')
else:
self.apply_action('open')
self.apply_action('open')

def close_cover(self, **kwargs):
"""Close the cover."""
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
self.apply_action('open')
else:
self.apply_action('close')
self.apply_action('close')

def stop_cover(self, **kwargs):
"""Stop the cover."""
Expand All @@ -232,7 +226,7 @@ def stop_cover(self, **kwargs):
'rts:BlindRTSComponent'):
self.apply_action('my')
elif self.tahoma_device.type in \
('io:HorizontalAwningIOComponent',
(HORIZONTAL_AWNING,
'io:RollerShutterGenericIOComponent',
'io:VerticalExteriorAwningIOComponent'):
self.apply_action('stop')
Expand Down