Skip to content

Commit

Permalink
Fix charge end logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Feb 14, 2024
1 parent 2863020 commit 6b38cc7
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions custom_components/ohme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ def _sanitise_points(points):
return output


def _charge_finished(data):
"""Is the charge finished?"""
now = int(time())
data = [x['y'] for x in data if x["t"] > now]

if len(data) == 0 or min(data) == max(data):
return True
return False


def _next_slot(data, live=False, in_progress=False):
"""Get the next slot. live is whether or not we may start mid charge. Eg: For the next slot end sensor, we dont have the
start but still want the end of the in progress session, but for the slot list sensor we only want slots that have
Expand Down Expand Up @@ -117,7 +107,7 @@ def charge_graph_slot_list(charge_start, points, skip_format=False):
data = points if skip_format else _format_charge_graph(charge_start, points)

# Don't return any slots if charge is over
if _charge_finished(data):
if charge_graph_next_slot(charge_start, points)['end'] is None:
return []

data = _sanitise_points(data)
Expand Down

0 comments on commit 6b38cc7

Please sign in to comment.