From 92e9e70eb828e39b9882427cc6de46ecf21d296b Mon Sep 17 00:00:00 2001 From: Paul Daumlechner Date: Fri, 24 Nov 2023 23:54:06 +0100 Subject: [PATCH] fix pylint --- pyvlx/heartbeat.py | 6 +- pyvlx/node_helper.py | 24 +++- pyvlx/node_updater.py | 71 ++++++++---- pyvlx/opening_device.py | 245 +++++++++++++++++++++++++--------------- pyvlx/parameter.py | 49 ++++---- 5 files changed, 251 insertions(+), 144 deletions(-) diff --git a/pyvlx/heartbeat.py b/pyvlx/heartbeat.py index 5dbc326a..30886694 100644 --- a/pyvlx/heartbeat.py +++ b/pyvlx/heartbeat.py @@ -15,7 +15,9 @@ class Heartbeat: """Class for sending heartbeats to API.""" - def __init__(self, pyvlx: "PyVLX", interval: int = 30, load_all_states: bool = True): + def __init__( + self, pyvlx: "PyVLX", interval: int = 30, load_all_states: bool = True + ): """Initialize Heartbeat object.""" PYVLXLOG.debug("Heartbeat __init__") self.pyvlx = pyvlx @@ -70,7 +72,7 @@ async def pulse(self) -> None: # If nodes contain Blind or DualRollerShutter device, refresh orientation or upper/lower curtain positions because House Monitoring # delivers wrong values for FP1, FP2 and FP3 parameter for node in self.pyvlx.nodes: - if isinstance(node, Blind) or isinstance(node, DualRollerShutter) or self.load_all_states: + if isinstance(node, (Blind, DualRollerShutter)) or self.load_all_states: status_request = StatusRequest(self.pyvlx, node.node_id) await status_request.do_api_call() # give user requests a chance diff --git a/pyvlx/node_helper.py b/pyvlx/node_helper.py index b7447ada..369b5b2f 100644 --- a/pyvlx/node_helper.py +++ b/pyvlx/node_helper.py @@ -3,22 +3,34 @@ from .api.frames import ( FrameGetAllNodesInformationNotification, - FrameGetNodeInformationNotification) + FrameGetNodeInformationNotification, +) from .const import NodeTypeWithSubtype from .lightening_device import Light from .log import PYVLXLOG from .node import Node from .on_off_switch import OnOffSwitch from .opening_device import ( - Awning, Blade, Blind, DualRollerShutter, GarageDoor, Gate, RollerShutter, - Window) + Awning, + Blade, + Blind, + DualRollerShutter, + GarageDoor, + Gate, + RollerShutter, + Window, +) if TYPE_CHECKING: from pyvlx import PyVLX -def convert_frame_to_node(pyvlx: "PyVLX", - frame: Union[FrameGetNodeInformationNotification, FrameGetAllNodesInformationNotification]) -> Optional[Node]: +def convert_frame_to_node( + pyvlx: "PyVLX", + frame: Union[ + FrameGetNodeInformationNotification, FrameGetAllNodesInformationNotification + ], +) -> Optional[Node]: """Convert FrameGet[All]Node[s]InformationNotification into Node object.""" # pylint: disable=too-many-return-statements @@ -55,7 +67,7 @@ def convert_frame_to_node(pyvlx: "PyVLX", if frame.node_type in [ NodeTypeWithSubtype.ROLLER_SHUTTER, - NodeTypeWithSubtype.SWINGING_SHUTTERS + NodeTypeWithSubtype.SWINGING_SHUTTERS, ]: return RollerShutter( pyvlx=pyvlx, diff --git a/pyvlx/node_updater.py b/pyvlx/node_updater.py index ddf37a4a..96c1b4a8 100644 --- a/pyvlx/node_updater.py +++ b/pyvlx/node_updater.py @@ -3,8 +3,11 @@ from typing import TYPE_CHECKING, Any from .api.frames import ( - FrameBase, FrameGetAllNodesInformationNotification, - FrameNodeStatePositionChangedNotification, FrameStatusRequestNotification) + FrameBase, + FrameGetAllNodesInformationNotification, + FrameNodeStatePositionChangedNotification, + FrameStatusRequestNotification, +) from .const import NodeParameter, OperatingState from .lightening_device import LighteningDevice from .log import PYVLXLOG @@ -23,16 +26,18 @@ def __init__(self, pyvlx: "PyVLX"): """Initialize NodeUpdater object.""" self.pyvlx = pyvlx - async def process_frame_status_request_notification(self, frame: FrameStatusRequestNotification) -> None: + async def process_frame_status_request_notification( + self, frame: FrameStatusRequestNotification + ) -> None: """Process FrameStatusRequestNotification.""" PYVLXLOG.debug("NodeUpdater process frame: %s", frame) if frame.node_id not in self.pyvlx.nodes: return node = self.pyvlx.nodes[frame.node_id] if isinstance(node, Blind): - if NodeParameter(0) not in frame.parameter_data: # MP missing in frame + if NodeParameter(0) not in frame.parameter_data: # MP missing in frame return - if NodeParameter(3) not in frame.parameter_data: # FP3 missing in frame + if NodeParameter(3) not in frame.parameter_data: # FP3 missing in frame return position = Position(frame.parameter_data[NodeParameter(0)]) orientation = Position(frame.parameter_data[NodeParameter(3)]) @@ -41,17 +46,15 @@ async def process_frame_status_request_notification(self, frame: FrameStatusRequ PYVLXLOG.debug("%s position changed to: %s", node.name, position) if orientation.position <= Parameter.MAX: node.orientation = orientation - PYVLXLOG.debug( - "%s orientation changed to: %s", node.name, orientation - ) + PYVLXLOG.debug("%s orientation changed to: %s", node.name, orientation) await node.after_update() if isinstance(node, DualRollerShutter): - if NodeParameter(0) not in frame.parameter_data: # MP missing in frame + if NodeParameter(0) not in frame.parameter_data: # MP missing in frame return - if NodeParameter(1) not in frame.parameter_data: # FP1 missing in frame + if NodeParameter(1) not in frame.parameter_data: # FP1 missing in frame return - if NodeParameter(2) not in frame.parameter_data: # FP2 missing in frame + if NodeParameter(2) not in frame.parameter_data: # FP2 missing in frame return position = Position(frame.parameter_data[NodeParameter(0)]) position_upper_curtain = Position(frame.parameter_data[NodeParameter(1)]) @@ -62,23 +65,27 @@ async def process_frame_status_request_notification(self, frame: FrameStatusRequ if position_upper_curtain.position <= Parameter.MAX: node.position_upper_curtain = position_upper_curtain PYVLXLOG.debug( - "%s position upper curtain changed to: %s", node.name, position_upper_curtain + "%s position upper curtain changed to: %s", + node.name, + position_upper_curtain, ) if position_lower_curtain.position <= Parameter.MAX: node.position_lower_curtain = position_lower_curtain PYVLXLOG.debug( - "%s position lower curtain changed to: %s", node.name, position_lower_curtain + "%s position lower curtain changed to: %s", + node.name, + position_lower_curtain, ) await node.after_update() async def process_frame(self, frame: FrameBase) -> None: """Update nodes via frame, usually received by house monitor.""" if isinstance( - frame, - ( - FrameGetAllNodesInformationNotification, - FrameNodeStatePositionChangedNotification, - ), + frame, + ( + FrameGetAllNodesInformationNotification, + FrameNodeStatePositionChangedNotification, + ), ): PYVLXLOG.debug("NodeUpdater process frame: %s", frame) if frame.node_id not in self.pyvlx.nodes: @@ -92,18 +99,34 @@ async def process_frame(self, frame: FrameBase) -> None: # Set opening device status if isinstance(node, OpeningDevice): - if (position.position > target.position <= Parameter.MAX) and ((frame.state == OperatingState.EXECUTING) or frame.remaining_time > 0): + if (position.position > target.position <= Parameter.MAX) and ( + (frame.state == OperatingState.EXECUTING) + or frame.remaining_time > 0 + ): node.is_opening = True PYVLXLOG.debug("%s is opening", node.name) node.state_received_at = datetime.datetime.now() - node.estimated_completion = node.state_received_at + datetime.timedelta(0, frame.remaining_time) - PYVLXLOG.debug("%s will be opening until", node.estimated_completion) - elif (position.position < target.position <= Parameter.MAX) and ((frame.state == OperatingState.EXECUTING) or frame.remaining_time > 0): + node.estimated_completion = ( + node.state_received_at + + datetime.timedelta(0, frame.remaining_time) + ) + PYVLXLOG.debug( + "%s will be opening until", node.estimated_completion + ) + elif (position.position < target.position <= Parameter.MAX) and ( + (frame.state == OperatingState.EXECUTING) + or frame.remaining_time > 0 + ): node.is_closing = True PYVLXLOG.debug("%s is closing", node.name) node.state_received_at = datetime.datetime.now() - node.estimated_completion = node.state_received_at + datetime.timedelta(0, frame.remaining_time) - PYVLXLOG.debug("%s will be closing until", node.estimated_completion) + node.estimated_completion = ( + node.state_received_at + + datetime.timedelta(0, frame.remaining_time) + ) + PYVLXLOG.debug( + "%s will be closing until", node.estimated_completion + ) else: if node.is_opening: node.is_opening = False diff --git a/pyvlx/opening_device.py b/pyvlx/opening_device.py index 56ce1012..9a58cac4 100644 --- a/pyvlx/opening_device.py +++ b/pyvlx/opening_device.py @@ -8,8 +8,13 @@ from .exception import PyVLXException from .node import Node from .parameter import ( - CurrentPosition, DualRollerShutterPosition, IgnorePosition, Parameter, - Position, TargetPosition) + CurrentPosition, + DualRollerShutterPosition, + IgnorePosition, + Parameter, + Position, + TargetPosition, +) if TYPE_CHECKING: from pyvlx import PyVLX @@ -19,12 +24,12 @@ class OpeningDevice(Node): """Meta class for opening device with one main parameter for position.""" def __init__( - self, - pyvlx: "PyVLX", - node_id: int, - name: str, - serial_number: str, - position_parameter: Parameter = Parameter() + self, + pyvlx: "PyVLX", + node_id: int, + name: str, + serial_number: str, + position_parameter: Parameter = Parameter(), ): """Initialize opening device. @@ -38,10 +43,7 @@ def __init__( """ super().__init__( - pyvlx=pyvlx, - node_id=node_id, - name=name, - serial_number=serial_number + pyvlx=pyvlx, node_id=node_id, name=name, serial_number=serial_number ) self.position = Position(parameter=position_parameter) self.target = Position(parameter=position_parameter) @@ -54,9 +56,12 @@ def __init__( self.open_position_target: int = 0 self.close_position_target: int = 100 - async def set_position(self, position: Position, - velocity: Velocity | int | None = Velocity.DEFAULT, - wait_for_completion: bool = True) -> None: + async def set_position( + self, + position: Position, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Set window to desired position. Parameters: @@ -68,29 +73,35 @@ async def set_position(self, position: Position, """ kwargs: Any = {} - if (velocity is None or velocity is Velocity.DEFAULT) and self.use_default_velocity: + if ( + velocity is None or velocity is Velocity.DEFAULT + ) and self.use_default_velocity: velocity = self.default_velocity if isinstance(velocity, Velocity): if velocity is not Velocity.DEFAULT: if velocity is Velocity.SILENT: - kwargs['fp1'] = Parameter(raw=b"\x00\x00") + kwargs["fp1"] = Parameter(raw=b"\x00\x00") else: - kwargs['fp1'] = Parameter(raw=b"\xC8\x00") + kwargs["fp1"] = Parameter(raw=b"\xC8\x00") elif isinstance(velocity, int): - kwargs['fp1'] = Position.from_percent(velocity) + kwargs["fp1"] = Position.from_percent(velocity) command = CommandSend( pyvlx=self.pyvlx, wait_for_completion=wait_for_completion, node_id=self.node_id, parameter=position, - functional_parameter=kwargs + functional_parameter=kwargs, ) await command.send() await self.after_update() - async def open(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion: bool = True) -> None: + async def open( + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Open window. Parameters: @@ -105,7 +116,11 @@ async def open(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_fo wait_for_completion=wait_for_completion, ) - async def close(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion: bool = True) -> None: + async def close( + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Close window. Parameters: @@ -134,10 +149,12 @@ async def stop(self, wait_for_completion: bool = True) -> None: def __str__(self) -> str: """Return object as readable string.""" - return ( - '<{} name="{}" node_id="{}" serial_number="{}" position="{}"/>'.format( - type(self).__name__, self.name, self.node_id, self.serial_number, self.position - ) + return '<{} name="{}" node_id="{}" serial_number="{}" position="{}"/>'.format( + type(self).__name__, + self.name, + self.node_id, + self.serial_number, + self.position, ) @@ -145,13 +162,13 @@ class Window(OpeningDevice): """Window object.""" def __init__( - self, - pyvlx: "PyVLX", - node_id: int, - name: str, - serial_number: str, - position_parameter: Parameter = Parameter(), - rain_sensor: bool = False, + self, + pyvlx: "PyVLX", + node_id: int, + name: str, + serial_number: str, + position_parameter: Parameter = Parameter(), + rain_sensor: bool = False, ): """Initialize Window class. @@ -177,11 +194,13 @@ def __init__( def __str__(self) -> str: """Return object as readable string.""" - return ( - '<{} name="{}" node_id="{}" rain_sensor={} serial_number="{}" position="{}"/>'.format( - type(self).__name__, self.name, self.node_id, - self.rain_sensor, self.serial_number, self.position - ) + return '<{} name="{}" node_id="{}" rain_sensor={} serial_number="{}" position="{}"/>'.format( + type(self).__name__, + self.name, + self.node_id, + self.rain_sensor, + self.serial_number, + self.position, ) async def get_limitation(self) -> GetLimitation: @@ -197,7 +216,12 @@ class Blind(OpeningDevice): """Blind objects.""" def __init__( - self, pyvlx: "PyVLX", node_id: int, name: str, serial_number: str, position_parameter: Parameter = Parameter() + self, + pyvlx: "PyVLX", + node_id: int, + name: str, + serial_number: str, + position_parameter: Parameter = Parameter(), ): """Initialize Blind class. @@ -222,11 +246,12 @@ def __init__( self.close_orientation_target: int = 100 async def set_position_and_orientation( - self, - position: Position, - wait_for_completion: bool = True, - velocity: Velocity | int | None = None, - orientation: Optional[Position] = None) -> None: + self, + position: Position, + wait_for_completion: bool = True, + velocity: Velocity | int | None = None, + orientation: Optional[Position] = None, + ) -> None: """Set window to desired position. Parameters: @@ -246,24 +271,26 @@ async def set_position_and_orientation( kwargs: Any = {} if orientation is not None: - kwargs['fp3'] = orientation + kwargs["fp3"] = orientation elif self.target_position == Position(position_percent=0): - kwargs['fp3'] = Position(position_percent=0) + kwargs["fp3"] = Position(position_percent=0) else: - kwargs['fp3'] = IgnorePosition() + kwargs["fp3"] = IgnorePosition() - if (velocity is None or velocity is Velocity.DEFAULT) and self.use_default_velocity: + if ( + velocity is None or velocity is Velocity.DEFAULT + ) and self.use_default_velocity: velocity = self.default_velocity if isinstance(velocity, Velocity): if velocity is not Velocity.DEFAULT: if velocity is Velocity.SILENT: # The above code is declaring a variable called `kwargs`. - kwargs['fp1'] = Parameter(raw=b"\x00\x00") + kwargs["fp1"] = Parameter(raw=b"\x00\x00") else: - kwargs['fp1'] = Parameter(raw=b"\xC8\x00") + kwargs["fp1"] = Parameter(raw=b"\xC8\x00") elif isinstance(velocity, int): - kwargs['fp1'] = Position.from_percent(velocity) + kwargs["fp1"] = Position.from_percent(velocity) command = CommandSend( pyvlx=self.pyvlx, @@ -275,7 +302,12 @@ async def set_position_and_orientation( await command.send() await self.after_update() - async def set_position(self, position: Position, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion: bool = True) -> None: + async def set_position( + self, + position: Position, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Set window to desired position. Parameters: @@ -287,9 +319,17 @@ async def set_position(self, position: Position, velocity: Velocity | int | None * wait_for_completion: If set, function will return after device has reached target position. """ - await self.set_position_and_orientation(position=position, wait_for_completion=wait_for_completion, velocity=velocity) + await self.set_position_and_orientation( + position=position, + wait_for_completion=wait_for_completion, + velocity=velocity, + ) - async def open(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion: bool = True) -> None: + async def open( + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Open window. Parameters: @@ -303,7 +343,11 @@ async def open(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_fo wait_for_completion=wait_for_completion, ) - async def close(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion: bool = True) -> None: + async def close( + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + ) -> None: """Close window. Parameters: @@ -320,10 +364,14 @@ async def close(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_f async def stop(self, wait_for_completion: bool = True) -> None: """Stop Blind position.""" await self.set_position_and_orientation( - position=CurrentPosition(), wait_for_completion=wait_for_completion, orientation=self.target_orientation + position=CurrentPosition(), + wait_for_completion=wait_for_completion, + orientation=self.target_orientation, ) - async def set_orientation(self, orientation: Position, wait_for_completion: bool = True) -> None: + async def set_orientation( + self, orientation: Position, wait_for_completion: bool = True + ) -> None: """Set Blind shades to desired orientation. Parameters: @@ -338,9 +386,11 @@ async def set_orientation(self, orientation: Position, wait_for_completion: bool self.target_orientation = TargetPosition.from_position(orientation) self.orientation = orientation - fp3 = Position(position_percent=0)\ - if self.target_position == Position(position_percent=0)\ + fp3 = ( + Position(position_percent=0) + if self.target_position == Position(position_percent=0) else self.target_orientation + ) print("Orientation in device: %s " % (orientation)) command = CommandSend( @@ -387,12 +437,12 @@ class DualRollerShutter(OpeningDevice): """DualRollerShutter object.""" def __init__( - self, - pyvlx: "PyVLX", - node_id: int, - name: str, - serial_number: str, - position_parameter: Parameter = Parameter() + self, + pyvlx: "PyVLX", + node_id: int, + name: str, + serial_number: str, + position_parameter: Parameter = Parameter(), ): """Initialize Blind class. @@ -415,11 +465,13 @@ def __init__( self.target_position: Any = TargetPosition() self.active_parameter = 0 - async def set_position(self, - position: Position, - velocity: Velocity | int | None = Velocity.DEFAULT, - wait_for_completion: bool = True, - curtain: str = "dual") -> None: + async def set_position( + self, + position: Position, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + curtain: str = "dual", + ) -> None: """Set window to desired position. Parameters: @@ -434,28 +486,30 @@ async def set_position(self, if curtain == "upper": self.target_position = DualRollerShutterPosition() self.active_parameter = 1 - kwargs['fp1'] = position - kwargs['fp2'] = TargetPosition() + kwargs["fp1"] = position + kwargs["fp2"] = TargetPosition() elif curtain == "lower": self.target_position = DualRollerShutterPosition() self.active_parameter = 2 - kwargs['fp1'] = TargetPosition() - kwargs['fp2'] = position + kwargs["fp1"] = TargetPosition() + kwargs["fp2"] = position else: self.target_position = position self.active_parameter = 0 - if (velocity is None or velocity is Velocity.DEFAULT) and self.use_default_velocity: + if ( + velocity is None or velocity is Velocity.DEFAULT + ) and self.use_default_velocity: velocity = self.default_velocity if isinstance(velocity, Velocity): if velocity is not Velocity.DEFAULT: if velocity is Velocity.SILENT: - kwargs['fp3'] = Parameter(raw=b"\x00\x00") + kwargs["fp3"] = Parameter(raw=b"\x00\x00") else: - kwargs['fp3'] = Parameter(raw=b"\xC8\x00") + kwargs["fp3"] = Parameter(raw=b"\xC8\x00") elif isinstance(velocity, int): - kwargs['fp3'] = Position.from_percent(velocity) + kwargs["fp3"] = Position.from_percent(velocity) command = CommandSend( pyvlx=self.pyvlx, @@ -476,10 +530,11 @@ async def set_position(self, await self.after_update() async def open( - self, - velocity: Velocity | int | None = Velocity.DEFAULT, - wait_for_completion: bool = True, - curtain: str = "dual") -> None: + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + curtain: str = "dual", + ) -> None: """Open window. Parameters: @@ -491,13 +546,15 @@ async def open( position=Position(position_percent=self.open_position_target), velocity=velocity, wait_for_completion=wait_for_completion, - curtain=curtain + curtain=curtain, ) - async def close(self, - velocity: Velocity | int | None = Velocity.DEFAULT, - wait_for_completion: bool = True, - curtain: str = "dual") -> None: + async def close( + self, + velocity: Velocity | int | None = Velocity.DEFAULT, + wait_for_completion: bool = True, + curtain: str = "dual", + ) -> None: """Close window. Parameters: @@ -508,19 +565,21 @@ async def close(self, position=Position(position_percent=self.close_position_target), velocity=velocity, wait_for_completion=wait_for_completion, - curtain=curtain + curtain=curtain, ) - async def stop(self, - wait_for_completion: bool = True, - velocity: Velocity | int | None = Velocity.DEFAULT, - curtain: str = "dual") -> None: + async def stop( + self, + wait_for_completion: bool = True, + velocity: Velocity | int | None = Velocity.DEFAULT, + curtain: str = "dual", + ) -> None: """Stop Blind position.""" await self.set_position( position=CurrentPosition(), velocity=velocity, wait_for_completion=wait_for_completion, - curtain=curtain + curtain=curtain, ) diff --git a/pyvlx/parameter.py b/pyvlx/parameter.py index 47f1cf4c..feb1b509 100644 --- a/pyvlx/parameter.py +++ b/pyvlx/parameter.py @@ -52,15 +52,14 @@ def is_valid_int(value: int) -> bool: """Test if value can be rendered out of int.""" if 0 <= value <= Parameter.MAX: # This includes ON and OFF return True - if value == Parameter.UNKNOWN_VALUE: - return True - if value == Parameter.IGNORE: - return True - if value == Parameter.CURRENT: - return True - if value == Parameter.TARGET: - return True - if value == Parameter.DUAL_SHUTTER_CURTAINS: + valid_values = { + Parameter.UNKNOWN_VALUE.value, + Parameter.IGNORE.value, + Parameter.CURRENT.value, + Parameter.TARGET.value, + Parameter.DUAL_SHUTTER_CURTAINS.value + } + if value in valid_values: return True return False @@ -72,11 +71,11 @@ def from_raw(raw: bytes) -> bytes: if len(raw) != 2: raise PyVLXException("Position::raw_must_be_two_bytes") if ( - raw != Position.from_int(Position.CURRENT) - and raw != Position.from_int(Position.IGNORE) - and raw != Position.from_int(Position.TARGET) - and raw != Position.from_int(Position.UNKNOWN_VALUE) - and Position.to_int(raw) > Position.MAX + raw != Position.from_int(Position.CURRENT) + and raw != Position.from_int(Position.IGNORE) + and raw != Position.from_int(Position.TARGET) + and raw != Position.from_int(Position.UNKNOWN_VALUE) + and Position.to_int(raw) > Position.MAX ): return Position.from_int(Position.UNKNOWN_VALUE) return raw @@ -124,7 +123,9 @@ def __str__(self) -> str: class SwitchParameter(Parameter): """Class for storing On or Off values.""" - def __init__(self, parameter: Optional[Parameter] = None, state: Optional[int] = None): + def __init__( + self, parameter: Optional[Parameter] = None, state: Optional[int] = None + ): """Initialize Parameter class.""" super().__init__() if parameter is not None: @@ -162,9 +163,9 @@ def __str__(self) -> str: """Return string representation of object.""" if self.raw == self.from_int(Parameter.ON): return "ON" - elif self.raw == self.from_int(Parameter.OFF): + if self.raw == self.from_int(Parameter.OFF): return "OFF" - else: + return "UNKNOWN" @@ -187,7 +188,12 @@ def __init__(self) -> None: class Position(Parameter): """Class for storing a position.""" - def __init__(self, parameter: Optional[Parameter] = None, position: Optional[int] = None, position_percent: Optional[int] = None): + def __init__( + self, + parameter: Optional[Parameter] = None, + position: Optional[int] = None, + position_percent: Optional[int] = None, + ): """Initialize Position class.""" super().__init__() if parameter is not None: @@ -284,7 +290,12 @@ def __init__(self) -> None: class Intensity(Parameter): """Class for storing an intensity.""" - def __init__(self, parameter: Optional[Parameter] = None, intensity: Optional[int] = None, intensity_percent: Optional[int] = None): + def __init__( + self, + parameter: Optional[Parameter] = None, + intensity: Optional[int] = None, + intensity_percent: Optional[int] = None, + ): """Initialize Intensity class.""" super().__init__() if parameter is not None: