-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/structure' into develop
# Conflicts: # custom_components/peaqev/peaqservice/chargecontroller/ichargecontroller.py # custom_components/peaqev/peaqservice/charger/charger.py # custom_components/peaqev/peaqservice/hub/nordpool/nordpool.py
- Loading branch information
Showing
50 changed files
with
1,335 additions
and
1,076 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 20 additions & 21 deletions
41
custom_components/peaqev/peaqservice/chargecontroller/chargecontroller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
custom_components/peaqev/peaqservice/chargecontroller/chargecontroller_helpers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from datetime import datetime, timedelta | ||
|
||
|
||
def defer_start(non_hours: list) -> bool: | ||
"""Defer starting if next hour is a non-hour and minute is 50 or greater, to avoid short running times.""" | ||
if (datetime.now() + timedelta(hours=1)).hour in non_hours: | ||
return datetime.now().minute >= 50 | ||
return False | ||
|
||
|
||
def calculate_stop_len(nonhours) -> str: | ||
ret = "" | ||
for idx, h in enumerate(nonhours): | ||
if idx + 1 < len(nonhours): | ||
if _getuneven(nonhours[idx + 1], nonhours[idx]): | ||
ret = _get_stopped_string(h) | ||
break | ||
elif idx + 1 == len(nonhours): | ||
ret = _get_stopped_string(h) | ||
break | ||
return ret | ||
|
||
|
||
def _get_stopped_string(h) -> str: | ||
val = h + 1 if h + 1 < 24 else h + 1 - 24 | ||
if len(str(val)) == 1: | ||
return f"Charging stopped until 0{val}:00" | ||
return f"Charging stopped until {val}:00" | ||
|
||
|
||
def _getuneven(first, second) -> bool: | ||
if second > first: | ||
return first - (second - 24) != 1 | ||
return first - second != 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.