allow parsing config with missing keys, added nightlamp config stuff, added nightlamp testing,
This commit is contained in:
@@ -25,9 +25,16 @@ interface FileInfo{
|
||||
}
|
||||
|
||||
interface NightLampConfig {
|
||||
enabled: boolean,
|
||||
night_lamp_hour_start: number,
|
||||
night_lamp_hour_end: number,
|
||||
night_lamp_only_when_dark: boolean,
|
||||
low_soc_cutoff: number,
|
||||
low_soc_restore: number
|
||||
}
|
||||
|
||||
interface NightLampCommand {
|
||||
active: boolean
|
||||
}
|
||||
|
||||
interface TankConfig {
|
||||
|
@@ -225,7 +225,16 @@ export class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testNightLamp(active: boolean){
|
||||
var body: NightLampCommand = {
|
||||
active: active
|
||||
}
|
||||
var pretty = JSON.stringify(body, undefined, 1);
|
||||
fetch(PUBLIC_URL + "/lamptest", {
|
||||
method: "POST",
|
||||
body: pretty
|
||||
})
|
||||
}
|
||||
|
||||
testPlant(plantId: number) {
|
||||
let counter = 0
|
||||
@@ -349,11 +358,19 @@ export class Controller {
|
||||
waitForReboot() {
|
||||
console.log("Check if controller online again")
|
||||
fetch(PUBLIC_URL + "/version", {
|
||||
method: "POST",
|
||||
method: "GET",
|
||||
signal: AbortSignal.timeout(5000)
|
||||
}).then(response => {
|
||||
console.log("Reached controller, reloading")
|
||||
window.location.reload();
|
||||
if (response.status != 200){
|
||||
console.log("Not reached yet, retrying")
|
||||
setTimeout(controller.waitForReboot, 1000)
|
||||
} else {
|
||||
console.log("Reached controller, reloading")
|
||||
controller.progressview.addIndeterminate("rebooting", "Reached Controller, reloading")
|
||||
setTimeout(function(){
|
||||
window.location.reload()
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("Not reached yet, retrying")
|
||||
|
@@ -16,9 +16,13 @@
|
||||
</style>
|
||||
|
||||
<div class="subtitle">Light:</div>
|
||||
<div class="flexcontainer">
|
||||
<div class="lightkey">Test Nightlight</div>
|
||||
<input class="lightcheckbox" type="checkbox" id="night_lamp_test">
|
||||
</div>
|
||||
<div class="flexcontainer" style="text-decoration-line: line-through;">
|
||||
<div class="lightkey">Enable Nightlight</div>
|
||||
<input class="lightcheckbox" type="checkbox" id="night_lamp_enabled" checked="false">
|
||||
<input class="lightcheckbox" type="checkbox" id="night_lamp_enabled">
|
||||
</div>
|
||||
<div class="flexcontainer">
|
||||
<div class="lightkey">Light only when dark</div>
|
||||
@@ -33,4 +37,12 @@
|
||||
<div class="lightkey">Stop</div>
|
||||
<select class="lightnumberbox" type="time" id="night_lamp_time_end">
|
||||
</select>
|
||||
</div>
|
||||
<div class="flexcontainer">
|
||||
<div class="lightkey">Disable if Battery below %</div>
|
||||
<input class="lightcheckbox" type="number" id="night_lamp_soc_low" min="0" max="100">
|
||||
</div>
|
||||
<div class="flexcontainer">
|
||||
<div class="lightkey">Reenable if Battery higher %</div>
|
||||
<input class="lightcheckbox" type="number" id="night_lamp_soc_restore" min="0" max="100">
|
||||
</div>
|
@@ -4,12 +4,26 @@ export class NightLampView {
|
||||
private readonly night_lamp_only_when_dark: HTMLInputElement;
|
||||
private readonly night_lamp_time_start: HTMLSelectElement;
|
||||
private readonly night_lamp_time_end: HTMLSelectElement;
|
||||
private readonly night_lamp_test: HTMLInputElement;
|
||||
private readonly night_lamp_enabled: HTMLInputElement;
|
||||
private readonly night_lamp_soc_low: HTMLInputElement;
|
||||
private readonly night_lamp_soc_restore: HTMLInputElement;
|
||||
|
||||
constructor(controller:Controller){
|
||||
(document.getElementById("lightview") as HTMLElement).innerHTML = require('./nightlightview.html') as string;
|
||||
|
||||
|
||||
this.night_lamp_only_when_dark = document.getElementById("night_lamp_only_when_dark") as HTMLInputElement;
|
||||
this.night_lamp_only_when_dark.onchange = controller.configChanged
|
||||
|
||||
this.night_lamp_enabled = document.getElementById("night_lamp_enabled") as HTMLInputElement;
|
||||
this.night_lamp_enabled.onchange = controller.configChanged
|
||||
|
||||
this.night_lamp_soc_low = document.getElementById("night_lamp_soc_low") as HTMLInputElement;
|
||||
this.night_lamp_soc_low.onchange = controller.configChanged
|
||||
|
||||
this.night_lamp_soc_restore = document.getElementById("night_lamp_soc_restore") as HTMLInputElement;
|
||||
this.night_lamp_soc_restore.onchange = controller.configChanged
|
||||
|
||||
this.night_lamp_time_start = document.getElementById("night_lamp_time_start") as HTMLSelectElement;
|
||||
this.night_lamp_time_start.onchange = controller.configChanged
|
||||
for (let i = 0; i < 24; i++) {
|
||||
@@ -31,12 +45,21 @@ export class NightLampView {
|
||||
option.innerText = i.toString();
|
||||
this.night_lamp_time_end.appendChild(option);
|
||||
}
|
||||
|
||||
let night_lamp_test = document.getElementById("night_lamp_test") as HTMLInputElement;
|
||||
this.night_lamp_test = night_lamp_test
|
||||
this.night_lamp_test.onchange = () => {
|
||||
controller.testNightLamp(night_lamp_test.checked)
|
||||
}
|
||||
}
|
||||
|
||||
setConfig(nightLamp: NightLampConfig) {
|
||||
this.night_lamp_only_when_dark.checked = nightLamp.night_lamp_only_when_dark
|
||||
this.night_lamp_time_start.value = nightLamp.night_lamp_hour_start.toString();
|
||||
this.night_lamp_time_end.value = nightLamp.night_lamp_hour_end.toString();
|
||||
this.night_lamp_enabled.checked = nightLamp.enabled;
|
||||
this.night_lamp_soc_low.value = nightLamp.low_soc_cutoff.toString();
|
||||
this.night_lamp_soc_restore.value = nightLamp.low_soc_restore.toString();
|
||||
}
|
||||
|
||||
getConfig(): NightLampConfig {
|
||||
@@ -44,6 +67,9 @@ export class NightLampView {
|
||||
night_lamp_hour_start: +this.night_lamp_time_start.value,
|
||||
night_lamp_hour_end: +this.night_lamp_time_end.value,
|
||||
night_lamp_only_when_dark: this.night_lamp_only_when_dark.checked,
|
||||
enabled: this.night_lamp_enabled.checked,
|
||||
low_soc_cutoff: +this.night_lamp_soc_low.value,
|
||||
low_soc_restore: +this.night_lamp_soc_restore.value
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@
|
||||
<div class="flexcontainer">
|
||||
<div class="subtitle">Tank:</div>
|
||||
</div>
|
||||
<div class="flexcontainer" style="text-decoration-line: line-through;">
|
||||
<div class="flexcontainer">
|
||||
<span class="tankkey">Enable Tank Sensor</span>
|
||||
<input class="tankcheckbox" type="checkbox" id="tank_sensor_enabled">
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user