diff --git a/pyvlx/opening_device.py b/pyvlx/opening_device.py index 9b9c9a73..2a595bda 100644 --- a/pyvlx/opening_device.py +++ b/pyvlx/opening_device.py @@ -5,8 +5,7 @@ from .api.get_limitation import GetLimitation from .exception import PyVLXException from .node import Node -from .parameter import ( - CurrentPosition, IgnorePosition, Parameter, Position, TargetPosition) +from .parameter import CurrentPosition, IgnorePosition, Parameter, Position if TYPE_CHECKING: from pyvlx import PyVLX @@ -145,7 +144,7 @@ def __str__(self) -> str: ) async def get_limitation(self) -> GetLimitation: - """Return limitaation.""" + """Return limitation.""" get_limitation = GetLimitation(pyvlx=self.pyvlx, node_id=self.node_id) await get_limitation.do_api_call() if not get_limitation.success: @@ -176,21 +175,22 @@ def __init__( position_parameter=position_parameter, ) self.orientation = Position(position_percent=0) - self.target_orientation = TargetPosition() - self.target_position = TargetPosition() + self.target_orientation = Position() + self.target_position = Position() self.open_orientation_target: int = 50 self.close_orientation_target: int = 100 - async def set_position_and_orientation(self, - position: Position, - wait_for_completion: bool = True, - orientation: Optional[Position] = None) -> None: + async def set_position_and_orientation( + self, + position: Position, + wait_for_completion: bool = True, + orientation: Optional[Position] = None) -> None: """Set window to desired position. Parameters: * position: Position object containing the current position. * target_position: Position object holding the target position - which allows to ajust the position while the blind is in movement + which allows to adjust the position while the blind is in movement without stopping the blind (if orientation position has been changed.) * wait_for_completion: If set, function will return after device has reached target position. @@ -198,7 +198,7 @@ async def set_position_and_orientation(self, Note, that, if the position is set to 0, the orientation will be set to 0 too. """ - self.target_position = TargetPosition.from_position(position) + self.target_position = position self.position = position fp3: Position @@ -227,7 +227,7 @@ async def set_position(self, position: Position, wait_for_completion: bool = Tru Parameters: * position: Position object containing the current position. * target_position: Position object holding the target position - which allows to ajust the position while the blind is in movement + which allows to adjust the position while the blind is in movement without stopping the blind (if orientation position has been changed.) * wait_for_completion: If set, function will return after device has reached target position. @@ -276,7 +276,7 @@ async def set_orientation(self, orientation: Position, wait_for_completion: bool after device has reached target position. """ - self.target_orientation = TargetPosition.from_position(orientation) + self.target_orientation = orientation self.orientation = orientation fp3 = Position(position_percent=0)\ diff --git a/pyvlx/parameter.py b/pyvlx/parameter.py index 2bc2c05d..c06039ee 100644 --- a/pyvlx/parameter.py +++ b/pyvlx/parameter.py @@ -30,7 +30,7 @@ def from_parameter(self, parameter: "Parameter") -> None: @staticmethod def from_int(value: int) -> bytes: - """Create raw out of position vlaue.""" + """Create raw out of position value.""" if not isinstance(value, int): raise PyVLXException("value_has_to_be_int") if not Parameter.is_valid_int(value): @@ -201,7 +201,7 @@ def from_percent(position_percent: int) -> bytes: @staticmethod def to_percent(raw: bytes) -> int: """Create percent position value out of raw.""" - # The first byte has the vlue from 0 to 200. Ignoring the second one. + # The first byte has the value from 0 to 200. Ignoring the second one. # Adding 0.5 allows a slight tolerance for devices (e.g. Velux SML) that # do not return exactly 51200 as final position when closed. return int(raw[0] / 2 + 0.5) @@ -230,26 +230,12 @@ def __init__(self) -> None: class TargetPosition(Position): - """Class for using a target position, if another parameter is set. - - It is implemented by taking the target parameter value and loads it into the execution - parameter buffer. When the target value is read, it holds for a given parameter always the - latest stored target value about a command execution. - - """ + """Class for using a target position.""" def __init__(self) -> None: """Initialize TargetPosition class.""" super().__init__(position=Position.TARGET) - @staticmethod - def from_position(from_position: Position) -> "TargetPosition": - """Create TargetPosition from an existing position.""" - target = TargetPosition() - target.position = from_position.position - target.position_percent = from_position.position_percent - return target - class IgnorePosition(Position): """The Ignore is used where a parameter in the frame is to be ignored.""" @@ -304,7 +290,7 @@ def intensity(self, intensity: int) -> None: @property def intensity_percent(self) -> int: """Intensity percent property.""" - # inclear why it returns a here + # unclear why it returns a here return int(self.to_percent(self.raw)) @intensity_percent.setter