Skip to content

Commit

Permalink
Use more constants for cover (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Nov 25, 2024
1 parent 3c611ea commit 0391c0e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions hahomematic/model/custom/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
_CLOSED_LEVEL: Final = 0.0
_COVER_VENT_MAX_POSITION: Final = 50
_LEVEL_TO_POSITION_MULTIPLIER: Final = 100.0
_MAX_LEVEL_POSITION: Final = 100.0
_MIN_LEVEL_POSITION: Final = 0.0
_OPEN_LEVEL: Final = 1.0
_OPEN_TILT_LEVEL: Final = 1.0
_WD_CLOSED_LEVEL: Final = -0.005
Expand Down Expand Up @@ -125,8 +127,7 @@ async def set_position(
if not self.is_state_change(position=position):
return
level = (
min(_LEVEL_TO_POSITION_MULTIPLIER, max(self._dp_level.min, position))
/ _LEVEL_TO_POSITION_MULTIPLIER
min(_MAX_LEVEL_POSITION, max(_MIN_LEVEL_POSITION, position)) / _MAX_LEVEL_POSITION
if position is not None
else None
)
Expand Down Expand Up @@ -290,14 +291,12 @@ async def set_position(
if not self.is_state_change(position=position, tilt_position=tilt_position):
return
level = (
min(_LEVEL_TO_POSITION_MULTIPLIER, max(self._dp_level.min, position))
/ _LEVEL_TO_POSITION_MULTIPLIER
min(_MAX_LEVEL_POSITION, max(_MIN_LEVEL_POSITION, position)) / _MAX_LEVEL_POSITION
if position is not None
else None
)
tilt_level = (
min(_LEVEL_TO_POSITION_MULTIPLIER, max(self._dp_level_2.min, tilt_position))
/ _LEVEL_TO_POSITION_MULTIPLIER
min(_MAX_LEVEL_POSITION, max(_MIN_LEVEL_POSITION, tilt_position)) / _MAX_LEVEL_POSITION
if tilt_position is not None
else None
)
Expand Down

0 comments on commit 0391c0e

Please sign in to comment.