Skip to content

Fix the accumulator helper being called with the wrong arity - #1039

Open
it-rec wants to merge 1 commit into
WillCodeForCats:mainfrom
it-rec:fix/meter-accum-call-arity
Open

Fix the accumulator helper being called with the wrong arity#1039
it-rec wants to merge 1 commit into
WillCodeForCats:mainfrom
it-rec:fix/meter-accum-call-arity

Conversation

@it-rec

@it-rec it-rec commented Aug 16, 2026

Copy link
Copy Markdown

Problem

update_accum() is defined as update_accum(self, accum_value) in helpers.py, but both meter accumulator sensors call it with three arguments:

return update_accum(self, value, value)

Every call raises TypeError: update_accum() takes 2 positional arguments but 3 were given. The call sits inside a bare except Exception: return None, so the error is swallowed and the affected entities simply report None forever. That is also why this went unnoticed: nothing appears in the log.

Changes

  • Pass the value once.
  • Narrow the handler to ValueError, which is what update_accum legitimately raises for a non-increasing accumulator. A programming error is no longer hidden.

Testing

Verified by reading the signature against the call sites - the mismatch is unconditional and does not depend on hardware.

On my own system the affected entities stay unavailable even after this fix, because my meter does not implement the corresponding scale factors: M_VAh_SF and M_varh_SF both return the not-implemented sentinel, and the existing scale-factor range check correctly keeps the entities unavailable. So I can confirm the crash is gone, but I cannot confirm a value on real hardware - that needs a meter that implements those registers.

Checklist

  • Based on the latest upstream main.
  • One subject only.
  • Verified against the code; hardware limitation stated above.

update_accum() takes (self, accum_value), but both meter accumulator
sensors call it as update_accum(self, value, value). Every call raises
TypeError, and because the call is wrapped in a bare "except Exception:
return None" the error is swallowed, so the affected entities silently
report None instead of a value.

Pass the value once, and narrow the handler to ValueError, which is what
update_accum legitimately raises for a non-increasing accumulator. A
programming error is no longer hidden.
@it-rec
it-rec force-pushed the fix/meter-accum-call-arity branch from fd3fef6 to df58a68 Compare August 17, 2026 05:04
@WillCodeForCats

Copy link
Copy Markdown
Owner

This went unnoticed because the other places update_accum() was used were actually removed years ago, and these were forgotten about because nobody uses them to report a problem (measurements are not supported by the most common meters provided by SolarEdge).

It can be fixed but this is more of a reminder to stop using them and delete the helper completely.

@it-rec

it-rec commented Aug 17, 2026

Copy link
Copy Markdown
Author

Agree. Should I do it?

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.

2 participants