diff --git a/custom_components/tahoma/const.py b/custom_components/tahoma/const.py index 620f65711..ce2a31d8e 100644 --- a/custom_components/tahoma/const.py +++ b/custom_components/tahoma/const.py @@ -68,6 +68,7 @@ "SwingingShutter": DEVICE_CLASS_SHUTTER, } + # Used to map the Somfy widget or uiClass to the Home Assistant device classes TAHOMA_BINARY_SENSOR_DEVICE_CLASSES = { "SmokeSensor": DEVICE_CLASS_SMOKE, @@ -97,6 +98,7 @@ CORE_RSSI_LEVEL_STATE = "core:RSSILevelState" CORE_STATUS_STATE = "core:StatusState" CORE_CLOSURE_STATE = "core:ClosureState" +CORE_TARGET_CLOSURE_STATE = "core:TargetClosureState" CORE_DEPLOYMENT_STATE = "core:DeploymentState" CORE_SLATS_ORIENTATION_STATE = "core:SlatsOrientationState" CORE_PRIORITY_LOCK_TIMER_STATE = "core:PriorityLockTimerState" diff --git a/custom_components/tahoma/cover.py b/custom_components/tahoma/cover.py index b9a34b258..e58ea2fe4 100644 --- a/custom_components/tahoma/cover.py +++ b/custom_components/tahoma/cover.py @@ -39,6 +39,7 @@ CORE_PEDESTRIAN_POSITION_STATE, CORE_PRIORITY_LOCK_TIMER_STATE, CORE_SLATS_ORIENTATION_STATE, + CORE_TARGET_CLOSURE_STATE, DOMAIN, IO_PRIORITY_LOCK_LEVEL_STATE, IO_PRIORITY_LOCK_ORIGINATOR_STATE, @@ -112,6 +113,11 @@ def update(self): CORE_PEDESTRIAN_POSITION_STATE ) + if CORE_TARGET_CLOSURE_STATE in self.tahoma_device.active_states: + self._position = 100 - self.tahoma_device.active_states.get( + CORE_TARGET_CLOSURE_STATE + ) + # Set tilt position for slats if CORE_SLATS_ORIENTATION_STATE in self.tahoma_device.active_states: self._tilt_position = 100 - self.tahoma_device.active_states.get( @@ -119,8 +125,8 @@ def update(self): ) if getattr(self, "_position", False): - # PositionableHorizontalAwning (e.g. io:HorizontalAwningIOComponent uses a reversed position) - if self.tahoma_device.widget == "PositionableHorizontalAwning": + # HorizontalAwning devices need a reversed position that can not be obtained via the API + if "Horizontal" in self.tahoma_device.widget: self._position = 100 - self._position # TODO Check if this offset is really necessary @@ -178,8 +184,8 @@ def set_cover_position(self, **kwargs): """Move the cover to a specific position.""" position = 100 - kwargs.get(ATTR_POSITION, 0) - # PositionableHorizontalAwning (e.g. io:HorizontalAwningIOComponent uses a reversed position) - if self.tahoma_device.widget == "PositionableHorizontalAwning": + # HorizontalAwning devices need a reversed position that can not be obtained via the API + if "Horizontal" in self.tahoma_device.widget: position = kwargs.get(ATTR_POSITION, 0) if COMMAND_SET_POSITION in self.tahoma_device.command_definitions: