Fix id_tag sensor not updated for local authorization (#1871)#1905
Fix id_tag sensor not updated for local authorization (#1871)#1905rishabhvaish wants to merge 3 commits intolbbrhzn:mainfrom
Conversation
…lbbrhzn#1871) When an OCPP 1.6 charger performs local authorization (e.g., RFID card in local list), it skips the Authorize message and sends StartTransaction directly. The on_start_transaction handler only set the connector-level id_tag but not the charger-level (connector 0) metric, so sensor.<cpid>_id_tag remained stale. Also clear the charger-level id_tag in on_stop_transaction for symmetry. The OCPP 2.0.1 handler (on_transaction_event) already handles this correctly. Fixes lbbrhzn#1871 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Rishabh Vaish <rishabhvaish.904@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSynchronize charger-level (connector 0) and per-connector id_tag metrics during transaction lifecycle: set connector 0 id_tag on StartTransaction; on StopTransaction, clear connector 0 only if no other connector is active, otherwise set it to an active connector's id_tag. (33 words) Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
…tion When stopping a transaction on one connector, the station-level id_tag (connector 0) was unconditionally cleared, blanking the charger-wide sensor even when another connector still had an active transaction. Now checks _active_tx for remaining active connectors before clearing. If another connector is still active, connector 0's id_tag is updated to that connector's id_tag instead of being blanked. Addresses CodeRabbit review feedback on PR lbbrhzn#1905. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1905 +/- ##
==========================================
- Coverage 94.92% 94.86% -0.06%
==========================================
Files 12 12
Lines 2954 2960 +6
==========================================
+ Hits 2804 2808 +4
- Misses 150 152 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add test for the case where stopping a transaction on one connector while another connector still has an active transaction preserves the station-level id_tag (connector 0) with the remaining active connector's id_tag instead of clearing it. This covers the 2 missing lines flagged by codecov patch check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
sensor.<cpid>_id_tagstays stale when charger performs local OCPP 1.6 authorization (skips Authorize, sends StartTransaction directly)on_start_transactionsets connector-level id_tag but not charger-level (connector 0)self._metrics[0][cstat.id_tag.value]inon_start_transactionon_stop_transactionfor symmetryFiles changed
custom_components/ocpp/ocppv16.py— update charger-level id_tag inon_start_transactionand clear it inon_stop_transactionTest plan
sensor.<cpid>_id_tagupdates on StartTransactionsensor.<cpid>_id_tagstill updates on normal Authorize -> StartTransaction flowFixes #1871
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests