-
-
Notifications
You must be signed in to change notification settings - Fork 101
Fixed #1466 #1477
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
Fixed #1466 #1477
Conversation
@altserg can you add a description to this pull request please? |
Now the Active.Import.Register sensor also gets updated
WalkthroughThe pull request introduces a new enumeration Changes
Sequence DiagramsequenceDiagram
participant CP as Charge Point
participant MS as Meter Service
CP->>MS: Receive Meter Values
alt Transaction Begin Context
MS-->>CP: Ignore Specific Measurands
else Normal Context
MS->>CP: Process Meter Values
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (2)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
custom_components/ocpp/chargepoint.py (1)
780-792
: Consider improving readability.The nested conditions could be simplified and the comment could be more descriptive. Here's a suggested refactor:
- # Ignore messages with Transaction Begin context - if context != ReadingContext.transaction_begin.value: - if is_transaction: - self._metrics[csess.session_energy.value].value = value - self._metrics[csess.session_energy.value].unit = unit - self._metrics[csess.session_energy.value].extra_attr[ - cstat.id_tag.name - ] = self._metrics[cstat.id_tag.value].value - else: - self._metrics[measurand].value = value - self._metrics[measurand].unit = unit - else: - continue + # Skip processing for Transaction Begin context as these values + # should not contribute to energy metrics + if context == ReadingContext.transaction_begin.value: + continue + + if is_transaction: + self._metrics[csess.session_energy.value].value = value + self._metrics[csess.session_energy.value].unit = unit + self._metrics[csess.session_energy.value].extra_attr[ + cstat.id_tag.name + ] = self._metrics[cstat.id_tag.value].value + else: + self._metrics[measurand].value = value + self._metrics[measurand].unit = unit
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
custom_components/ocpp/chargepoint.py
(2 hunks)
🔇 Additional comments (2)
custom_components/ocpp/chargepoint.py (2)
31-37
: LGTM! Import changes are appropriate.The addition of
ReadingContext
enum is necessary for the new functionality and is correctly grouped with other enums from the same module.
780-792
: LGTM! Changes correctly address the issue.The implementation properly ignores energy report messages with Transaction Begin context, which aligns with the PR objective to fix issue #1466.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1477 +/- ##
=======================================
Coverage 92.75% 92.75%
=======================================
Files 12 12
Lines 2028 2030 +2
=======================================
+ Hits 1881 1883 +2
Misses 147 147 ☔ View full report in Codecov by Sentry. |
Ignore energy report messages for Transaction.Begin context
Summary by CodeRabbit
New Features
ReadingContext
for improved context handling.Bug Fixes