From b72aeb4c91cb0da78bafcca8785a288cf2234880 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Thu, 3 Dec 2020 09:38:55 +0100 Subject: [PATCH] Allow setting width for TDBU blinds --- motionblinds/__init__.py | 2 +- motionblinds/motion_blinds.py | 9 ++++++--- setup.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/motionblinds/__init__.py b/motionblinds/__init__.py index 6a9db75..44f9b38 100644 --- a/motionblinds/__init__.py +++ b/motionblinds/__init__.py @@ -11,7 +11,7 @@ logging.getLogger(__name__) __title__ = "motion-blinds" -__version__ = "0.4.0" +__version__ = "0.4.1" # Import motion_blinds module from .motion_blinds import MotionGateway diff --git a/motionblinds/motion_blinds.py b/motionblinds/motion_blinds.py index f64a151..8564ed7 100644 --- a/motionblinds/motion_blinds.py +++ b/motionblinds/motion_blinds.py @@ -954,7 +954,7 @@ def Close(self, motor: str = "B"): self._parse_response(response) - def Set_position(self, position, motor: str = "B"): + def Set_position(self, position, motor: str = "B", width: int = None): """ Set the position of the blind. @@ -962,6 +962,9 @@ def Set_position(self, position, motor: str = "B"): 0 = open 100 = closed """ + if width is None: + width = self.width + if motor == "B": if position >= self._position["T"]: data = {"targetPosition_B": position} @@ -975,8 +978,8 @@ def Set_position(self, position, motor: str = "B"): _LOGGER.error('Error setting position, the top of the TDBU blind can not go below the bottom of the TDBU blind') return elif motor == "C": - if position >= self.width/2.0 and position <= (100 - self.width/2.0): - data = {"targetPosition_T": position-self.width/2.0, "targetPosition_B": position+self.width/2.0} + if position >= width/2.0 and position <= (100 - width/2.0): + data = {"targetPosition_T": position-width/2.0, "targetPosition_B": position+width/2.0} else: _LOGGER.error('Error setting position, the combined TDBU blind cannot reach position %.1f, because including the width of %.1f, it would exceed its limits', position, width) return diff --git a/setup.py b/setup.py index e3b8745..0ae38db 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ README = (HERE / "README.md").read_text() setup(name='motionblinds', - version='0.4.0', + version='0.4.1', description='Python library for interfacing with Motion Blinds', long_description=README, long_description_content_type="text/markdown",