Repository navigation
Conversation
The optimum is found first, with no cost on changing value. Each run of one value is then folded into a neighbour when that costs less than a share of what one slot at full output costs for every change it removes. Without it a price that wobbles by a couple of percent from slot to slot made the plan change value 74 times a day on a radiator house, each one a write to the device and a relay cycle; with it, 11, at about 0.4 % higher planned cost. A long preheat is still weighed as a whole, because the smoothing runs on the finished plan and not inside the search. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
Two rules the owner sets, beside PriceComfort. Both are off at zero and have no default: what a saving or a peak is worth depends on the contract, the house and the household. SavingsGate is the least a day's plans must save together before they are acted on. It was taken out in srcfl#2022 on the evidence that it never opened in the house that ran it. The log of that house shows otherwise once the plans are summed, as the limit is: it reached 5 kr on 15 and 16 November, partly on a room model that overstated what a preheat saves. The ADR's Open section now says so, and decision 9 stands unchanged until it is revisited. The gate counts a plan that leaves its band as saving nothing, scales a short horizon up to a day, and has a keep share so a saving near the limit does not open and close it every slot. A test holds the case that went wrong: three rooms that each save less than the limit and together save more. PeakRelief lets a zone's target down to the bottom of its band in the dearest hours of a sharp price peak: at least a minimum price, at least a factor times the lowest price of the window ahead, and at most so many hours of one peak. On a dear but flat day nothing is a peak. It moves the target only, never the band. Nothing calls either yet; the planner still only proposes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
heat.zones gives each zone its target and hard band, price comfort and peak relief; heat.savings the least saving worth acting on; heat.write whether a plan is sent to a device at all. A section that is left out changes nothing, write is off unless set, and a section that cannot be read one way is refused with the zone it names. Nothing reads it yet. The heatplan rules gain yaml tags so the file and /api/config spell them the same way. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
A heat service plans every zone in the heat section each quarter from its thermal twin, the stored total price and the weather forecast, applies the owner's price comfort and peak relief, and weighs every zone's saving together against the owner's least saving. GET /api/heat/plan shows the plan, what it would save a day and what was written. Nothing is written unless heat.write is on. Then a zone's setpoint control is held at the plan's first value through the same drivercontrol holds the API uses, so a planned value and an operator's hold share one lock and one expiry. A zone writes only while its twin is trusted, the least saving is reached and the site meter is fresh; otherwise the device is handed back to its own default. An operator's hold is neither overwritten nor released. A held value is renewed between plans before the device or the hold drops it, for controllers such as CTC's that reset a written register after five minutes. The heat section gains boundary (outdoor or a measured temperature, such as the room around a floor), source and heat_kw, all the owner's. Only direct electric setpoint zones are planned yet: a heat pump's efficiency and a curve offset's learned effect have nowhere to come from in this section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
A room sensor on an underfloor gateway is heated by a heat pump on another device, and the twin could not tell: it takes the sensor's own driver's power or the single other driver reporting one, and a site with more than one has none. heat.zones[].heat_input names "<driver>/<metric>" for the zone; the twin then learns against that and nothing else, and a silent named input is no input rather than a fallback to a pump the owner did not name. A sensor named in heat.zones is learned even when its driver declares no sensors. A changed source restarts the twin, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
…s effect source: heat_pump takes the owner's efficiency and heat curve (zero or absent fields take heatplan's starting point) and needs the outdoor forecast, which a heat pump's COP and flow temperature depend on. A zone whose declared control is a curve offset is planned through it with the owner's curve_effect, what one unit does to the zone and the flow, until a twin learns it; the device's own value is the control's declared default, else zero. heatplan.Source gains an exported Validate so the config can refuse a curve or an efficiency the planner would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
miravoss26
left a comment
There was a problem hiding this comment.
Builds on #2040 (first two commits are its, reviewed there). Adds the heat config section, heatrun service, GET /api/heat/plan and the write path through control holds. Shadow unless heat.write is on.
Partial review: this is ~2.9k diff lines and I read the API route, the holds writer, the config example, the changesets and heat_control.go closely. I did NOT read heatrun/service.go, thermal_twin.go or config/heat.go line by line.
GET /api/heat/planis registered asRead. It exposes plan, savings and written values, no secrets. Reasonable.HoldsWritergoes through the samedrivercontrol.Holdsas the operator endpoint, so one lock and one expiry. Good call.APIand heat control shareControlHoldsonly when it is set, otherwise the API builds its own. Worth a test that main.go always sets it when heat is enabled, or an operator hold and a planned write could race on two locks.- Security screen: no secrets, no new deps, no new network hosts. The write path is the one place that touches devices. It is gated on
heat.write, twin trust, the savings gate and meter freshness per the changeset. - CI green.
Needs a human decision before merge: this is the first path where Core writes setpoints from the planner. Someone who owns heat control should read service.go and confirm the hand-back-to-default behaviour on twin loss and meter staleness.
… of holds main.go is read to check that drivercontrol.New is called once and that the same holds go to heatrun.HoldsWriter and api.Deps.ControlHolds; the API builds its own holds when given none. A second test runs both ways over one set: each sees, and can release, the other's hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
miravoss26
left a comment
There was a problem hiding this comment.
Heat zone planning in shadow, writing only when heat.write is on (ADR 0012). Adds the heat config section + validation, heatplan, heatrun, thermal twin wiring, and GET /api/heat/plan. Builds on #2040, so I only looked at the post-#2040 part and skimmed.
- Security screen: nothing found in what I read. No new deps or network destinations; the new route is registered
Read, so it follows the existing read-auth path. Writes go through the shareddrivercontrol.Holds, so a planned value and an operator's hold take one lock and expire together. - Scope: this is ~2.6k lines. I read the API, config wiring, holds writer and the plan entry points, not the optimiser maths in
heatplan/comfort.goline by line, so I'm not vouching for the savings logic. - Question: with
heat.writeon, what happens when the twin stops being trusted mid-hold? The changeset says writes happen only while it is trusted; I'd want to see the release path (SendDefault) tested for that case.
Needs a human decision: a domain reviewer should look at the planner before this goes in, since it controls heating once heat.write is enabled. CI is green.
Drives the service through the real HoldsWriter and drivercontrol.Holds, so the release path is tested down to the registry's SendDefault, not only against the fake writer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On the question of what happens when the twin stops being trusted mid-hold, with
Tests:
The domain review of the planner is still open. |
miravoss26
left a comment
There was a problem hiding this comment.
Adds a heat config section and a heat planner (heatplan, heatrun, thermal twin), exposed read-only at GET /api/heat/plan. Nothing is written unless heat.write is on, and then only through the existing control holds, gated on a trusted twin, the least-saving rule and a fresh site meter. Stacked on #2040.
- Security screen: no secrets, no new dependencies, no new network destinations. New HTTP surface is the one read-only GET handler. Writes go through the existing hold path, so it inherits the existing auth.
- Shadow-by-default with no numeric defaults in config is the right shape for this.
- CI is green on the checks that ran.
- Needs a human decision: I did not verify the planner and comfort math or the twin-trust thresholds, and this is a 115 KB diff. A review of those from someone who knows the thermal model is worth more than mine. Also first two commits belong to #2040, so review those there.
My read: no security findings from a screen of the diff. Not a correctness sign-off on the planner.
|
Thanks for the test that runs the hand-back through the real holds writer. We have not reviewed the planner yet: |
The shadow plan was only in memory, so nothing showed whether its saving rested on a prediction the house bears out. Each tick now appends one line per zone to heat-shadow.jsonl in the data directory: the plan's and the left-alone baseline's prediction for the quarter starting, the horizon's saving and cost, and for the quarter that ended the forecast made for it, the zone's temperature at both ends, the heat input's energy integrated from 30 s samples and the share of the quarter those samples covered. In shadow the device runs itself, so the baseline is what the readings can confirm. heatplan.Plan keeps the baseline's slots for that. A forecast is compared only with the quarter it was made for; after a gap it is left out. The file moves to .1 at 32 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A twin that found its heat on its own records the bare driver as its source. An owner who then wrote the same source as heat_input, "<driver>/hp_power_w", gave a different string, and the twin restarted and threw away what it had learned. Caught on the home box before it happened: three floor twins with a week of samples each. A named input that is a driver's own heat power is now recorded as the bare driver, so the two spellings are one source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sample taken a few seconds after the boundary counted toward the slot that ended, so a fully covered quarter read 1.0000005 on the home box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The baseline in the shadow log only holds while the device runs itself. On the home box another controller runs the floors, and with heat.write on the plan runs them, so the baseline is never what happens. The log now gives each quarter the temperature the planner's model, as it stood at the quarter's start, reaches with the heat actually measured, beside the reading. That tests the model FTW plans with under any control. Each quarter also gets its electricity and its cost at the quarter's price. For direct electric heat the electricity is the heat input; for a heat pump, whose input is its space heat, it is the pump's hp_power_w, hot water included, since the driver does not split the draw. Neither a model temperature nor a cost is given for a quarter covered less than 90 % by fresh samples. A test sets the measured heat to the plan's and checks the model temperature is the plan's own, so the log and the planner cannot drift apart; it fails with a different inertia. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first plan after Core starts runs a minute into its quarter, so the start temperature was read then while the model ran the whole quarter. The model temperature now runs from when the start temperature was read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miravoss26
left a comment
There was a problem hiding this comment.
Adds a heat config section and a heatrun service that plans the owner's heat zones every quarter, with GET /api/heat/plan to view it. It only writes when heat.write is on, through the same drivercontrol.Holds the API uses. It also adds heat_input for the thermal twin and heat pump zones.
I built the branch (go build ./... clean) and the heatrun, heatplan, config, thermaltwin and drivercontrol tests pass. I did not run cmd/ftw. The write path matches the description: it needs a trusted twin, an open savings gate and a fresh site meter, and it doesn't overwrite or release an operator's hold.
Findings
- Low, shadowlog.go:256:
zp.StartC != 0treats a real 0.0 °C reading as missing for unplanned zones. Log only. - Low, shadowlog.go:214: a NaN reading makes JSON encoding fail and drops that tick's records. Logged once, nothing else breaks.
- Low, PR body: it says four commits after #2040, but there are twelve (shadow log, model test, late-slot fix and others). Worth updating so reviewers know the scope.
- Info:
make verifywasn't run, and 7cmd/ftwidentity tests fail on your Pi because of file mode. I read them as unrelated, but CI should confirm.
Security screen: no secrets, no new dependencies or hosts. The new route is Read-level like /api/thermal/twins, and heat.write goes through the existing config authz.
Safe to merge from my read once #2040 lands and the owner approves the minor changeset.
A NaN reading made JSON encoding fail and dropped every zone's record for that tick. Append now leaves out only the record it cannot encode and reports it. An unplanned zone's sensor reading is also checked for NaN before it is logged. The start temperature of an unplanned zone is now taken from the planned flag alone. The old check already read the sensor again for a 0.0 °C start, so that log was right; the test now pins it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miravoss26
left a comment
There was a problem hiding this comment.
Adds a shadow heat-zone planner (heatrun service, config heat:, GET /api/heat/plan) plus owner comfort rules. Everything is shadow by default; write: false sends nothing. ~3.9k diff lines, CI green.
- Security: new route
GET /api/heat/planisRead-scoped, matches the neighbouring thermal route. No new dependencies or network hosts. Shareddrivercontrol.Holdsbetween Core and the API is a sensible way to avoid two locks. - Needs a human decision: when
write: trueis enabled, the plan starts controlling heat drivers. Validation covers 'write needs control' but I read only the diff skim, not the full control path inheatrun/service.go(694 lines). Someone who knows the drivers should read that file before write is turned on anywhere. - Mergeable state shows UNKNOWN, so recheck for conflicts.
Shadow part looks safe to me; the write path needs a human read.
What
Heat zones can be planned by Core, in shadow unless the owner turns writing on (docs/adr/0012).
heatconfig section (go/internal/config/heat.go). Each zone names its sensor, control, boundary (outdooror a measured temperature, such as the room around a floor), source, heat output, target and hard band, plus the owner'sprice_comfortandpeak_relief.heat.savingsis the least saving a day's plans must reach together. No number has a default; a section left out changes nothing; a section that cannot be read one way is refused, naming the zone.heatrunservice. Every quarter it plans each zone from its thermal twin, the stored total price and the weather forecast, applies the owner's rules, and weighs every zone's saving together against the least saving.GET /api/heat/planshows the plan, the saving per day and what was written.heat.write). A zone's control is held at the plan's first value through the samedrivercontrol.Holdsthe API uses.mainnow creates one set of holds and passes it to both, so a planned value and an operator's hold share one lock and one expiry. A zone writes only while its twin is trusted, the least saving is reached, the site meter is fresh, and no one else holds the driver; otherwise the device goes back to its own default. An operator's hold is neither overwritten nor released. A held value is renewed between plans before the hold or the device drops it (CTC resets its BMS registers five minutes after the last write).heat_inputper zone for the twin. A room sensor on one device (an underfloor gateway) is heated by another (a heat pump). The twin used to take the sensor's own driver's power or the single other driver reporting one, so a site with several had none. A zone can now name"<driver>/<metric>", and the twin learns against that and nothing else. A sensor named inheat.zonesis learned even if its driver declares no sensors.source: heat_pumptakes the owner's efficiency and heat curve; zero fields take heatplan's starting point. A heat pump zone needs the outdoor forecast. A zone whose declared control is acurve_offsetis planned through it with the owner'scurve_effectuntil a twin learns it.heatplan.Sourcegains an exportedValidate.heatrun/shadowlog.go,<data dir>/heat-shadow.jsonl, rotated at 32 MB). At every quarter boundary each zone gets one JSON line: what the plan says for the quarter starting now (plan and baseline temperature, kWh and cost) and how the quarter that just ended came out. The measured outcome has the start and end temperature, heat input in kWh and its coverage, electricity drawn and its cost at the stored price, andmodel_end_c. That field is the planner's model run on the heat that actually went in, so the model is tested whoever controls the zone. A heat pump zone is costed on its electrical draw, not its heat. A forecast is compared only for the very quarter it was made for, and a thinly covered quarter is not judged. A record that cannot be encoded is left out and reported, and the other zones are still written.Why
This is the house that runs the planner's first version locally (a Python controller over a Wiser hub): three electric floors, and a CTC EcoZenith i255 with an EcoAir 610M feeding LK underfloor loops. Moving that control into Core needs exactly this: the owner's numbers in config, a plan visible before anything is written, writes through Core's holds, and a way to tie LK's room sensors to the CTC's heat.
Evidence
go build ./...andgo vetare clean for the touched packages.heatrun,heatplan,config,thermaltwin,apianddrivercontrol, and incmd/ftwfor the twin zones. On the Raspberry Pi I built on, 7cmd/ftwidentity tests fail withkey directory mode 0775. They pass withumask 022and are unrelated.heatruntests cover:make verifywas not run.Not in this PR
go/cmd/ftw/main.gois also touched by #1956, #1865, #1789, #1691 and #1364. The change here is three contained blocks: the shared holds, the heat service, and the catalog/twin reload line.The changeset is
minor, a visible new capability, so it needs the owner's approval.🤖 Generated with Claude Code