Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/control/chargepoint/chargepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,19 +357,19 @@ def _is_phase_switch_required(self) -> bool:
phase_switch_required = False
# Manche EVs brauchen nach der Umschaltung mehrere Zyklen, bis sie mit den drei Phasen laden. Dann darf
# nicht zwischendurch eine neue Umschaltung getriggert werden.
if ((self.data.control_parameter.state == ChargepointState.PHASE_SWITCH_AWAITED or
if ((((self.data.control_parameter.state == ChargepointState.PHASE_SWITCH_AWAITED or
self.data.control_parameter.state == ChargepointState.SWITCH_OFF_DELAY) and
# Nach Ablauf der Laden aktiv halten Zeit, sollte mit der vorgegebenen Phasenzahl geladen werden.
(self.check_deviating_contactor_states(self.data.set.phases_to_use, self.data.get.phases_in_use) or
# Nach Ablauf der Laden aktiv halten Zeit, sollte mit der vorgegebenen Phasenzahl geladen werden.
self.check_deviating_contactor_states(self.data.set.phases_to_use, self.data.get.phases_in_use)) or
# Vorgegebene Phasenzahl hat sich geändert
self.check_deviating_contactor_states(self.data.set.phases_to_use,
self.data.control_parameter.phases) and
self.data.control_parameter.phases)) and
# Wenn ein Soll-Strom vorgegeben ist, muss das Auto auch laden, damit umgeschaltet wird, sonst
# wird zB bei automatischer Umschaltung ständig versucht auf 1 Phase zurück zu schalten, wenn
# das Auto bei 3 Phasen voll ist.
((self.data.set.current != 0 and self.data.get.charge_state) or
(self.data.set.current != 0 and self.data.set.current_prev == 0) or
self.data.set.current == 0))):
((self.data.set.current != 0 and self.data.get.charge_state) or
(self.data.set.current != 0 and self.data.set.current_prev == 0) or
self.data.set.current == 0)):
phase_switch_required = True
if (self.data.control_parameter.state == ChargepointState.NO_CHARGING_ALLOWED and
(self.check_deviating_contactor_states(self.data.set.phases_to_use, self.data.get.phases_in_use) or
Expand Down
2 changes: 1 addition & 1 deletion packages/control/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ChargemodeConfig:
"topic": "chargemode_config/phase_switch_delay"})
pv_charging: PvCharging = field(default_factory=pv_charging_factory)
retry_failed_phase_switches: bool = field(
default=True,
default=False,
metadata={"topic": "chargemode_config/retry_failed_phase_switches"})
scheduled_charging: ScheduledCharging = field(default_factory=scheduled_charging_factory)
time_charging: TimeCharging = field(default_factory=time_charging_factory)
Expand Down
18 changes: 14 additions & 4 deletions packages/modules/vehicles/bmwbc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def init_store():
store['refresh_token'] = None
store['access_token'] = None
store['expires_at'] = None
if 'captcha_token' not in store:
store['captcha_token'] = None
store['gcid'] = None
store['session_id'] = None
store['captcha_token'] = None
return store


Expand Down Expand Up @@ -82,7 +83,7 @@ async def _fetch_soc(user_id: str, password: str, vin: str, captcha_token: str,
log.error("init: dataPath creation failed, dataPath: " +
str(DATA_PATH) + ", error=" + str(e))
store = init_store()
return store
return 0, 0.0
storeFile = str(DATA_PATH) + '/soc_bmwbc_vh_' + str(vnum) + '.json'

try:
Expand All @@ -104,6 +105,8 @@ async def _fetch_soc(user_id: str, password: str, vin: str, captcha_token: str,
store['expires_at'] = None
store['access_token'] = None
store['refresh_token'] = None
store['session_id'] = None
store['gcid'] = None
else:
log.info("captcha token unchanged")

Expand All @@ -124,6 +127,11 @@ async def _fetch_soc(user_id: str, password: str, vin: str, captcha_token: str,
Regions.REST_OF_WORLD,
hcaptcha_token=captcha_token)

if store['session_id'] is not None:
auth.session_id = store['session_id']
if store['gcid'] is not None:
auth.gcid = store['gcid']

clconf = MyBMWClientConfiguration(auth)
# account = MyBMWAccount(user_id, password, Regions.REST_OF_WORLD, config=clconf)
# user, password and region already set in BMWAuthentication/ClientConfiguration!
Expand Down Expand Up @@ -154,10 +162,12 @@ async def _fetch_soc(user_id: str, password: str, vin: str, captcha_token: str,

# store token and expires_at if changed
expires_at = datetime.datetime.isoformat(auth.expires_at)
if store['expires_at'] != expires_at:
if store['expires_at'] != expires_at or store['session_id'] != auth.session_id:
store['refresh_token'] = auth.refresh_token
store['access_token'] = auth.access_token
store['captcha_token'] = captcha_token
store['session_id'] = auth.session_id
store['gcid'] = auth.gcid
store['expires_at'] = datetime.datetime.isoformat(auth.expires_at)
write_store(store)

Expand Down
2 changes: 1 addition & 1 deletion packages/modules/vehicles/bmwbc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self,

class BMWbc:
def __init__(self,
name: str = "BMW (Bimmer)",
name: str = "BMW & Mini ",
type: str = "bmwbc",
configuration: BMWbcConfiguration = None) -> None:
self.name = name
Expand Down
10 changes: 10 additions & 0 deletions web/display/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
document.getElementById("log").classList.toggle("hide");
});
});

// schedule a window reload at 15 minutes past midnight
let now = new Date();
let reloadTime = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 2, 0, 15, 0, 0);
var millisecondsTillReload = reloadTime - now;
console.log("Current time: " + now);
console.log("Scheduled reload at " + reloadTime.toString() + " in " + millisecondsTillReload + "ms");
window.setTimeout(() => {
window.location.reload();
}, millisecondsTillReload);
</script>
</head>

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading