Repository navigation
Wire Apply button to buem-gateway for a live demo run - #97
Merged
Merged
Conversation
Clicking Apply now builds a BUEM GeoJSON feature from the current building state and POSTs it to buem-gateway's single-building endpoint (POST /buem/building), then feeds the real load profile and thermal summary back into the load profile chart and energy totals — replacing the static placeholder numbers with a real BuEM physics run. Also adds the X-Api-Key header ignisApi.ts's calls were missing, needed now that ignis sits behind Caddy with API-key auth for this demo stack. This is demo-only wiring, not the target architecture: in the real system Building Configurator only collects data, which flows through the EnerPlanET backend and an orchestration layer that dispatches to BuEM — not a direct frontend-to-service call like this one. Kept here to showcase Building Configurator + ignis + BuEM + Docker working together ahead of that layer existing (see buem-gateway's decision note on this). Verified live in-browser: Apply triggers a real ~8760-point hourly BuEM run, the monthly chart and CSV download reflect the real values, and ignis's live thermal-efficiency recalculation on parameter change still works.
Contributor
There was a problem hiding this comment.
Pull request overview
Wires the Building Configurator “Apply” flow to run a live BuEM simulation via buem-gateway and display the returned load profile + thermal summary in the existing UI, while also updating ignis API calls to include API-key auth headers for the demo stack.
Changes:
- Add a new
buemApi.tsclient that callsPOST /buem/buildingand adapts the response into the app’sLoadDataPoint+ thermal summary shapes. - Update
BuildingConfigurator.tsxso Apply triggers the live simulation, updates chart/totals state, and disables the button while running. - Add
X-Api-Keyheader wiring toignisApi.tsrequests (including POST) when configured via env.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/app/lib/ignisApi.ts |
Adds optional API-key auth headers to ignis fetch calls. |
src/app/lib/buemApi.ts |
Introduces a buem-gateway API client to run building simulations and adapt results for the UI. |
src/app/components/BuildingConfigurator/BuildingConfigurator.tsx |
Hooks “Apply” to the live BuEM run, prioritizes the live timeseries, and adds a running/disabled state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
+142
| ? ts.timestamps.map((timestamp, i) => ({ | ||
| timestamp, | ||
| heating: ts.heating[i] ?? 0, | ||
| electricity: ts.electricity[i] ?? 0, | ||
| // LoadDataPoint has no cooling field. Reusing "hotwater" for BuEM's | ||
| // cooling output matches the existing thermalSummary-based fallback | ||
| // in BuildingConfigurator.tsx's computeEnergyTotals — not a | ||
| // physically accurate label, but the established convention. | ||
| hotwater: ts.cooling?.[i] ?? 0, | ||
| })) |
Comment on lines
+319
to
324
| // Hourly timeseries from the most recent live buem-gateway run this session — takes | ||
| // priority over whatever timeseries the buildingData prop originally carried. | ||
| const [modelTimeseries, setModelTimeseries] = useState<LoadDataPoint[] | null>(null); | ||
| const [isRunningSimulation, setIsRunningSimulation] = useState(false); | ||
|
|
||
| const fileInputRef = useRef<HTMLInputElement>(null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /buem/buildingendpoint and feeds the result (load profile + thermal summary) into the existing chart/totals UI, replacing the static placeholder numbers.src/app/lib/buemApi.ts, following the same pattern as the existingignisApi.ts.ignisApi.tscalls to send theX-Api-Keyheader — needed now that ignis sits behind Caddy with API-key auth in the demo stack.This is demo-only wiring, not the target architecture. In the real system, Building Configurator only collects data; it flows through the EnerPlanET backend and an orchestration layer that dispatches to BuEM. This direct frontend→buem-gateway call exists solely to showcase Building Configurator + ignis + BuEM + Docker working together ahead of that orchestration layer existing.
Depends on enerplanet/buem-gateway#21 (a CORS bug found while testing this — without it, every request from a browser failed with
TypeError: Failed to fetcheven though buem-gateway responded 200).Test plan
npm run buildpasses