update calibration charge toggle button which can now stop automatic calibration charge and relevant file

This commit is contained in:
Yinyin Liu 2024-07-24 13:12:18 +02:00
parent 324e6f7688
commit 602470abc5
2 changed files with 24 additions and 21 deletions

View File

@ -15,8 +15,7 @@ MbPage {
property bool initialized: false
property VBusItem lastEoc: VBusItem { bind: "com.victronenergy.settings/Settings/Controller/LastEOC" }
property int previousEocValue: -1
property bool isCalibrationActive: false
property int previousEocValue: lastEoc.value
title: qsTr("Charging Strategy")
@ -28,6 +27,8 @@ MbPage {
id: controllerState
bind: "com.victronenergy.controller/State"
}
property bool isCalibrationActive: controllerState.value == 3 ? true : false
VBusItem {
id: systemType
@ -117,24 +118,24 @@ MbPage {
show: true
onClicked: {
console.log("Button clicked. Current controllerState: " + controllerState.value);
console.log("Button clicked. Current isCalibrationAction: " + isCalibrationActive);
console.log("Button clicked. Previous LastEOC: " + previousEocValue);
if (controllerState.value !== 3 && controllerState.value !== 11 && !isCalibrationActive) {
console.log("Starting calibration charge...");
if (previousEocValue === -1) {
previousEocValue = lastEoc.value;
console.log("Previous EOC Value saved: " + previousEocValue);
}
console.log("Starting manual calibration charge...");
previousEocValue = lastEoc.value;
console.log("Previous EOC Value saved: " + previousEocValue);
lastEoc.setValue(0);
console.log("Set lastEoc to 0");
isCalibrationActive = true;
} else if (controllerState.value === 3 && isCalibrationActive) {
console.log("Stopping calibration charge...");
if (previousEocValue !== -1) {
console.log("Stopping manual calibration charge...");
if(previousEocValue==0){
console.log("Postpone automatic calibration charge to 1 day later.");
lastEoc.setValue((new Date().getTime() - 24*60*60*1000)/1000);
}else{
lastEoc.setValue(previousEocValue);
console.log("Reverted lastEoc to previous value: " + previousEocValue);
previousEocValue = -1;
} else {
console.warn("No previous EOC value recorded.");
}
isCalibrationActive = false;
} else {
@ -150,7 +151,7 @@ MbPage {
if (lastEoc.value !== 0 && isCalibrationActive) {
console.log("Calibration charge completed, resetting button to 'Press here'.");
isCalibrationActive = false;
previousEocValue = -1;
previousEocValue = lastEoc.value;
eoctime.value = qsTr("Press here");
}
}

View File

@ -42,6 +42,10 @@ async def resize(remote_host):
command = "sh /opt/victronenergy/swupdate-scripts/resize2fs.sh"
return await run_remote_command(remote_host, command)
async def reboot(remote_host):
command = "reboot"
return await run_remote_command(remote_host, command)
async def upload_files(remote_host):
file_location_mappings = {
"rc.local": "/data/",
@ -107,15 +111,13 @@ async def main(remote_host):
#### 4. resize /dev/root #####
print("Resize /dev/root now!")
print(await resize(remote_host))
# ##### 5. stop battery service ######
# print("Stop battery service!")
# print(await stop_battery_service(remote_host))
##### 6. run rc.local ######
print("Run rc.local to set password, timezone and cp battery folder!")
# ##### 5. run rc.local ######
# print("Run rc.local to set password, timezone and cp battery folder!")
# print(await run_rclocal(remote_host))
##### 5. reboot to run rc.local and update qml ######
print("Reboot!")
print(await run_rclocal(remote_host))
# ##### 7. start battery service ######
# print("Start battery service!")
# print(await start_battery_service(remote_host))
else:
sys.exit("It's not Venus GX!")