Skip to content

fix(deye-svk): skip energy headroom when the SoC read fails - #224

Draft
murre87 wants to merge 1 commit into
srcfl:mainfrom
murre87:fix/deye-svk-nil-soc
Draft

murre87 wants to merge 1 commit into
srcfl:mainfrom
murre87:fix/deye-svk-nil-soc

Conversation

@murre87

@murre87 murre87 commented Nov 10, 2026

Copy link
Copy Markdown

Summary

deye-svk.lua computes the energy headroom from bat_soc whenever battery_capacity_wh > 0. When the SoC read fails in a poll, bat_soc is nil and math.floor(bat_soc * 100 + 0.5) raises a Lua error, so the whole poll fails. This adds the same guard the 50-125k-svk drivers already use (and bat_soc), so the headroom stays 0 for that poll. Version 0.2.2 -> 0.2.3 in the driver and manifest, CHANGELOG entry under Unreleased.

Seen in the field in EnergyWizard (driver from commit e07d27038e83): automatic error report ftw_deye-svk.poll: LuaError, murre87/energywizard#215. Fixed there by lazgeo (Co-authored-by in the commit). Context: murre87/energywizard#231.

Driver evidence

  • Driver id: deye-svk
  • Device make/model: Deye SUN hybrid (lean SvK fast-poll variant)
  • Firmware tested: none
  • Protocol/register source: unchanged, no register changes
  • Hardware test performed: no, not tested on Deye hardware (draft until it is)
  • Known limits: only guards the nil case; behaviour with a valid SoC is unchanged

Safety

  • The driver starts read-only, or this is a separately reviewed control change. (No control change.)
  • Vendor signs are converted at the driver boundary. (Unchanged.)
  • Cached telemetry becomes stale instead of being re-emitted as fresh. (Unchanged.)
  • No credentials, serial numbers, private addresses or site data are included.

Control evidence

not applicable (no control path changes)

Checks

  • Commits include Signed-off-by.
  • make test-driver ID=deye-svk (not run locally)
  • make check (not run locally; the Lua compiles with Lua 5.4)

bat_soc is nil after a failed SoC read, and the headroom calculation then
raised a Lua error whenever battery_capacity_wh was set. Guard it the same
way as the 50-125k-svk drivers. Version 0.2.2 -> 0.2.3.

Reported and fixed in murre87/energywizard#215 by lazgeo.

Co-authored-by: lazgeo <gl@glic.se>
Signed-off-by: Emil Axfors <17743298+murre87@users.noreply.github.com>
murre87 added a commit to murre87/energywizard that referenced this pull request Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant