mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Position is reversed for horizontal awnings (#23257)
* Position is reversed for awnings * Changed device class function to use map * It wanted more linebreak * Updated defaults * Shortened line * space
This commit is contained in:
parent
0eb387916f
commit
d041c62f55
@ -2,7 +2,10 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
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 homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
||||||
@ -16,6 +19,24 @@ ATTR_LOCK_END_TS = 'lock_end_ts'
|
|||||||
ATTR_LOCK_LEVEL = 'lock_level'
|
ATTR_LOCK_LEVEL = 'lock_level'
|
||||||
ATTR_LOCK_ORIG = 'lock_originator'
|
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):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Tahoma covers."""
|
"""Set up the Tahoma covers."""
|
||||||
@ -109,12 +130,18 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
|||||||
# _position: 0 is closed, 100 is fully open.
|
# _position: 0 is closed, 100 is fully open.
|
||||||
# 'core:ClosureState': 100 is closed, 0 is fully open.
|
# 'core:ClosureState': 100 is closed, 0 is fully open.
|
||||||
if self._closure is not None:
|
if self._closure is not None:
|
||||||
|
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
|
||||||
|
self._position = self._closure
|
||||||
|
else:
|
||||||
self._position = 100 - self._closure
|
self._position = 100 - self._closure
|
||||||
if self._position <= 5:
|
if self._position <= 5:
|
||||||
self._position = 0
|
self._position = 0
|
||||||
if self._position >= 95:
|
if self._position >= 95:
|
||||||
self._position = 100
|
self._position = 100
|
||||||
|
if self.tahoma_device.type == 'io:HorizontalAwningIOComponent':
|
||||||
self._closed = self._position == 0
|
self._closed = self._position == 0
|
||||||
|
else:
|
||||||
|
self._closed = self._position == 100
|
||||||
else:
|
else:
|
||||||
self._position = None
|
self._position = None
|
||||||
if 'core:OpenClosedState' in self.tahoma_device.active_states:
|
if 'core:OpenClosedState' in self.tahoma_device.active_states:
|
||||||
@ -133,7 +160,11 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
|||||||
|
|
||||||
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."""
|
||||||
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
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
@ -143,9 +174,7 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of the device."""
|
"""Return the class of the device."""
|
||||||
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
|
return TAHOMA_DEVICE_CLASSES.get(self.tahoma_device.type)
|
||||||
return 'window'
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user