Repository navigation
fix(solaredge_pv): read SunSpec scale factors every poll, not cached - #38
Merged
frahlg merged 2 commits intoApr 16, 2026
Merged
Conversation
SunSpec explicitly says scale factors are dynamic — they can change at runtime so the inverter can pick the optimal resolution for the current value. The PV-only driver was reading each _SF register once at startup and caching it in sf_cache, which silently breaks the moment the inverter changes range. Observed on a live commercial-firmware SolarEdge inverter: at startup the W_SF register was -1 (value * 0.1), so sf_cache.ac_power = -1. Later in the day the inverter shifted W_SF to 0 (no scaling), but the cached -1 stayed in effect — every reported AC power was off by a factor of 10 (3582 W inverter -> 358 W reported). Fix: drop the cache and batch-read the whole Model 103 inverter block (40069..40120, 52 regs) once per poll. Every value and every paired SF comes from the same Modbus transaction, which is exactly what SunSpec requires. Side effect: fewer round trips on steady-state polls than the previous code, which issued 6+ individual SF reads. MPPT A/V live outside Model 103 so they keep their own reads, but each MPPT poll now pairs its own SF read in the same cycle.
Member
|
Nice catch — the SunSpec dynamic-SF behavior is a real foot-gun, and the 52-register batch read is strictly cheaper than the old 6+ individual reads. Before merging: Either is fine with me; just don't want the twin driver to ship with a known bug while this one's fixed. |
github-actions Bot
pushed a commit
to erikarenhill/forty-two-watts
that referenced
this pull request
Apr 16, 2026
## [1.1.0](v1.0.1...v1.1.0) (2026-04-16) ### Bug Fixes * 5 Go-side P1 bugs from Codex review ([srcfl#46](https://github.com/erikarenhill/forty-two-watts/issues/46)) ([0cd2885](0cd2885)) * 5 Go-side P1 bugs from Codex review ([srcfl#47](https://github.com/erikarenhill/forty-two-watts/issues/47)) ([4f2eaf6](4f2eaf6)) * **solaredge_pv:** read SunSpec scale factors every poll, not cached ([srcfl#38](https://github.com/erikarenhill/forty-two-watts/issues/38)) ([26f8793](26f8793)) ### Drivers * fix 9 P1 bugs flagged by Codex review ([srcfl#44](https://github.com/erikarenhill/forty-two-watts/issues/44)) ([b20e485](b20e485)) ### UI * show mode band in plan chart + grid target on status card ([877e0bd](877e0bd)) ### Control loop * slew-rate anchors on actual battery power, not stale command ([srcfl#41](https://github.com/erikarenhill/forty-two-watts/issues/41)) ([4f73f19](4f73f19)) ### MPC planner * log optimize params + ems_mode per action for plan chart ([9e8c14b](9e8c14b)) * value SoC at import−export spread in self-consumption modes ([srcfl#40](https://github.com/erikarenhill/forty-two-watts/issues/40)) ([a90d525](a90d525))
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 16, 2026
## [2.0.1](v2.0.0...v2.0.1) (2026-04-16) ### Bug Fixes * 5 Go-side P1 bugs from Codex review ([#46](#46)) ([0cd2885](0cd2885)) * 5 Go-side P1 bugs from Codex review ([#47](#47)) ([4f2eaf6](4f2eaf6)) * **solaredge_pv:** read SunSpec scale factors every poll, not cached ([#38](#38)) ([26f8793](26f8793))
Contributor
|
🎉 This PR is included in version 2.0.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 16, 2026
## [0.4.0](v0.3.0...v0.4.0) (2026-04-16) ### Features * config/UI improvements — kWh display, secure EV password, planner tab ([#65](#65)) ([35ab03d](35ab03d)) * Easee Cloud driver + host.http_get/post for Lua drivers ([#56](#56)) ([4cdc942](4cdc942)) * EV charger config + credential masking in API responses ([#58](#58)) ([c22cb80](c22cb80)) ### Bug Fixes * 5 Go-side P1 bugs from Codex review ([#46](#46)) ([0cd2885](0cd2885)) * 5 Go-side P1 bugs from Codex review ([#47](#47)) ([4f2eaf6](4f2eaf6)) * address P2 review comments across control, MPC, drivers, and UI ([#64](#64)) ([fcafa88](fcafa88)) * **ci:** disable @semantic-release/github PR annotation features ([4020d46](4020d46)), closes [#32](#32) [#33](#33) [#34](#34) [#35](#35) [#36](#36) [#39](#39) * **ci:** switch semantic-release to conventionalcommits preset ([7e0bb89](7e0bb89)) * **ci:** upgrade GitHub Actions to Node.js 24 (drop deprecated Node 20) ([4005bd8](4005bd8)) * Lua driver Command() reading wrong field — Sungrow ignored targets ([9237156](9237156)) * populate EV Charger tab from driver config when ev_charger is empty ([5e6b116](5e6b116)) * remove dead evSlider event listeners that crash app.js ([8ae76c7](8ae76c7)) * replace wonky Catmull-Rom spline with simple linear forecast ([abea431](abea431)) * show '...' instead of stale v0.1.0 while JS loads version ([dc65065](dc65065)) * **solaredge_pv:** read SunSpec scale factors every poll, not cached ([#38](#38)) ([26f8793](26f8793)) ### Drivers * add Eastron SDM630 Lua driver ([#18](#18)) ([d5ad806](d5ad806)) * add Ferroamp Modbus driver (alt transport to ferroamp.lua) ([#31](#31)) ([03b802c](03b802c)) * fix 9 P1 bugs flagged by Codex review ([#44](#44)) ([b20e485](b20e485)) * port Deye SUN-SG hybrid inverter to 42W v2.1 Lua host ([#29](#29)) ([df8fbc0](df8fbc0)) * port Fronius GEN24 (SunSpec) to Lua ([#19](#19)) ([c1fc875](c1fc875)) * port Fronius Smart Meter (SunSpec Modbus, read-only) ([#24](#24)) ([575895c](575895c)) * port GoodWe hybrid inverter (ET-Plus / EH) to Lua v2.1 ([#28](#28)) ([e43d2d9](e43d2d9)) * port Growatt hybrid inverter driver (read-only) ([#20](#20)) ([92524ac](92524ac)) * port Huawei SUN2000 hybrid inverter ([#15](#15)) ([09a8855](09a8855)) * port Kostal Plenticore / Piko IQ (Lua, read-only) ([#21](#21)) ([bdeca96](bdeca96)) * port Pixii PowerShaper battery driver to v2.1 Lua host ([#22](#22)) ([70a96d1](70a96d1)) * port SMA hybrid inverter Lua driver ([#23](#23)) ([dd34555](dd34555)) * port Sofar HYD-ES/HYD-EP from hugin to Lua v2.1 ([#26](#26)) ([14f6131](14f6131)) * port SolarEdge SunSpec inverter + meter to Lua (read-only) ([#30](#30)) ([1007e63](1007e63)) * port Solis hybrid inverter ([#27](#27)) ([98b2a50](98b2a50)) * port Victron Energy GX Modbus driver ([#25](#25)) ([ad71db2](ad71db2)) ### UI * add status bar with driver health indicators ([b048d60](b048d60)) * EV status card + Easee control commands ([#59](#59)) ([b03749a](b03749a)) * fix summary cards grid for 7 cards + raise side-by-side breakpoint ([6e19973](6e19973)) * inline target on hover + driver card + collapsible model cards ([de88f43](de88f43)) * legend wrap + nice-tick y-axis + cleaner chart labels ([#33](#33)) ([aeb1d1c](aeb1d1c)) * remove manual EV charging slider ([063174c](063174c)) * show mode band in plan chart + grid target on status card ([877e0bd](877e0bd)) * smooth Catmull-Rom spline for forecast + 15min forecast zone ([dba51a5](dba51a5)) ### Control loop * fold live DerEV readings into the EV clamp ([#36](#36)) ([5d57d68](5d57d68)) * slew-rate anchors on actual battery power, not stale command ([#41](#41)) ([4f73f19](4f73f19)) ### MPC planner * fall back to forecast when learned PV twin collapses ([#39](#39)) ([f3062ac](f3062ac)) * log optimize params + ems_mode per action for plan chart ([9e8c14b](9e8c14b)) * value SoC at import−export spread in self-consumption modes ([#40](#40)) ([a90d525](a90d525)) ### Telemetry * add DerEV type for EV charger readings ([#34](#34)) ([65c9e2c](65c9e2c)) ### TSDB * long-format SQLite (14d) + Parquet rolloff for older ([c53c964](c53c964)) ### Safety * watchdog marks stale drivers offline + reverts to autonomous ([519196c](519196c))
frahlg
added a commit
that referenced
this pull request
Sep 27, 2026
…st proxies (#1454) Owner decision 2026-09-26: the signed control v2 runtime has been unreachable since the Device Support package format was removed (#1432); driverrepo only ever binds a read-only policy now. - #16 Remove control v2: LuaDriver.CommandV2/DefaultModeV2, the v2 load and lifecycle timeouts, write scopes, write budget and host evidence, the command/result envelope types and validation, the registry's v2 dispatch, lease timer, stale/lease-expiry defaults and v2 startup default, and Registry.CommandResultSink with its main.go wiring. The legacy driver_command/driver_default_mode path, the recovery gate and the observe_only handling from #1444 are unchanged. - RuntimePolicy (control_v2.go -> runtime_policy.go) keeps only the read-only policy; validate rejects any other, and allowWrite refuses every write from a driver that carries a policy. - Drop the 100 ms host.sleep cap that, after v2, applied only to signed read-only drivers, so a file sleeps the same whichever source it came from (new test). - driver_command_results is no longer created and its write-only store method is gone; existing tables are left inert with a note in migrate(). - #38 Delete the unused HostEnv mqttSubscribe, mqttPublish, mqttPollMessages, modbusWriteSingle and modbusWriteMulti proxies. - Move the surviving read-only lifecycle test, adapt the HTTP 302 and OAuth sign-in tests, and update the roadmap, driver guide and comments that described v2. Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SunSpec explicitly says scale factors are dynamic — they can change at runtime so the inverter can pick the optimal resolution for the current value. The PV-only driver was reading each _SF register once at startup and caching it in sf_cache, which silently breaks the moment the inverter changes range.
Observed on a live commercial-firmware SolarEdge inverter: at startup the W_SF register was -1 (value * 0.1), so sf_cache.ac_power = -1. Later in the day the inverter shifted W_SF to 0 (no scaling), but the cached -1 stayed in effect — every reported AC power was off by a factor of 10 (3582 W inverter -> 358 W reported).
Fix: drop the cache and batch-read the whole Model 103 inverter block (40069..40120, 52 regs) once per poll. Every value and every paired SF comes from the same Modbus transaction, which is exactly what SunSpec requires. Side effect: fewer round trips on steady-state polls than the previous code, which issued 6+ individual SF reads.
MPPT A/V live outside Model 103 so they keep their own reads, but each MPPT poll now pairs its own SF read in the same cycle.