Skip to content

Commit

Permalink
Update temperature_helper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
elden1337 authored Nov 15, 2024
1 parent 0fc03ae commit 708a24f
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@

_LOGGER = logging.getLogger(__name__)


def get_tempdiff_inverted(current_offset: int, temp_diff: float, min_temp_diff: float, determine_tolerance: callable) -> int:
diff = temp_diff + 0.00001
min_diff_influence = min_temp_diff * 0.5 if min_temp_diff < 0 else 0
combined_diff = diff + min_diff_influence

if abs(combined_diff) < 0.2:

def calc_int(diff: float) -> int:
diff += 0.00001
if abs(diff) < 0.2:
return 0
_tolerance = determine_tolerance(diff * -1, current_offset)
return floor(abs(diff) / _tolerance) * (-1 if diff > 0 else 1)

ret = calc_int(temp_diff)
min_ret = calc_int(min_temp_diff * 0.5 if min_temp_diff < 0 else 0)
combined_ret = ret + min_ret

if abs(combined_ret) < 0.2:
return 0

_tolerance = determine_tolerance(combined_diff * -1, current_offset)
ret = floor(abs(combined_diff) / _tolerance) * -1

if combined_diff > 0:
return ret
return ret * -1
return combined_ret


def get_temp_trend_offset(do_calc: bool, temp_diff_offset: float, predicted_temp: float, adjusted_temp: float) -> float:
Expand Down

0 comments on commit 708a24f

Please sign in to comment.