Repository navigation
Add energy formulas - #143
Mohammad-Tayyab-Frequenz wants to merge 3 commits into
Conversation
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>
d419e1e to
1071b21
Compare
Marenz
left a comment
There was a problem hiding this comment.
The centralizing fix is the right shape, but the fallback isn't safe yet. formula_for_metric reuses the AC_POWER_ACTIVE formula for AC_ENERGY_ACTIVE_CONSUMED/DELIVERED. The real consumption/grid formulas use subtraction and MAX(x - y, 0.0) to pick between bidirectional meters — that arithmetic doesn't make sense applied to energy counters, which are already non-negative and direction-resolved. It also means consumed and delivered end up with the identical fallback formula, nothing tells them apart. Tests only cover a plain sum (#12+#23), so this doesn't show up.
Also: mypy now fails under ci_checks_max on tests/test_config.py:129 (indexed assignment into an Optional dict), and the branch still conflicts with v0.x.x (RELEASE_NOTES.md, _load.py, _microgrid.py, from #144's generation type) — needs a rebase before this can land.
| formula = self.formula.get(_POWER_FORMULA_METRIC) | ||
| return formula | ||
|
|
||
| def cids(self, metric: str = "") -> list[int]: |
There was a problem hiding this comment.
I think we should remove this, I am not aware if it is used anywhere.
Is this still true, I think the clamping was removed. |
Add
AC_ENERGY_ACTIVE,AC_ENERGY_ACTIVE_CONSUMED, andAC_ENERGY_ACTIVE_DELIVEREDto_derive_component_configsfunction.