Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of current + voltage for single-phase pvinverters #1892

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

chriadam
Copy link
Contributor

@chriadam chriadam commented Feb 5, 2025

The /Ac/Current and /Ac/Voltage paths for pvinverters are deprecated / no longer valid.

Instead, determine whether there is a single valid phase available for a given pvinverter, and if so, export that phase's current and voltage as properties.

(If multiple valid phases exist, we cannot export valid aggregate values for current or voltage, so return NaN.)

Contributes to issue #1883

Contributes to issue #1713 in the case where only a single valid phase exists in the pvinverter device.

@chriadam chriadam force-pushed the chriadam/pvinverter-single-valid-phase branch from 55edcf4 to 6fde078 Compare February 5, 2025 06:47
readonly property real power: _power.isValid ? _power.value : NaN
readonly property real voltage: _voltage.isValid ? _voltage.value : NaN
readonly property real current: _validSinglePhase ? _validSinglePhase.current : NaN
readonly property real voltage: _validSinglePhase ? _validSinglePhase.voltage : NaN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see this data being useful in other multi-phase cases. What if these values could be provided by PhaseModel instead? E.g. if we had PhaseModel properties like current and voltage or overallCurrent and overallVoltage and these were only set in the single-phase case (i.e. when there is only one phase with valid voltage/current/power)?

@chriadam chriadam force-pushed the chriadam/pvinverter-single-valid-phase branch from 6fde078 to 2fe5693 Compare February 17, 2025 05:28
Copy link
Contributor

@blammit blammit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, LGTM

phases.updateCount(index + 1)
} else if (phases.count > index) {
phases.setValue(index, PhaseModel.EnergyRole, NaN)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth adding a function to do this to avoid the duplicated code for the four roles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@chriadam chriadam force-pushed the chriadam/pvinverter-single-valid-phase branch 2 times, most recently from 0472666 to a98866a Compare February 18, 2025 04:59
The /Ac/Current and /Ac/Voltage paths for pvinverters are
deprecated / no longer valid.

Instead, determine whether there is a single valid phase
available for a given pvinverter, and if so, export that
phase's current and voltage as properties.

(If multiple valid phases exist, we cannot export valid
aggregate values for current or voltage, so return NaN.)

Contributes to issue #1883

Contributes to issue #1713 in the case where only a
single valid phase exists in the pvinverter device.
@chriadam chriadam force-pushed the chriadam/pvinverter-single-valid-phase branch from a98866a to e570f82 Compare February 18, 2025 05:41
@chriadam
Copy link
Contributor Author

done. merging.

@chriadam chriadam merged commit 5b52fd9 into main Feb 18, 2025
2 checks passed
@chriadam chriadam deleted the chriadam/pvinverter-single-valid-phase branch February 18, 2025 06:02
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.

3 participants