Skip to content

POST /api/config that sets is_site_meter never reaches the running controller — grid_w pegs at 0 #760

Closed

Description

@Leitet

Symptom

Add the first driver with is_site_meter: true via POST /api/config (what the setup wizard and Settings do). The driver starts and polls fine — drivers.<name>.meter_w in /api/status is live and correct — but top-level grid_w stays exactly 0, load_w inflates to ≈ |pv_w| (it's computed as grid − bat − pv with grid 0), and the grid energy slot counters never accumulate. Dispatch would treat the site as having no meter. A process restart fixes it.

Observed on v1.15.0 on a fresh Pi-image install: FoxESS site meter added via the API, site exporting ~3.8 kW, dashboard showing Grid 0 W and Load 4.6 kW.

Root cause — two halves

  1. handlePostConfig applies control fields selectively and misses SiteMeterDriver (api.go, "Apply control-level changes immediately"): it sets grid target, tolerance, slew, min dispatch interval, PV-surplus fields — but not Ctrl.SiteMeterDriver. With no driver at boot, the controller's field stays "", and handleStatus takes the deliberate SiteMeterDriver == "" → grid_w = 0 branch.

  2. The same handler then masks the watcher that would have repaired it. configreload/watcher.go handles exactly this ("Site-meter swap … or set it for the first time" — its comment even predicts "grid_w pegs at 0"). But the watcher diffs the file against the shared cfg pointer (oldCfg := *w.cfg), and handlePostConfig swaps that pointer (*s.deps.Cfg = newCfg) before/as it saves the file. By the time the watcher fires on the API-written file, old == new, every diff is a no-op, and the swap logic never runs. The API path's partial "we're snappier" apply suppresses the watcher's complete one — for SiteMeterDriver and for anything else the handler doesn't replicate (the watcher also syncs mpc + loadmodel via main.go's applier callback; the API path does none of that).

Fix directions

Either make handlePostConfig stop pre-swapping the shared pointer and let the watcher own the apply, or extract the watcher's apply into one function both paths call. Duplicating one more field into the handler would fix this symptom but leaves the masking pattern in place for the next field.

Workaround

POST /api/restart (or moving is_site_meter by editing config.yaml directly, which the watcher does see).

🤖 Diagnosed with Claude Code

Activity

  1. added a commit that references this issue on Aug 4, 2026
    b348685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions