Skip to content

Commit

Permalink
Merge pull request #82 from iMicknl/fix_44
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Jun 22, 2020
2 parents 91bffec + 3b3c534 commit 5dd234b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions custom_components/tahoma/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 10 additions & 4 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -112,15 +113,20 @@ 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(
CORE_SLATS_ORIENTATION_STATE
)

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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5dd234b

Please sign in to comment.