webfix for sensora enable, ina start

This commit is contained in:
2025-06-19 22:57:54 +02:00
parent 3a2e59874e
commit de54afce52
4 changed files with 27 additions and 2 deletions

View File

@@ -71,6 +71,10 @@
<input class="plantvalue" id="plant_${plantId}_max_frequency" type="number" min="1000" max="25000" >
</div>
<div class="flexcontainer">
<div class="plantkey">Sensor A installed:</div>
<input class="plantcheckbox" id="plant_${plantId}_sensor_a" type="checkbox">
</div>
<div class="flexcontainer">
<div class="plantkey">Sensor B installed:</div>
<input class="plantcheckbox" id="plant_${plantId}_sensor_b" type="checkbox">

View File

@@ -55,6 +55,7 @@ export class PlantView {
private readonly pumpCooldown: HTMLInputElement;
private readonly pumpHourStart: HTMLSelectElement;
private readonly pumpHourEnd: HTMLSelectElement;
private readonly sensorAInstalled: HTMLInputElement;
private readonly sensorBInstalled: HTMLInputElement;
private readonly mode: HTMLSelectElement;
private readonly moistureA: HTMLElement;
@@ -128,6 +129,11 @@ export class PlantView {
this.pumpHourEnd.appendChild(option);
}
this.sensorAInstalled = document.getElementById("plant_"+plantId+"_sensor_a") as HTMLInputElement;
this.sensorAInstalled.onchange = function(){
controller.configChanged()
}
this.sensorBInstalled = document.getElementById("plant_"+plantId+"_sensor_b") as HTMLInputElement;
this.sensorBInstalled.onchange = function(){
controller.configChanged()
@@ -165,6 +171,7 @@ export class PlantView {
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
this.sensorBInstalled.checked = plantConfig.sensor_b;
this.sensorAInstalled.checked = plantConfig.sensor_a;
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
// Set new fields
@@ -176,8 +183,6 @@ export class PlantView {
getConfig(): PlantConfig {
return {
// hardcoded for now
sensor_a: true,
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
@@ -185,6 +190,7 @@ export class PlantView {
pump_hour_start: +this.pumpHourStart.value,
pump_hour_end: +this.pumpHourEnd.value,
sensor_b: this.sensorBInstalled.checked,
sensor_a: this.sensorAInstalled.checked,
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || null,
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || null