From e7824dc29739b38137dae323798dca998a16aabd Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 30 Jun 2026 19:53:54 +0200 Subject: [PATCH] ui: show water level and status line before any sud is loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pot config (water_mass, volumen) sent in System message at startup. app.js stores potConfig and uses it in updatePotVisualization/ updateStatusLine when sudEmpty, showing startup fill level and "No schedule – N L water" without requiring a sud to be loaded first. Co-Authored-By: Claude Sonnet 4.6 --- config-real.json.tpl | 4 +++- config-sim.json.tpl | 4 +++- server/brewpi.py | 3 ++- web/app.js | 26 +++++++++++++++++++++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/config-real.json.tpl b/config-real.json.tpl index d1a161d..07c48ec 100644 --- a/config-real.json.tpl +++ b/config-real.json.tpl @@ -48,6 +48,8 @@ "mass": 5.96, "material": "Edelstahl 18/10", "L": 0.2, - "Td": 17 + "Td": 17, + "water_mass": 22, + "volumen": 30 } } diff --git a/config-sim.json.tpl b/config-sim.json.tpl index 8bd8421..f86299a 100644 --- a/config-sim.json.tpl +++ b/config-sim.json.tpl @@ -47,6 +47,8 @@ "mass": 5.96, "material": "Edelstahl 18/10", "L": 0.2, - "Td": 17 + "Td": 17, + "water_mass": 22, + "volumen": 30 } } diff --git a/server/brewpi.py b/server/brewpi.py index 40e9362..32f36e4 100755 --- a/server/brewpi.py +++ b/server/brewpi.py @@ -164,7 +164,8 @@ if __name__ == '__main__': msg_system = dispatcher.msgio_get("System") async def send_system_info(): - await msg_system.send({'AmbientTemp': theta_amb, 'WarpFactor': DT / DT_TASK, 'PlantSim': plant_sim}) + await msg_system.send({'AmbientTemp': theta_amb, 'WarpFactor': DT / DT_TASK, 'PlantSim': plant_sim, + 'Pot': config.get('Pot', {})}) asyncio.ensure_future(send_system_info()) async def on_system_recv(data): diff --git a/web/app.js b/web/app.js index 96da869..61ebfd8 100644 --- a/web/app.js +++ b/web/app.js @@ -41,6 +41,10 @@ let heaterMaxPower = 100; // Only switchable when not running; auto-reset to true on play. let closedLoop = true; +// Pot hardware config from server's Pot section - used for display before +// any sud is loaded (startup water level, status line). +let potConfig = {}; + // Sud state - mirrors the sud_* fields on client/brewpi_gui.py's Window. let sudSchedule = []; let sudName = ''; @@ -420,7 +424,11 @@ function updatePotVisualization() { const levelTickEl = document.getElementById('level-tick'); const levelLabelEl = document.getElementById('level-label'); - if (sudEmpty || sudVolumen <= 0) { + const volumen = sudEmpty ? (potConfig.volumen || 0) : sudVolumen; + const grainMass = sudEmpty ? 0 : currentStepGrainMass(); + const waterMass = sudEmpty ? (potConfig.water_mass || 0) : currentStepWaterMass(); + + if (volumen <= 0) { waterFillEl.setAttribute('height', '0'); waterWaveEl.setAttribute('d', ''); if (waterClipRect) waterClipRect.setAttribute('height', '0'); @@ -430,9 +438,8 @@ function updatePotVisualization() { return; } - const grainMass = currentStepGrainMass(); - const utilizedVolume = currentStepWaterMass() + grainMass * 0.7; - const fillFraction = Math.min(1, Math.max(0, utilizedVolume / sudVolumen)); + const utilizedVolume = waterMass + grainMass * 0.7; + const fillFraction = Math.min(1, Math.max(0, utilizedVolume / volumen)); const waterH = fillFraction * potInnerH; const waterTop = potInnerBottom - waterH; waterFillEl.setAttribute('y', waterTop.toFixed(1)); @@ -462,7 +469,8 @@ function updatePotVisualization() { function updateStatusLine() { const el = document.getElementById('sud-status-line'); if (sudSchedule.length === 0) { - el.textContent = ''; + const w = potConfig.water_mass || 0; + el.textContent = w > 0 ? `No schedule – ${w} L water` : ''; return; } let text = ''; @@ -776,6 +784,13 @@ function onSystemChanged(msg) { if ('PlantSim' in msg) { document.getElementById('pot-reset-row').classList.toggle('hidden', !msg.PlantSim); } + if ('Pot' in msg) { + potConfig = msg.Pot; + if (sudEmpty) { + updatePotVisualization(); + updateStatusLine(); + } + } } const HANDLERS = { @@ -820,6 +835,7 @@ function connect() { initialTempSollSync = true; initialPotTempSync = true; closedLoop = true; + potConfig = {}; setConnected(true); for (const channel of CHANNELS) { ws.send(JSON.stringify({'+': channel}));