add ability to override frequency per plant and adjust timezone, fix missing workhour for plants

This commit is contained in:
2025-05-06 22:33:33 +02:00
parent f8274ea7a8
commit 5fe1dc8f40
10 changed files with 257 additions and 94 deletions

View File

@@ -1,4 +1,3 @@
const PLANT_COUNT = 8;
@@ -43,6 +42,8 @@ export class PlantViews {
}
export class PlantView {
private readonly moistureSensorMinFrequency: HTMLInputElement;
private readonly moistureSensorMaxFrequency: HTMLInputElement;
private readonly plantId: number;
private readonly plantDiv: HTMLDivElement;
private readonly header: HTMLElement;
@@ -136,6 +137,19 @@ export class PlantView {
this.maxConsecutivePumpCount.onchange = function(){
controller.configChanged()
}
this.moistureSensorMinFrequency = document.getElementById("plant_"+plantId+"_min_frequency") as HTMLInputElement;
this.moistureSensorMinFrequency.onchange = function(){
controller.configChanged()
}
this.moistureSensorMinFrequency.onchange = () => {
controller.configChanged();
};
this.moistureSensorMaxFrequency = document.getElementById("plant_"+plantId+"_max_frequency") as HTMLInputElement;
this.moistureSensorMaxFrequency.onchange = () => {
controller.configChanged();
};
}
update(a: number, b: number) {
@@ -159,23 +173,31 @@ export class PlantView {
this.pumpCooldown.value = plantConfig.pump_cooldown_min.toString();
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
this.sensorBInstalled.checked = plantConfig.sensor_b
this.sensorBInstalled.checked = plantConfig.sensor_b;
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
// Set new fields
this.moistureSensorMinFrequency.value =
plantConfig.moisture_sensor_min_frequency?.toString() || "";
this.moistureSensorMaxFrequency.value =
plantConfig.moisture_sensor_max_frequency?.toString() || "";
}
getConfig() :PlantConfig {
const rv:PlantConfig = {
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
pump_hour_start: +this.pumpHourStart.value,
pump_hour_end: +this.pumpHourEnd.value,
sensor_b: this.sensorBInstalled.checked,
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber
}
return rv
}
getConfig(): PlantConfig {
const rv: PlantConfig = {
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
pump_hour_start: +this.pumpHourStart.value,
pump_hour_end: +this.pumpHourEnd.value,
sensor_b: this.sensorBInstalled.checked,
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || undefined,
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || undefined,
};
return rv;
}
setMoistureA(a: number) {
this.moistureA.innerText = String(a);