Skip to content

Commit

Permalink
Allow setting width for TDBU blinds
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Dec 3, 2020
1 parent 5fc41aa commit b72aeb4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion motionblinds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions motionblinds/motion_blinds.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,14 +954,17 @@ 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.
position is in %, so 0-100
0 = open
100 = closed
"""
if width is None:
width = self.width

if motor == "B":
if position >= self._position["T"]:
data = {"targetPosition_B": position}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b72aeb4

Please sign in to comment.