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.
Fix for incorrectly defaulted values
Summary
This pull request addresses an issue related to the reporting of electricity consumption and production values for triple-phase power.
Context
After installing a new power meter, I transitioned from single-phase to triple-phase power. However, the existing reader began reporting incorrect values. The issue arises from a unique edge-case scenario: most of my home is connected to the first phase, while solar panels are connected to the second phase. This results in power consumption on the first phase and power generation on the second phase.
Problem
The discrepancy occurs in the calculation of
electricity.instantaneous.power.negative.L1
due to the defaulting behavior ofoutput.power.instantaneousProducedElectricityL1
:This defaulting behavior should only apply when
output.power.instantaneousProducedElectricityL1
isundefined
, not when it is0
.Solution
A new function
getDefaultedValue
has been introduced to handle the defaulting behavior. It iterates through provided arguments and returns the first non-undefined value or 0 if all provided arguments are undefined:Example
This change ensures that the defaulting behavior operates as intended, addressing the reported discrepancies.