Skip to content

Commit

Permalink
Fix local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss committed Jun 17, 2024
1 parent d0fa820 commit f8ae014
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,18 @@ def state(self) -> int:
def interpolate_states(self, state):
"""Interpolate states."""
normal_range = [0, 100]
new_range = []
if self.start_value and self.end_value:
new_range = [self.start_value, self.end_value]
if self.normal_list and self.new_list:
normal_range = list(map(int, self.normal_list))
new_range = list(map(int, self.new_list))
state = np.interp(state, normal_range, new_range)
if state == new_range[0]:
state = 0
if state == new_range[-1]:
state = 100
if new_range:
state = np.interp(state, normal_range, new_range)
if state == new_range[0]:
state = 0
if state == new_range[-1]:
state = 100
return state

@property
Expand Down

0 comments on commit f8ae014

Please sign in to comment.