github nicois/foxess-control v1.0.22

43 minutes ago

Consolidates the 1.0.22-beta.1 … beta.13 pre-releases. Headline: a read-only local gateway backend (foxess-local), the scheduler handback ("Release the inverter when idle" and disable_scheduler), a new backup action, schedule writes that work on H3, EVO and other models that rejected them with errno 40257, force_charge holding full power for its whole window, and per-string PV3/PV4 and PV-only energy sensors.

Added

  • New action foxess_control.backup: Backup mode for a set time (PR #29, thanks @giggles-38a). Solar still charges the battery, but the battery does not discharge to the house, so the house runs on solar and the grid. Useful for free or cheap grid-power windows (issue #32). It takes a duration, an optional start_time and replace_conflicts, like feedin, and the inverter returns to self-use when the window ends.
  • Schedules can be written to inverters that only accept the v1 API, such as the EVO 10-5H (issue #28). These inverters refused every schedule change with "FoxESS API error 40257", so no action or smart session worked. By default the integration still writes via v0, the API every other reported model uses. If the inverter refuses that with 40257, it retries once via v1 and keeps using v1 from then on. A new Schedule write API option (Auto / v0 / v1) lets you pin a version: choose v1 for an EVO to skip the failed v0 attempt after each restart. The diagnostics download shows the version in use. Thanks to @prgarnett for testing both endpoints and posting the requests that worked.
  • Switch an existing entry between FoxESS Cloud and the local gateway without losing anything. Until now, trying foxess-local meant deleting the cloud entry and adding a new one, which threw away every entity's history and broke the dashboards, automations and helpers that referred to them. Reconfigure now offers Local gateway (foxess-local) and FoxESS Cloud (API key), and switches the same entry in place: entity ids, history, the Energy dashboard and all options carry on unchanged. The other backend's credentials are kept, so switching back needs nothing re-typed. A gateway that reports a different inverter is refused, and so is a switch while a smart session is running (its schedule group could not be recovered or removed by the other backend). A local entry's Reconfigure also changes its gateway URL or token; the token field is masked and pre-filled, and clearing it removes the token.
  • Local gateway backend (read-only): run FoxESS Control from a foxess-local gateway instead of the FoxESS Cloud. foxess-local owns the inverter's connection on your own network and serves a local API. Choose Local gateway in the initial setup and give the gateway's URL and an access token. The integration then reads everything from the gateway: no cloud account, no Open API rate limits, and live power and SoC about every 5 seconds over the gateway's event stream. The stream stays connected for the life of the entry, because on the LAN it costs nothing, so it has none of the cloud WebSocket's on/off gating. Lifetime energy sensors come from the inverter's own counters via the gateway, so they match the FoxESS app. The gateway's battery capacity pre-fills the Battery Capacity option. This first release is sensors only: every action refuses with an explanation rather than failing obscurely. Local control (schedule writes, smart sessions, the scheduler handback, pacing against the gateway's write budget) is the next phase. Refs D-064, D-065.
  • The local backend tells you when it has lost the inverter. If the gateway reports the inverter offline, or its event stream goes silent for 20 seconds (a half-open connection would otherwise freeze the last values on screen while still looking connected), the data stops being presented as live. If the gateway itself is unreachable or refuses the token, the entities go unavailable rather than showing old numbers. Data Freshness reads local, and the cards show a Local badge that turns stale after 3 minutes, which is three missed /state polls. Refs C-020, C-026.
  • Diagnostics gain a local_gateway section for local entries: stream health and last error, inverter liveness, and a live read of the gateway's version, identity, write support, forward mode, write budget, energy-counter sources and inverter clock offset. It also compares the gateway's time zone with Home Assistant's; a mismatch would shift every schedule window once local control exists. The gateway token and the inverter serial are redacted. Refs C-020.
  • An inverter that cannot release Mode Scheduler control now says so, instead of doing nothing forever (issue #17). Reported on an H3-12.0-E running 1.0.22-beta.6: Could not turn the Mode Scheduler master switch on via /op/v0/device/scheduler/set on inverter H3-12.0-E; writing the schedule anyway. requests.exceptions.HTTPError: 404 Client Error: Not Found. That endpoint is the only API call that can turn the master switch off, so scheduler handback can never work on that hardware — and until now a user could switch the option on, watch nothing happen at the end of every session for the rest of the install's life, and find the explanation only by downloading a diagnostics file and reading last_handback. Which is exactly the failure C-020 exists to prevent. Three things changed. A Repair issue now appears (Settings → System → Repairs) naming the model and the endpoint, so it reads as the continuation of the warning already in the user's log; it is the shape Repairs are for — you asked for something your hardware cannot do, it will never start working by itself, and there is one useful action, which is turning the option back off. It is raised only when the option is on, because nobody who never asked for handback should be told their inverter cannot do it, and it is withdrawn when the option goes off, when the endpoint later answers, or on a restart that has not yet seen a 404 — a firmware fix retires it without anyone doing anything. The disable_scheduler action now refuses, with the reason, rather than reporting a success it did not achieve. And the missing endpoint is remembered rather than rediscovered at every session boundary: the master-switch write is already attempted before every schedule write, so by the time a teardown asks, the answer is known at no extra cost, and the handback declines with something to say instead of failing a step it was never going to win. How much is inferred from one response is bounded deliberately, because over-inferring would permanently disable a working feature: only a 404 counts — a 500, a timeout, or the errno 40257 a device without a scheduler answers with are all left alone, since none of them says the endpoint is absent — nothing is persisted, so a reload re-tests from scratch, and any later successful write erases the memory immediately. Modelled as a separate fact, not as "this device has no Mode Scheduler": that device's own flag endpoint says it does have one, and its schedule writes enable the switch implicitly, so calling it unsupported would be a confident falsehood about the owner's hardware — the same mistake get_scheduler_flag was changed to stop making — and would send them hunting for a firmware limitation they do not have. Smart charging and discharging are entirely unaffected on these inverters, and always were; nothing about sessions changes, and the session's own override group still comes off at teardown whether or not the handback can do anything (C-025 outranks this whole feature). Also covered end to end in a real Home Assistant for the first time (C-029): the disable_scheduler action over the real service registry including its mid-session refusal, and the 404 case from the wire all the way to a Repair issue listed by the repairs/list_issues websocket command. Writing that end-to-end coverage turned up something worth knowing if you drive this action from a script: a refusal is fully legible over the websocket API — which is what the frontend, Developer Tools, scripts and automations all use, message and translation key included — but Home Assistant's REST POST /api/services/foxess_control/disable_scheduler maps only two specific exception types to a 400 and lets everything else escape, so a refusal there arrives as a bare 500 Server got itself in trouble with the reason discarded. That is Home Assistant's behaviour for every integration rather than anything this one can change, but it is the difference between "the action explained itself" and "the action broke", so prefer a script step or a websocket call over raw REST if you need to know why. Regression coverage in tests/test_handback_policy.py::TestSchedulerSetUnavailable, tests/test_handback_foxess.py::TestTheMasterSwitchWriteEndpointIsRemembered and tests/test_handback_teardown.py::TestTheMasterSwitchWriteEndpointIsMissing, verified against four deliberately wrong implementations before the real one was kept: one folding the 404 into "no Mode Scheduler support" (caught by six tests), one recording any failed master-switch write so a single transient 500 disabled the feature until the next restart (three), one that never withdrew the Repair issue, so the notice outlived both the option being turned off and the endpoint starting to answer (two), and one raising the Repair issue regardless of the option, which would have notified every install that never opted in (one). The warning itself already fired once per inverter and then dropped to debug — that shipped in 1.0.22-beta.6 and needed no change; a test now also pins the demotion, so a future "fix" cannot silence the repeat outright and leave nothing to correlate against.
  • New action foxess_control.disable_scheduler — "Release the inverter now" (issue #16 asked for it by name). Turns the Mode Scheduler master switch off and returns the inverter to its own settings: work mode Self Use, plus your own Min SoC on grid if the integration recorded it. Local Modbus control works again, and a Min SoC below the scheduler's 10% floor becomes possible (issue #4). It deliberately does not consult the "Release the inverter when idle" option, because calling the action is the request — the option governs the automatic handback after every session, and requiring both would leave the person who wants their inverter released once, without signing up for it forever, with no action at all. That is not a licence to invent a floor: the value put back is still only the one the integration read before it ever touched that register, and if it never captured one, nothing is written (P-002). Every guard the automatic path applies applies here, by being the same code rather than a second copy of it: it refuses during a smart charge or discharge session (C-025 — disabling the scheduler mid-session strands the live override, so the group stops driving the inverter while the integration still believes it is discharging), refuses when the schedule contains work modes this integration does not manage and names the mode so "remove it in the FoxESS app" is actionable advice (C-018), refuses on a device that reports no Mode Scheduler, distinguishes "could not find out" from "your hardware does not have one", and makes no API call whatsoever in entity mode. Unlike the automatic path, a refusal is raised into the service call and shown in the UI immediately: a service that silently does nothing is worse than no service, because the user concludes their inverter was released (C-020). A device that refuses a write, by contrast, does not raise — by then the three independent steps have each been attempted and some may have taken effect, so an exception would misreport a partial handback as a total one; those go to the recent-errors buffer and the last-outcome record instead (C-026, D-059). It is not a second clear_overrides: no schedule group is added or removed, so a user asking for local control back does not silently lose a group they built, and calling it twice is not an error. Named, described and translated in all ten shipped locales, refusal message included — Home Assistant serves action labels from translations/<lang>.json rather than strings.json, so a missing locale renders the bare key. Regression class tests/test_handback_teardown.py::TestDisableSchedulerAction (plus a locale-parity class), verified against four deliberately wrong implementations before the real one was kept: one that bypassed the policy and wrote the master switch directly (caught by five tests), one that substituted the configured Min SoC default when nothing had been captured (two, one of them the automatic path's), one that made the action honour the opt-in option (nine), and one that logged refusals instead of raising them (seven). The tests themselves needed a second pass for the same reason: ServiceNotFound is a subclass of ServiceValidationError, so the one refusal test that checked only the exception type passed while the action did not exist at all.
  • The diagnostics download now explains the handback. Settings → Devices & Services → FoxESS Control → ⋮ → Download diagnostics gains a handback section carrying whether the option is on, the Min SoC on grid that was captured as yours, and the outcome of the most recent handback attempt — including the ones that declined, with the reason. That last part is the point: the handback is off by default, so on almost every install every outcome is a decline, and "why is my inverter still scheduler-controlled?" has to be answerable from a download taken on a system where, by design, nothing happened (C-020, C-026). "Never captured" and "captured 0%" are reported as different things, because a 0 % floor is exactly what issue #4 is about and a download that rendered the two identically could not say whether a handback will restore anything at all. The last known state of the Mode Scheduler master switch is included too, and it follows the write that turns the switch off as well as reads of it — otherwise a report from a released inverter would claim the switch was still on and contradict the device it was describing. The section is read entirely from memory: generating diagnostics makes no API call. That is asserted against recorded HTTP traffic rather than inferred from the code, because a download is requested precisely when the cloud is already misbehaving, and a report that hangs or trips the rate limiter is the one report that would have explained the problem. When the switch has never been observed the field is null rather than false, since "we never looked" and "we looked and it was off" send troubleshooting to opposite places. Nothing in the section is a credential, and that is proved by test rather than argued — non-vacuously, since the check first asserts the section is populated. Regression class tests/test_diagnostics.py::TestHandbackSection / ::TestHandbackSectionMakesNoRequest (15 tests), verified against three deliberately wrong implementations before the real one was kept: one testing the captured floor for truthiness so a real 0 % floor read as "nothing captured" (three tests), one fetching the scheduler flag live on the diagnostics path (four tests, one of them counting requests), and one whose cached flag tracked reads but not writes, so the download reported the master switch as still on for an inverter the integration had just released (one test).
  • The "Release the inverter when idle" option now does something. With it switched on, the end of every smart session hands the inverter back to its own settings: the Mode Scheduler master switch is turned off, the device's own work mode is set to Self Use, and your own Min SoC on grid is put back — exactly the value the integration read before it ever touched that register, including 0%, which the Mode Scheduler itself refuses to accept (issues #16, #4). With Mode Scheduler off the inverter obeys local Modbus control again, and the integration turns it straight back on for the next session, so sessions are unaffected. Off by default: an install that has not opted in makes no new API call of any kind at any session boundary — not merely no writes — so upgrading changes nothing until you ask it to. The order is fixed and is the safety argument for the whole feature: the session's schedule group comes off first, and only then does the master switch go off, because a failure the other way round would leave the inverter force-discharging behind a scheduler the integration could no longer steer (P-001). For the same reason a handback failure can never hold up the override removal (C-025) or be mistaken for one; failures are recorded individually in the diagnostics download's recent-errors buffer, collapsed by cause so one repeatedly failing teardown cannot evict the other 29 entries, and a last-outcome record keeps the reason even when the answer is "nothing happened" — a handback that fails silently is worse than one that never runs, because the toggle being on invites you to assume your inverter was released. Handback never acts while a session is running, and because that check is a snapshot it is re-taken immediately before the switch goes off and immediately after: a session that starts in that window has the switch turned straight back on. clear_overrides hands back too, since a user asking for their inverter back is the clearest case there is. Regression class tests/test_handback_teardown.py (29 tests) plus two end-to-end tests in a real Home Assistant, verified against eleven deliberately wrong implementations before the real one was kept — including one that handed back before removing the group (caught by five tests, one of them asserting request order, since the end state is identical either way and only the intermediate state is dangerous), one that ignored the opt-in option (four tests), one that swallowed step failures silently (two), one that trusted the session snapshot (two), one that omitted the error-buffer de-duplication (one), one that substituted the configured Min SoC default when nothing had been captured (one), and one with no exception guard at all, whose handback failure escaped into the listener and faked a failed override removal (three). Five of the 29 exist because a bug in the handback code itself must not become a session-boundary violation: every inverter interaction already absorbs its own failure, so nothing in normal operation reached the module's outermost guard, leaving its "never raises" promise load-bearing and untested — the sort of promise that quietly stops being true at the first refactor. Those tests also pin the honesty of the record: a crash must not leave the diagnostics download still reporting the previous session's success, and must never leave a half-written record describing a handback that never happened in that shape.
  • A "Release the inverter when idle" option in the integration's options (Settings → Devices & Services → FoxESS Control → Configure), which is the switch the scheduler handback of issues #16 and #4 will hang off. Off by default, and it does nothing yet — the teardown wiring lands separately, so this release only makes the option settable and readable. Nothing on the control path reads it, no byte on the wire differs, and no existing install changes behaviour. The default is the part worth being careful about rather than the feature: Home Assistant replaces the whole options dict with whatever an options flow returns, and the value it returns for a field the user never touched is the schema default — so a default of "on" would have enabled the handback, and with it writes to the user's own persistent Min SoC register, for anyone who merely opened the dialog and pressed Submit. Both directions are pinned by test, including an entry saved before this version existed reading as off all the way through to IntegrationConfig. For the same reason the tests also assert that adding the field did not make the dialog destructive: every other option the step owns (polling interval, Min SoC on grid, battery capacity, export limit, smart headroom, BMS interval, WebSocket mode, the additional-PV variable) is given a deliberately non-default value, and a save that only means to flip the new toggle must return all of them unchanged — compared as whole IntegrationConfig objects, not merely as present keys, since an options flow that silently reset someone's configuration would be far worse than this feature is worth.
  • The captured Min SoC is shown beside that toggle, read-only, as Home Assistant helper text (C-020). It has to be visible, because the captured value is authoritative and never re-read: a handback user who changes their floor in the FoxESS app has it put back. The remedy already exists — turning the option off and on re-captures — but a remedy for a value nobody can see is not a remedy. A dash is shown when nothing has been captured, deliberately not a number, since a number there would be a claim about the user's inverter that the integration has not actually read; the surrounding text explains the dash, so what the user reads stays localised in all ten languages. 0% renders as 0% rather than as "nothing captured", because a 0 % floor is exactly what issue #4 is about and a truthiness test there would hide the feature's own use case. The dialog still opens when the integration failed to set up, since "we do not know" is a perfectly good thing for it to say. Label and description are translated into all ten shipped locales, with a new locale-parity regression class — tests/test_card_translations.py covers only the Lovelace card's JavaScript tables, so the options flow had no such guard, and Home Assistant serves these labels from translations/<lang>.json rather than strings.json, meaning a locale missing the key renders the raw option name on a toggle that rewrites the user's Min SoC. Regression class tests/test_handback_options.py (48 tests), verified against four deliberately wrong implementations before the real one was kept: one defaulting the option to on (caught by three tests), one replacing the options schema instead of extending it so the save dropped every other option (three tests), one whose default ignored the saved value so every options save silently disabled the feature (one test), and one testing the captured floor for truthiness so a real 0 % floor read as "nothing captured" (one test).
  • New sensor.foxess_pv3_power and sensor.foxess_pv4_power — per-string power for multi-MPPT inverters (issue #15). KH-series and other inverters with more than two MPPT inputs report pv3Power / pv4Power, which the integration never asked for. Both follow the existing PV1/PV2 pattern exactly: diagnostic category, kW, disabled by default — enable them in Settings → Devices & Services → Entities. On inverters with only two strings the variables are absent from the API response, so the entities simply read unavailable and nothing else is affected. Note the overview card's PV breakdown still shows PV1 + PV2 only.
  • New sensor.foxess_solar_pv_energy — "Solar PV Energy" (C-041). Cumulative photovoltaic-only yield, from the FoxESS PVEnergyTotal variable, which the integration did not previously poll at all. Energy device class, total_increasing, kWh, enabled by default. This is the sensor to use as the Home Assistant Energy dashboard's solar source. On inverter models that do not report PVEnergyTotal the entity simply reads unavailable — the FoxESS API silently omits an unsupported variable from the response (verified against a live KH10), so the rest of the poll is unaffected and no reconfiguration is needed.
  • Detect when the inverter ignores schedule changes (issue #11). The integration now reconciles the work mode it commands against the mode the inverter actually reports on each poll (no extra API calls — it reuses the work mode the poll already reads). If the inverter keeps reporting a different mode well after a commanded change — e.g. it accepts a schedule write at the API but does not apply it, as some inverter firmware updates cause — a Repair issue is raised ("Inverter is not applying schedule changes") and the divergence is recorded in diagnostics. Detection only: it does not change control behaviour. Motivated by a report of smart charge running past the target SoC after an inverter firmware update.

Changed

  • Full power now uses the inverter's own declared maximum, even when it's higher than the old estimate (issue #34). The maximum charge/discharge power was the inverter's capacity × 1050, lowered to the maximum the inverter declares if that was smaller. The FoxESS API reports capacity as a whole number, so a KH9.9 reported 9 and was capped at 9450 W, while it declares, and the FoxESS app allows, about 10400 W. The declared maximum is now used whenever the inverter provides one; capacity × 1050 is only the fallback.
  • A Backup group made in the FoxESS app no longer blocks every action (D-067). Until now, any Backup group in the schedule made the integration refuse all schedule changes until you removed it in the app. Backup is now handled like the other modes the integration manages. A Backup window that doesn't overlap is kept as it is. One that overlaps is reported as a conflict unless you set replace_conflicts. Calling backup replaces it, and clear_overrides removes it. Nothing removes a Backup group unless you ask from Home Assistant. Modes the integration doesn't manage at all, such as PeakShaving, still make it refuse and name the mode.
  • The interpolated SoC can now run up to 0.494 % above the reported value, up from 0.44 %. Between the inverter's whole-percent SoC readings, the cards estimate SoC from battery power, held within [tick − 0.5, tick + 0.494] of the latest reading. The wider top end lets the estimate climb almost to the next whole percent during a charge before it stops, and the rounded value still matches the SoC entity.
  • Setup now always asks how the inverter is reached. Without foxess_modbus installed, the first step used to jump straight to the cloud API-key form. It now offers FoxESS Cloud and Local gateway, plus the foxess_modbus option when that integration is present.
  • Test infrastructure: an E2E failure capture can finally describe a card failure. No user-visible change — this is entirely test-harness diagnostics. CI run 33380962649 lost a TestFormInputPersistence failure to two blind spots. The .html artefact was written from page.content(), which is document.documentElement.outerHTML, and outerHTML does not serialise shadow roots — so for a dashboard whose cards sit four shadow hops inside Home Assistant, the dump stopped at <home-assistant> and contained nothing that was on screen. Grepping the real artefact for ha-textfield, form-start or No active operations returned nothing at all, even though the accompanying screenshot showed all three, which left the one question the failing test had asked — did the form ever open? — unanswerable from the evidence. The capture now walks every open shadow root and emits its content inline, each block wrapped in a self-describing #shadow-root (open) of TAG comment pair so a reader can tell shadow content from light DOM at a glance; subtrees containing no shadow host are still handed to outerHTML verbatim, so fidelity and cost are the browser's own. Depth and size are capped, and the cap announces itself in place rather than silently truncating, because a shortened dump that reads as a complete one produces a confidently wrong conclusion. A deliberately deep tree is not a hypothetical: with the depth cap removed the same walk raises RangeError: Maximum call stack size exceeded, and because the write is wrapped in contextlib.suppress, that failure would have deleted the artefact rather than reported anything — so the walk also falls back to the old shallow dump instead of losing the file. Second, the browser-diagnostics .log is now written on every capture, unconditionally. It was previously written only when the recorder buffer was non-empty, so for this failure — where the recorder was attached and the browser genuinely had nothing to say — no file appeared, and an absent file cannot be told apart from a harness bug that forgot to attach a recorder. Those are opposite conclusions: one is a defect in the test infrastructure, the other is evidence, positively ruling out a console error, an uncaught exception and a lost asset as the cause. The log now states which of the two it is describing, in words. Finally, the Playwright-native waits re-raise their own exception, whose entire text is Page.wait_for_function: Timeout 10000ms exceeded.; the capture summary that wait_for_condition puts in its message was being discarded, which is why this reached a human as an unexplained timeout with no hint that artefacts existed. Those sites now re-raise the same exception type carrying the summary. Regression class tests/test_e2e_failure_capture_shadow_dom.py, which drives a real Chromium DOM built to Home Assistant's actual nesting and asserts on the bytes written to the artefact rather than on the serialiser's source text, verified against eight deliberately wrong implementations before the real one was kept: the status quo (caught by five tests), a blind "concatenate every element's outerHTML and every shadow root's innerHTML" dump (three — and notably not caught by the straightforward "is the marker present" assertion, which is exactly why the negative controls exist), a correct walk that failed to delimit shadow content (one), the walk with its depth cap removed (one), the walk with no fallback, so an evaluate failure deleted the artefact (one), a log that did not distinguish a missing recorder from a silent browser (one), an unconditional log that dropped the recorded entries (two, one of them the pre-existing Lovelace panel-load test), and the original capture-then-discard-the-summary re-raise (one). The capture also now records navigations, because the improved capture immediately earned its keep and then ran out of things to say. Replaying the failing body ~1200 times under deliberate CPU load reproduced the failure once, and the new artefact localised it exactly: the timeout is the first wait, so the form never opened, and the serialised card shows a perfectly healthy idle card ten seconds later — SoC 50%, "No active operations", both action buttons present, no form overlay anywhere. The only unexplained content left was two aborted asset loads, net::ERR_ABORTED on a translations JSON and a frontend_latest chunk, which hints the document was replaced mid-load without saying so — and the difference decides the diagnosis, because a navigation landing between the click and the wait yields a fresh card with no form state and raises no "Execution context was destroyed", so every retry path stays dormant while the wait polls a healthy card until its budget expires. _set_form_value already carries a recovery branch for exactly that mode, so it is one this harness has met before. Navigations are now recorded with the main frame marked separately, since only a main-frame navigation replaces the card, and a negative control pins that a page which never navigated must not report one — an unconditionally emitted line would assert the very thing the next diagnosis needs to rule out. Nothing was changed in the test or the card, deliberately: 1600 instrumented replays showed the click always landing and always rendering the form synchronously, so no branch has been shown to need changing, and raising the wait's budget would be tuning a trigger away rather than fixing a cause (C-031). Refs C-031, C-029, C-020.
  • Test infrastructure: Flaky Test Detection's job timeout raised from 30 to 50 minutes. On v1.0.22-beta.6 ten of the twenty matrix jobs were cancelled at exactly 30 minutes while every job that finished passed — a time limit surfacing as a red workflow with no test actually failing. The previous fix (per-test rather than per-file selection, v1.0.22-beta.5) removed the variance in job size, where a third of the matrix drew 166 of 174 tests; it did not make the jobs fast, and the judgement at the time that they "were not legitimately slow" was wrong. A flat 87-test half runs 16-30 minutes on a GitHub runner, and the E2E suite has since gained a cold-browser-context test class for the Lovelace panel-load recovery work. 50 minutes clears the observed ceiling while still failing a genuine hang.
  • Groundwork for the scheduler handback (issues #16, #4): the integration now captures the user's own persistent Min SoC on grid, once, and restores it if a previous run died with a session floor still in the register. plan_handback already refuses to invent a Min SoC and restores only what was captured — but that rule is only as strong as the capture, and if the captured value were read after something had written a session value into MinSocOnGrid, the policy layer would faithfully restore the session value: the shipped defect the rule exists to prevent, reproduced with an immaculate-looking decision layer. This project has already shipped exactly that defect once, where an adapter wrote a session target into the persistent floor and never put the user's value back, so once the session ended the inverter imported from the grid to hold a floor the user never chose (P-001, P-002). So the capture is deliberately paranoid. It happens at most once and is then authoritative and never re-read, because any later read may see a session value and "refresh it while we're here" is the bug rather than a convenience. It happens only from a clean device — no smart session active and no managed override group (Force Charge / Force Discharge / Feed-in) on the inverter — and it runs after the startup schedule reconcile, which is what removes the orphaned groups a failed teardown leaves behind, so "clean" means clean rather than "clean apart from yesterday's leftovers". A whole-day Self Use group does not block it, since that is the normal idle state every session teardown leaves behind and group values never move the persistent register; treating it as unclean would mean capture never happened on a real install and the feature silently restored nothing forever. If capture is impossible — API failure or an unclean device — nothing is stored, plan_handback receives None, and nothing is restored; a later restart may try again, but a default is never substituted. In the other direction, a value already in storage is the user's value and outranks whatever the device currently reports, so it is written back over a leftover floor rather than being overwritten by it. The one write this adds is surgical: it goes through the device's MinSocOnGrid setting rather than battery/soc/set, because that endpoint writes minSoc and minSocOnGrid in a single request, so restoring only the captured on-grid floor through it would mean inventing an off-grid one — the same sin aimed at the other register. Values pass through verbatim, with no clamping to the Mode Scheduler's 10 % minimum and no rounding, because 0 is exactly what issue #4 is about. Nothing here can break setup or a session: every failure path is swallowed and logged, and a failed restore keeps the captured value so the next restart can retry. Only the write is gated on the new opt-in option, never the capture. Capture is a read and always runs, because reading early is the only way the value can be the user's own — waiting until they opt in would mean reading a register the integration might by then have written to. The crash-recovery restore is the one place this feature touches the inverter with no plan_handback decision in front of it, since it runs at setup before any plan exists, so it checks the option itself: with scheduler handback off — the shipped default — nothing here writes to the inverter at all, which is what makes "existing installs behave exactly as they did before the upgrade" true rather than aspirational. And because the captured value is authoritative and never re-read, there is a deliberate way to change your mind: turning the option off and then on again re-reads the floor. That transition is the only safe moment for a re-read — at the instant someone opts in, the integration has not been writing to the register, so whatever it holds is by definition what they chose — and it doubles as the remedy for a floor changed in the FoxESS app, with no new service and nothing extra to explain (C-020). Re-capture keeps every guard the first capture has, and one that cannot read a clean value keeps the value already stored rather than trading a slightly stale floor the user did once choose for no floor at all. Regression class tests/test_handback_capture.py (45 tests driving the real client over HTTP against a fresh simulator and a real Home Assistant Store), including issue #4 end to end at this layer — a 0 % floor captured, a real session run over it, and the floor restored through the real plan_handback decision — and verified against two deliberately wrong implementations before the real one was written: one that re-read the device late and substituted the configured default, and one that gated the capture instead of the write and re-captured on every options change.
  • Groundwork for the scheduler handback (issues #16, #4): the decision about whether to hand the inverter back to its own settings is now a pure function, handback.plan_handback, separate from anything that performs it. No user-visible change whatsoever — nothing calls it, no configuration option exists, no teardown path changed, and no byte on the wire differs; the wiring lands separately. It is split out first because the handback's risk is not in the two API calls, it is in deciding when they are safe, and a decision expressed as a value can be tested exhaustively without HTTP or a running Home Assistant. Five guards refuse to act, each guarding a way this feature could damage a working install: the option being off (opt-in, default off — hundreds of existing installs must behave exactly as they do today after an upgrade); entity mode (no cloud Mode Scheduler exists to hand back); the device reporting no scheduler support; any unmanaged work mode present in the schedule (C-018 — a Backup group is there because the user put it there, and the refusal names the group so the log is actionable rather than sending them hunting through the FoxESS app); and a smart session being active (C-025 — turning the master switch off mid-session would strand the live override, so the schedule group stops driving the inverter while the integration still believes it is charging or discharging, which is a safety divergence rather than untidiness). Guards are evaluated most-permanent-cause-first — not enabled, then entity mode, then unsupported, then unmanaged modes, then active session — so the reason a caller logs names the condition that will still be true tomorrow: a Backup group needs the user in the FoxESS app, whereas a session clears itself within hours, and reporting the transient cause over the permanent one would tell someone to wait for something that was never going to happen. Precedence only ever selects which reason is reported, since every guard declines, so no ordering can make the decision less safe. The behaviour that matters most is what the plan restores: when no Min SoC was captured, nothing is restored, and a default is never substituted — and a captured value passes through verbatim, with no clamping to the Mode Scheduler's 10 % minimum and no rounding, because 0 is exactly what issue #4 is about. This integration has already shipped a defect in which an adapter wrote a session value into the persistent Min SoC floor and never put the user's value back, so the inverter imported from the grid after the session ended; choosing a floor is the user's business (P-002) and the most this feature may ever do is put back what it found. The plan is a frozen dataclass so a caller cannot fill in a floor between the decision and the execution, and a declined plan carries no actions at all, so a caller that ignored the decision would still do nothing. Regression class tests/test_handback_policy.py (41 tests), which pins every guard, the precedence order, the never-invent rule and the immutability; verified against a deliberately wrong implementation before the real one existed.
  • Groundwork for the scheduler handback (issues #16, #4): the FoxESS client can now read and write the inverter's own settings, independently of the Mode Scheduler, via the undocumented POST /op/v0/device/setting/get and .../setting/set. No user-visible change yet — nothing calls these on the control path, no setting is written during normal operation, and no configuration option exists; the handback that uses them lands separately. Two properties of that surface, verified read-only against a live KH10, are now pinned by tests because they are the entire basis of the feature and would otherwise be silent assumptions. First, the direct work-mode enumeration contains no forced modes — it offers PeakShaving, Feedin, Backup, SelfUse and neither ForceCharge nor ForceDischarge — so a forced charge or discharge can only ever be expressed as a schedule group. That is why smart sessions must keep using the Mode Scheduler however the handback is configured, and why the handback can only govern the idle state; if FoxESS ever adds forced modes there, a failing test now says so rather than nobody noticing. Second, MinSocOnGrid accepts 0 as a device setting while the same device declares minsocongrid.range.min = 10 for schedule groups and rejects anything lower with errno 40257 (C-042) — so the 10 % floor users cannot get below is a Mode Scheduler restriction, not a hardware limit, which is precisely issue #4. Writing a work mode the device does not declare is refused locally with an error naming the mode and the accepted list, rather than being sent to earn an opaque 40257; this is deliberately stricter than the schedule path, which warns and writes anyway because refusing there could break installs that work today. The new set_work_mode_direct is named to be impossible to confuse with the existing set_work_mode, which writes a schedule group — the two are different control paths onto the same inverter, and tests pin that they stay independent in both directions: a settings write neither creates nor alters schedule groups, and a session's schedule write moves neither the user's work-mode setting nor their persistent Min SoC. docs/api/foxess-cloud-api.md documents both endpoints, their declared shapes and both asymmetries. Regression class tests/test_handback_foxess.py.
  • Test infrastructure: the Flaky Test Detection workflow's chronic panel-load failures are fixed (C-031) — one of the workflow's two independent causes of redness; see the job-timeout entry below for the other. No user-visible change — the integration is untouched; only the E2E harness changed. The workflow had never passed since v1.0.21-beta.2 (June 2026): on roughly 1 in 100 dashboard loads a test errored at setup with E2EConditionTimeout: lovelace-stage:ha-panel-lovelace: pass_check not satisfied within 74991ms, always at setup, never as an assertion failure, on random tests and in both connection modes. The captured screenshot showed the reason the message did not: a fully-booted Home Assistant with "Error while loading page lovelace." in the content area. Home Assistant loads its Lovelace panel as a Promise.all over 51 separately-fetched JavaScript chunks; if any one of those requests is lost — a starved GitHub runner drops one occasionally — hass-router-page catches the rejection, replaces the panel with <hass-error-screen> and never re-issues the import. The document is dead from that moment, so the harness's 75-second wait could never succeed; it was waiting for a page that had already failed, and then reporting a timeout, which sent three months of investigation towards slow-boot theories. The harness now (a) recognises hass-error-screen in its fail-fast check — previously it knew only ha-panel-error / hui-error-card, neither of which HA uses here — so the failure surfaces in about a second instead of 75, and (b) recovers by re-navigating, bounded to three navigations, because a rejected dynamic import is only ever retried by a new document; a plain timeout still fails on the first attempt, so this is recovery from an identified terminal state rather than a blind retry. Reproduced deterministically by fault injection against a real container (tests/e2e/test_ui.py::TestPanelLoadFailureRecovery aborts exactly the chunk that defines ha-panel-lovelace), which produced a pixel-identical failure capture and the verbatim CI error before the fix, and passes after it — setup time for that test fell from 87.3s to 14.0s. The trigger itself is environmental and does not occur locally: 820 consecutive local dashboard loads (500 unconstrained, 320 pinned to four cores, both at high xdist parallelism) produced zero failures.
  • Test infrastructure: E2E failure captures now say why the browser failed (C-020's spirit applied to the harness). Each page records console errors, uncaught page errors and failed network requests; on a wait failure the tail goes into the pytest message and the whole buffer is written next to the existing HTML and PNG as a .log artefact. The DOM summary is also now a recursive shadow-DOM search that reports the error element and its message — previously it used a flat document.querySelector for tags Home Assistant nests several shadow roots deep, which is why every capture said only elements present: ['home-assistant', 'home-assistant-main']. Had either of these existed in June, the failure above would have named the lost asset and the net error on day one. Regression class tests/test_e2e_lovelace_panel_load_error.py (11 tests, three of which drive a real Chromium shadow DOM).
  • Test infrastructure: a third of the Flaky Test Detection matrix was cancelled on every run, independently of test health, and no longer is. The workflow gave each of its 20 jobs "a random half of the tests", but selected at file granularity — and there are only three E2E files (76 + 90 + 8 tests), so one of the three equally-likely pairs draws the two heaviest, 166 of 174 tests. That overruns the job's 30-minute limit and is cancelled: 6 of 20 jobs on the last run, 10 on 2026-06-19. Selection is now per test, so every job runs 87 tests and finishes in the same time (~13 min against a 30-minute limit), while keeping the randomised test co-location the workflow exists to probe. The timeout was deliberately not raised — the jobs were not legitimately slow, they were unevenly sized. matrix.run also moved from ${{ }} interpolation inside run: into env:, following GitHub's workflow-injection guidance; it was never untrusted input, but the pattern is worth not modelling badly.
  • Test infrastructure: two pytest runs on one machine no longer destroy each other (new C-043). No user-visible change — this is a developer-workflow fix. E2E container names were derived only from the xdist worker id (ha-e2e-gw0), and the ha_e2e fixture removes that name at setup as a hygiene step, so the second of two concurrent runs issued podman rm -f against the first run's live container; the losing run then polled a dead container until its budget expired and reported TimeoutError: HA did not become ready within 120s at setup, producing cascades of failures that looked like product regressions. Reproduced directly by running the same two-test subset from two working directories at once: 1 passed, 1 skipped, 2 errors (121.9s setup) versus 2 passed, 2 skipped for the run that won the race; after the fix both runs give 2 passed, 2 skipped in ~31s. Container names now carry a checkout token, the worker process's pid and the xdist worker id, and cleanup removes a container only when it can prove the container is this run's own or belongs to a run that is provably dead — so a crashed run's leftovers are still reclaimed but a live run's are never touched. Separately, _find_free_port() probed a host port and released it before podman run -p bound it, so a concurrent run's probe could be handed the same port (measured: 6 concurrent processes x 50 ports produced duplicates in 5 of 6 rounds); ports now come from an OS probe paired with a host-wide claim held for the life of the run, under a cross-process lock, so a collision is impossible rather than unlikely. tests/soak/ uses the same helpers, so a soak run and an E2E run can share a host, and .githooks/pre-push no longer blanket-stops every ha-e2e-* container. Regression class tests/test_e2e_container_isolation.py (29 tests). This restores local E2E as a trustworthy signal (C-031) — CI is unaffected, as it runs one job per machine.
  • Test infrastructure: the simulator now models device-declared scheduler ranges (/op/v3/device/scheduler/get), the deviceType / function fields of device detail, and rejects out-of-range groups the way the live API does. Test HTTP servers bind 127.0.0.1 rather than localhost — a dual-stack localhost bind assigns different ports to the IPv4 and IPv6 sockets, so the advertised port was only valid for one family and concurrently-running test servers could receive each other's requests (C-031).

Fixed

  • No more "WS-DIAG" warnings in the log. Temporary diagnostics kept in 1.0.21 for the WebSocket idle-leak investigation logged a warning on every 5-minute poll, and a stack trace every time the WebSocket started or stopped. That leak is fixed, and the diagnostics are removed.
  • force_charge now charges at full power for its whole window (issue #32). It runs as a full-power smart session, but the "ahead of schedule, return to self-use" check still applied to it. So whenever the pacing estimate found spare time, a forced charge went back to self-use and later restarted at a reduced rate. With Battery Capacity unset, which force_charge allows, it looked as if no energy was needed, so it stayed in self-use for the rest of the window. On a cloudy day this left the battery well short. Forced charges no longer defer or re-defer, and always start at maximum power.
  • The charge card no longer contradicts itself (issue #32). The "target reachable" flag, the slack figures, the time-remaining estimate and the forecast now use the same inputs as the charging logic: the battery capacity the session started with, house load and the configured headroom. Before, they read the capacity from the options and ignored house load, so the card could call the target unreachable while the session was still waiting. The waiting message also no longer suggests a solar forecast. It now says charging at full power from the stated time still reaches the target.
  • Frozen cloud data now shows as stale (issue #41). The FoxESS Cloud sometimes keeps answering the 5-minute poll with the same cached sample for 30-55 minutes. One user saw this whenever Additional solar power variable was set to meterPower2. The integration presented each repeat as fresh data. It now compares the sample time the cloud returns: while the same sample keeps coming back, Data Freshness keeps the time it was first received, so the cards show its real age and turn stale after 15 minutes. A repeat longer than that is recorded in Recent Errors. The diagnostics download has a new rest_freshness section listing recent repeats, their duration, and whether the additional PV variable was in the request.
  • Turning the Mode Scheduler master switch on or off now works (issues #16, #17, #30). The integration sent it to /op/v0/device/scheduler/set, which the FoxESS Cloud does not serve on any model: KH, H1 and H3 inverters all answered HTTP 404. So foxess_control.disable_scheduler and Release the inverter when idle could never turn the switch off, and the switch was never explicitly turned on before a schedule write (the "Could not turn the Mode Scheduler master switch on" warning). It now uses /op/v1/device/scheduler/set/flag, the counterpart of the /op/v1/device/scheduler/get/flag read the integration already uses.
  • The Work Mode sensor no longer crashes with foxess_modbus (issue #24). foxess_modbus reports the work mode as Self Use, Force Charge and so on, while the sensor only accepts SelfUse, ForceCharge and the other mode values. So the sensor never got a state and every refresh logged a ValueError. The labels are now translated, and a mode with no equivalent here, such as Peak Shaving, shows as unknown. Thanks to @jesmon84 (PR #25) and @yourrival for the diagnosis.
  • Setup no longer fails on inverters whose device detail has no capacity (issues #13, #33). The M1-800-E and the MQ2200-M-H (NextEnergy Orbit-M) omit the capacity field, so setup stopped at "Could not determine inverter capacity from device detail" and retried forever. The integration now uses the maximum charge/discharge power the inverter declares for its schedules, and only fails if the inverter declares that too.
  • The options can be saved again with foxess_modbus installed and entity fields left empty (issue #33). Every empty entity field on the foxess_modbus step was rejected with "Entity is neither a valid entity ID nor a valid UUID", which blocked saving options for any cloud entry on a system with foxess_modbus installed. Empty fields are now accepted, and detected or current entities are still pre-filled.
  • A smart discharge that would start later is refused on the local backend, like every other action. The refusal used to come only from the start-now branch: a deferred discharge recorded a session, then failed while attaching its listeners, so the automation saw the error but a phantom "deferred" session stayed on the card. The backend check now runs before any session state changes.
  • A smart session persisted under the cloud backend no longer breaks setup on the local backend. Session recovery assumed every non-entity entry has a cloud inverter and failed an assertion without one; on a backend that cannot control the inverter, persisted sessions are now discarded with a warning.
  • environment.data_source in the diagnostics download was always null. It read a coordinator key that has never existed (data_source rather than _data_source), so every download claimed no data source.
  • AC-coupled installs no longer report grid import while they are exporting. With solar coming through a separate inverter (not wired into the FoxESS PV strings) and the battery full, the integration showed Grid Consumption Energy climbing and Grid Feed-in Energy stuck at zero, while the native FoxESS app showed the site exporting 1.52 kW — reported on an H3 5kW Gen 2 with WebSocket enabled (issue #18). The AC-coupled generation is the meterPower2 variable over REST, but the real-time WebSocket carries it as a node named aux, which the integration never read. So during any smart session the grid-direction inference (C-006) ran believing the site was generating nothing while it was in fact producing 3.32 kW: from a house load of 1.80 kW it predicted an import of 1.80 kW, the actual grid reading was 1.52 kW, and because those two magnitudes agree within the 3x reliability window the gridStatus field — which correctly said export — was never consulted. The sign came out backwards, and every kWh the site exported was booked as consumption. The existing "additional solar power variable" option could not save it: that value was added to pvPower after the direction had already been decided, so the balance never saw it however fresh it was. The WebSocket path now reads aux and folds it in before the balance runs, preferring the live value and falling back to the last REST-polled one when a frame does not carry it (dropping the term would put the balance straight back into the same failure mode). Units are handled per C-004 — watts as strings unless the field's own unit says kW. This is opt-in and changes nothing for anyone else: the term is only applied if you have set Additional solar power variable (usually meterPower2), because on a DC-coupled system the meaning of aux is not established. The derived direction logic is deliberately kept — it exists because gridStatus is not always reliable (D-010) — since the defect here was the input it was fed, not the arithmetic. If you have AC-coupled solar and have not yet set that option, set it: it is what enables both this fix and the correct total-generation figure the pacing algorithm works from. Refs C-004, C-006, D-010.
  • The control card now tells you when it has stopped receiving updates, and stops offering you buttons that cannot work. A user on 1.0.22-beta.5 clicked Cancel on a smart charge session, confirmed it, and watched the card go on showing a live charging session "even after a long time" — so they reported cancel as broken. It was not: their recorder history and system log show the session going idle at 12:20:01 and again at 12:21:22 and staying idle for 45 minutes, until one of their own automations re-armed it. The integration did exactly what it was asked; their browser had stopped receiving state updates, and the card gave them nothing whatsoever to see that with. This was a gap in 1.0.22-beta.5: that release added a staleness banner and dimming to the overview card and left the control card — the one that owns Cancel, Charge and Discharge — with nothing, which is the worse half of the pair. A stale overview shows misleading numbers; a stale control card invites you to act on them, and _handleAction called callService regardless of how old the view was, so on a dead WebSocket the click went nowhere and the user was left believing they had acted. The control card now carries the same treatment as the overview card, from the same code (a new shared foxess-stale.js imported by both, rather than a second copy of a threshold table that would drift): a warning banner at full strength above readings that are dimmed and desaturated, with the two causes worded differently because they need opposite responses from you — no connection to Home Assistant ("your readings are frozen; check your browser or network") versus inverter data stale ("check the inverter or the cloud API"). Only hass.connected distinguishes them, because the age a card displays is computed in your browser against its own clock, so a disconnected page shows an age that grows without bound while every number on it is frozen. While disconnected, Charge, Discharge and Cancel are all disabled, and the banner says why: the service call provably cannot be delivered, so an enabled button is a lie, and it is the specific lie that produced this report. When the connection is fine but the data is old the controls stay fully usable, deliberately — you may be cancelling precisely because you can see something is wrong, the call still reaches Home Assistant, and Home Assistant acts on its own state rather than on your browser's snapshot. Two smaller fixes ride along. The card's data-source badge used a flat 30-second staleness threshold against a 300-second poll interval, so a perfectly healthy REST install rendered the "stale" badge about 90% of the time — the same cry-wolf bug the overview card was fixed for, and the reason "API · 45m" did not stand out from the "API · 2m" the card showed the rest of the day; it now uses the per-source thresholds (WebSocket 60 s, REST and Modbus 900 s = three missed polls). And the staleness treatment is applied on the partial re-render path too, which is what runs while the Charge/Discharge form is open — the moment you are about to act is the worst possible moment to hide that the view is frozen. Refs C-020, C-029.
  • Cancel now acknowledges itself immediately, instead of appearing to do nothing. The confirming click used to fire clear_overrides and re-render from unchanged state, so nothing at all changed on screen until Home Assistant pushed new state — which is a large part of why the user above could not tell "my click didn't register" from "it worked and the session is ending". The button now switches to Cancelling… and goes un-clickable the instant you confirm, so a second click cannot fire a second request. It clears as soon as Home Assistant sends any news about the session (it ends, or its phase changes), and it is bounded: if the request never settles and no state ever arrives, the card gives up after 15 seconds and says so rather than sitting on "Cancelling…" forever — a permanently spinning card would be a new bug, not a fix for the old one. If the request is rejected outright, that is surfaced in words under the buttons with Cancel re-enabled so you can retry, rather than the failure being swallowed and the card left looking untouched — and that message retires when the session it was about ends, so you are never left reading "tap Cancel to retry" on an idle card that no longer has a Cancel button. It does survive ordinary polling, though, so there is time to read it. Refs C-020.
  • A rejected schedule write is now diagnosable from the diagnostics download alone. Issue #17 (an H3-12.0-E) still reports FoxESS API error 40257: Parameters do not meet expectations on 1.0.22-beta.4 — with the C-042 declared-range clamp demonstrably working (max_power_w 12000, not the 12600 the capacity x 1050 heuristic would give) and ForceCharge present in the device's declared enumeration. So a different schedule-group parameter is out of range, and the download could not say which, for three reasons: the smart-session listener's retry path caught the exception, logged it and returned without recording it, so recent_errors was empty despite three failures and an aborted session (defeating D-059 and C-026 for the integration's most important error class); the rejected payload was retained nowhere, because it only ever existed in the schedule_write event, which is emitted after a successful POST; and scheduler_limits reported two derived fields out of the whole properties map the device declares, hiding the declared fdsoc / minsocongrid ranges and maxGroupCount. All three are now closed. Adapter failures during a session reach recent_errors with the errno, the device's own message and the exact groups payload that was refused; the diagnostics schedule section reports last_write_failure (paired with last_write_ok_at, so a historical failure does not read as a current one) covering writes that never touch a session — the Self Use teardown baseline, a service call, the startup reconcile; and environment.scheduler_limits reports the device's full declared property map. To keep one failing session from evicting the 30-slot buffer, repeats of the same failure signature collapse into a single entry with a repeat count and a last_t timestamp — a session failing identically every tick costs two entries (the failure and the circuit-breaker escalation) no matter how many ticks or replays, while every occurrence is still logged. Observability only: no clamp was added, no schedule payload changed, and C-024's circuit-breaker semantics are pinned by test — the breaker still opens on exactly the third consecutive failure, holds for five ticks without touching the adapter, then aborts once.
  • Schedule writes no longer depend on an unverified API coupling to take effect. Schedule groups only drive the inverter while its Mode Scheduler master switch is on, and that switch is separate device state: removing every group does not turn it off (issue #16 — FoxCloud still showed the inverter as scheduler-controlled with no groups left). The converse has never been confirmed. Nobody knows whether POST /op/v0/device/scheduler/enable turns the switch back on from off, and finding out would mean writing to a production home battery, so it has not been tested. If it does not, then any session started after something turned the switch off — the forthcoming scheduler-handback feature, the FoxESS app, the web portal — would write a schedule that silently never fires: errno 0 from the API, the groups readable back from scheduler/get, and the inverter quietly sitting in Self Use with nothing surfaced to the user (P-003, P-005, C-020). The integration now turns the master switch on explicitly (POST /op/v0/device/scheduler/set) at the single point every schedule write passes through, so the outcome no longer depends on the answer. The call is idempotent and failure is tolerated — the endpoint is absent on some firmware and regions, and a device reporting support: false (e.g. a batteryless micro-inverter) rejects it — so a failed enable can never abort a write that would otherwise have worked; it warns once per inverter, then stays quiet. Nothing changes for installs whose switch is already on: the schedule payload on the wire is byte-identical. Regression class tests/test_handback_foxess.py, which pins both possible API behaviours in the simulator and asserts the same observable outcome either way — the switch is on and the group is actually in force. Prerequisite for the scheduler handback that closes issues #16 and #4.
  • A failed read of the Mode Scheduler capability flag was reported as "this inverter reports no Mode Scheduler support" (C-020, P-005). get_scheduler_flag() degraded any unexpected response shape to all-False, and result: null is a shape this API genuinely produces — scheduler/get returns it whenever no scheduler is configured. So one malformed or dropped reply became a confident statement about the user's hardware. The decision was fail-safe either way, since the handback declines in both cases, but the reason it would have logged sent someone looking for a firmware limitation that does not exist, and a log that lies is worse than one that says "unknown". There is now exactly one signal for "we do not know" — an exception — because a failed request and a malformed reply are indistinguishable in the only respect that matters, and collapsing them onto one mechanism makes it impossible to treat unknown as False by forgetting to check a sentinel. Inverter.probe_scheduler_support() turns that into the tri-state the policy layer consumes (True / False are the device's own answer, None means the question could not be answered), it never raises and never writes, and plan_handback now reports the two cases as two distinct reasons. Nothing user-visible changes yet: nothing on the control path reads the flag.
  • The overview card presented a disconnected browser as stale inverter data (C-020). If the Home Assistant frontend loses its WebSocket — tab suspended, laptop asleep, network blip — the page's copy of last_update freezes while the card keeps computing its age as Date.now() - last_update, so the displayed age grows without bound. A user reported "API - last updated 45 minutes ago" with solar reading zero; the integration had in fact polled successfully every 5 minutes throughout (every poll success: True, server-side age_seconds never above 300 s across 22 consecutive intervals). The card now checks hass.connected and distinguishes the two causes, because they need opposite responses: a disconnected frontend means check the browser or network, whereas genuinely old data means check the inverter or the cloud API. When either applies the readings are dimmed and desaturated behind a full-strength amber banner naming the cause and the age, so a stale card cannot be mistaken for a live one at a glance. Styled entirely from theme variables, so it reads correctly in light and dark themes, and translated into all nine languages the card ships.
  • The stale badge cried wolf, which is why the real signal was missed. Its threshold was a flat 30 s against a 300 s REST poll interval, so a perfectly healthy install rendered the stale badge for roughly 90% of every interval — "API - 2m" almost always, making the genuinely broken "API - 45m" indistinguishable from normal. Thresholds are now anchored to each source's actual cadence: 60 s for the WebSocket (which pushes every ~5 s) and 900 s for REST polling (three missed polls). The badge shows a bare API when healthy and only appends an age when something is actually wrong. Regression class tests/test_overview_card_stale.py (13 tests driving the shipped card in a real Chromium DOM, asserting computed opacity and filter rather than just class names); the E2E test that previously asserted the 30 s behaviour now guards the inverse.
  • Two sensors were mislabelled as solar when they measure inverter output (C-041), which caused the HA Energy dashboard to count battery discharge twice. sensor.foxess_solar_generation_energy ("Solar Generation Energy" / German "Solarenergie") and sensor.foxess_generation ("Generation") are fed by the FoxESS generation / generationPower variables — the inverter's cumulative AC output energy and power, which include everything the battery discharged. The solar name and solar icon led users to wire the energy one into the Energy dashboard as their solar source alongside the battery-discharge sensor as their battery source; on a live KH10 one night's computed home consumption came out as 26.6 kWh against an actual house load of 7.2 kWh (raw cloud history for that night: generation +18.2 kWh, PVEnergyTotal +0.2 kWh, pvPower flat at 0). They are now named "Inverter Output Energy" and "Inverter Output" in every language, and no longer carry solar icons. This is a friendly-name change only — unique IDs are unchanged and Home Assistant keeps the entity IDs of already-registered entities, so existing automations, dashboards, statistics and history are untouched. Fresh installs get entity IDs derived from the new names (sensor.foxess_inverter_output_energy, sensor.foxess_inverter_output). If you had either sensor set as your Energy dashboard solar source, switch it to the new sensor.foxess_solar_pv_energy.
  • scripts/collect_ha_session.py recorded inverter output in its solar_power column when the locale-aware entity lookup was unavailable — the English fallback pointed at sensor.foxess_generation instead of sensor.foxess_solar_power.
  • docs/api/foxess-cloud-api.md documented generation as "Lifetime solar generation energy" — the origin of the mislabelling. It now describes generation / generationPower as the inverter's AC output side, documents PVEnergyTotal as the PV-only counter, records that todayYield reads 0.0 on the KH10 and must not be relied on, and documents that real/query silently omits unsupported variables (errno: 0) rather than rejecting the request.
  • Every scheduler write failed with FoxESS API error 40257: Parameters do not meet expectations on H3-15.0-Smart, H3-12.0-M and EVO 10-5-H (issues #17, #14, #12; new C-042). Force Discharge, Feed-in and Force Charge all failed immediately — as did session teardown — while polling, real-time data and setup worked normally. Root cause: the force-discharge power (fdPwr) written into every schedule group was derived as capacity_kw * 1050, a factor reverse-engineered from a KH10. The FoxESS API declares the accepted fdPwr ceiling per device (POST /op/v3/device/scheduler/get → properties.fdpwr.range.max), and on a KH10 that ceiling is exactly 10 * 1050 = 10500 W — so the heuristic was right there by coincidence. Other model families declare the plain nameplate rating, so the same arithmetic overshot by 5 % (12600 W on a 12 kW H3, 5250 W on a 5 kW EVO) and the API rejected the whole write. The integration now reads the device's declared ranges once at setup and clamps fdPwr, fdSoc and minSocOnGrid into them at the single point every schedule write passes through, so no service argument or pacing value can produce a rejected payload. max_power_w (the ceiling the pacing algorithms work against) is now the lower of the capacity-derived value and the declared maximum. Installs whose devices do not expose the declared ranges keep the previous behaviour unchanged, and devices whose declared ceiling already equals capacity * 1050 (KH family) write a byte-identical payload — no reconfiguration is needed for anyone. Regression class tests/test_scheduler_device_limits.py.
  • Diagnostics always reported inverter_model: null. The field read a non-existent model attribute instead of device_type, so every diagnostics download from every user showed a null model — which made the three 40257 reports above look like a model-recognition problem when the model string is not used for anything. Diagnostics now report the real model name (e.g. KH10, H3-12.0-M) plus a new scheduler_limits section carrying the device-declared fdPwr ceiling and supported work modes, so a future rejected write is diagnosable from the download alone (C-020, C-026).
  • A work mode the inverter does not list as supported now logs a warning naming the mode and the device's own supported list, instead of only surfacing the API's opaque 40257. The write is still attempted, so a device that under-reports its capabilities keeps working.
  • Add-on could not start on Home Assistant OS (issues #9, #10). The add-on container died before reaching run.sh, so the integration was never copied into /config/custom_components/ — users saw the add-on install successfully but nothing appear under Settings → Devices & Services → Integrations. foxess-control/config.yaml did not declare init:, and the Supervisor defaults that option to true (vol.Optional(ATTR_INIT, default=True) in supervisor/apps/validate.py, passed to Docker as init= in supervisor/docker/app.py), which puts Docker's own init process (tini) at PID 1. The add-on is built on Home Assistant's Alpine base images, which ship s6-overlay v3 (3.2.2.0) and declare ENTRYPOINT ["/init"]; s6-overlay v3 requires its /init to be PID 1 and aborts with s6-overlay-suexec: fatal: can only run as pid 1 otherwise. Fixed by declaring init: false, which the add-on documentation has required for s6-overlay-v3 base images since 2022. This is the second of two stacked failures at the same choke point: the [FATAL tini (7)] exec /init failed: Permission denied variant both users quoted was the custom AppArmor profile that omitted /init (dropped in 1.0.19), and removing tini from the exec chain rules out both. No change to the integration itself — entity IDs, unique IDs and behaviour are untouched; only how the installer container boots. Regression class tests/test_addon_supervisor_boot.py, which builds the real add-on image and boots it the way the Supervisor does.
  • Orphaned schedule groups are now cleared on startup (issue #11, C-025). A FoxESS schedule group recurs daily, so a managed group (Force Charge / Force Discharge / Feed-in) left in the inverter by a smart session whose teardown did not complete — e.g. Home Assistant restarted mid-session, or the inverter accepted but did not apply the removal write — would re-fire at that window every day with the integration unaware. On startup, after session recovery, the integration now reads the live inverter schedule and removes any managed group that no active session covers, logging it and recording it in diagnostics. If an unmanaged mode (e.g. Backup) is present it does not modify the schedule (C-018) and surfaces the leftover instead. The diagnostics download now also includes the live inverter schedule (as of the last startup) so a leftover group is directly visible. Coverage is matched on work mode only (mirroring the in-session coverage check), not the exact schedule window, so a just-resumed session whose live group has a C-027 safe-horizon end (earlier than the planned window) is not wrongly removed. Note: a Force Charge / Force Discharge / Feed-in schedule group created manually in the FoxESS app (with no active smart session) is treated as an orphan and removed on startup; use an unmanaged mode (e.g. Backup) or the integration's own controls to retain manual schedules.
  • WebSocket data was discarded for the first few minutes of every smart session (C-020). The realtime-frame plausibility filter — which drops a single anomalous frame whose power diverges >10× from the last accepted value — also rejected the legitimate power jump at a session's start (idle batChargePower ≈0.36 kW → forced-charge ≈10 kW is a 27× jump, above the 0.1 kW near-zero exemption). Every frame was dropped until a REST poll happened to re-anchor the reference to a charging-scale value, so sensor.foxess_data_freshness stayed on api (not ws) for ~3–5 minutes after each charge/discharge start, and the WebSocket repeatedly went stale → disconnected → reconnected in that window (live 2026-06-15). Root cause: the >10× guard compared each frame only against the last accepted value and could not distinguish a sustained legitimate transition from a transient one-off glitch. Fix: the filter now confirms a divergent reading against the next frame — a transition corroborated by consecutive frames is accepted (after dropping only the first frame), while a lone glitch that is not corroborated is still discarded (preserving the anti-glitch protection added for the 2026-04-27 single-sample-dip incident). Bounds the worst-case data gap to one frame (~5 s) instead of minutes, in both directions (idle→active and active→idle). Regression class tests/test_realtime_ws.py::TestSustainedTransitionAccepted.

Documentation

  • docs/api/foxess-local-gateway-requirements.md: what the integration requires of the gateway (lifetime energy counters, write-budget visibility), written for the gateway's developers and since implemented. New design doc docs/knowledge/04-design/local-gateway.md (D-064, D-065).

Don't miss a new foxess-control release

NewReleases is sending notifications on new releases.