Skip to content

Commit

Permalink
#28
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuselden authored and magnuselden committed Sep 14, 2023
1 parent 00d76a0 commit 1e6a3bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions custom_components/peaqnext/sensors/next_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,18 @@ def _make_hours_display(self, model: HourModel) -> str:
return ""
if self._relative_time:
differ = model.dt_start
prefix = "start "
prefix = "Start "
if self._calculate_by == CalculateBy.ENDTIME:
differ = model.dt_end
prefix = "end "
hour_diff = int((datetime.now() - differ).total_seconds()/3600)
prefix = "End "
hour_diff = int((differ - datetime.now()).total_seconds()/3600)
minute_diff = int((differ - datetime.now()).total_seconds()/60)
if hour_diff == 0:
return f"{prefix}now"
return f"{prefix}{hour_diff}h"
if minute_diff == 0:
return f"{prefix}now -"
else:
return f"{prefix}in {minute_diff}m -"
return f"{prefix}in {hour_diff}h -"
else:
tomorrow1: str = self._get_tomorrow_assignation(model.dt_start.day > datetime.now().day)
tomorrow2: str = self._get_tomorrow_assignation(model.dt_end.day > datetime.now().day)
Expand Down

0 comments on commit 1e6a3bb

Please sign in to comment.