Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position is reversed for horizontal awnings #23257

Merged
merged 6 commits into from Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 36 additions & 7 deletions homeassistant/components/tahoma/cover.py
Expand Up @@ -2,7 +2,10 @@
from datetime import timedelta
import logging

from homeassistant.components.cover import ATTR_POSITION, CoverDevice
from homeassistant.components.cover import (
ATTR_POSITION, DEVICE_CLASS_AWNING, DEVICE_CLASS_BLIND,
DEVICE_CLASS_CURTAIN, DEVICE_CLASS_GARAGE, DEVICE_CLASS_SHUTTER,
DEVICE_CLASS_WINDOW, CoverDevice)
from homeassistant.util.dt import utcnow

from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
Expand All @@ -16,6 +19,24 @@
ATTR_LOCK_LEVEL = 'lock_level'
ATTR_LOCK_ORIG = 'lock_originator'

TAHOMA_DEVICE_CLASSES = {
'io:ExteriorVenetianBlindIOComponent': DEVICE_CLASS_BLIND,
'io:HorizontalAwningIOComponent': DEVICE_CLASS_AWNING,
'io:RollerShutterGenericIOComponent': DEVICE_CLASS_SHUTTER,
'io:RollerShutterUnoIOComponent': DEVICE_CLASS_SHUTTER,
'io:RollerShutterVeluxIOComponent': DEVICE_CLASS_SHUTTER,
'io:RollerShutterWithLowSpeedManagementIOComponent': DEVICE_CLASS_SHUTTER,
'io:VerticalExteriorAwningIOComponent': DEVICE_CLASS_AWNING,
'io:WindowOpenerVeluxIOComponent': DEVICE_CLASS_WINDOW,
'io:GarageOpenerIOComponent': DEVICE_CLASS_GARAGE,
'rts:BlindRTSComponent': DEVICE_CLASS_BLIND,
'rts:CurtainRTSComponent': DEVICE_CLASS_CURTAIN,
'rts:DualCurtainRTSComponent': DEVICE_CLASS_CURTAIN,
'rts:ExteriorVenetianBlindRTSComponent': DEVICE_CLASS_BLIND,
'rts:RollerShutterRTSComponent': DEVICE_CLASS_SHUTTER,
'rts:VenetianBlindRTSComponent': DEVICE_CLASS_BLIND
}


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tahoma covers."""
Expand Down Expand Up @@ -109,12 +130,18 @@ 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:
self._position = 100 - self._closure
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
awarecan marked this conversation as resolved.
Show resolved Hide resolved
self._position = self._closure
else:
self._position = 100 - self._closure
if self._position <= 5:
self._position = 0
if self._position >= 95:
self._position = 100
self._closed = self._position == 0
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 @@ -133,7 +160,11 @@ def current_cover_position(self):

def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
self.apply_action('setPosition', 100 - kwargs.get(ATTR_POSITION))
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
self.apply_action('setPosition', kwargs.get(ATTR_POSITION, 0))
else:
self.apply_action('setPosition',
100 - kwargs.get(ATTR_POSITION, 0))

@property
def is_closed(self):
Expand All @@ -143,9 +174,7 @@ def is_closed(self):
@property
def device_class(self):
"""Return the class of the device."""
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
return 'window'
return None
return TAHOMA_DEVICE_CLASSES.get(self.tahoma_device.type)

@property
def device_state_attributes(self):
Expand Down