-
-
Notifications
You must be signed in to change notification settings - Fork 106
Make remote id tag configurable and reset on Home Assistant transaction start #1832
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces configuration-driven remote ID tag management for the OCPP charging point. A new configuration option enables specifying a remote ID tag, which is retrieved by a new method that falls back to random generation if not configured. Upon successful transaction start, the stored remote ID tag updates the corresponding metric. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
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)
297-303: Replace unused loop variable with underscore.The loop variable
ion line 302 is unused and should be replaced with_per Python convention.🔎 Apply this diff to follow Python conventions:
def get_remote_id_tag(self) -> str: """Get remote id tag from configuration.yaml or generate a random 20 char one.""" config = self.hass.data[DOMAIN].get(CONFIG, {}) alphabet = string.ascii_uppercase + string.digits return config.get( - CONF_REMOTE_ID_TAG, "".join(secrets.choice(alphabet) for i in range(20)) + CONF_REMOTE_ID_TAG, "".join(secrets.choice(alphabet) for _ in range(20)) )
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
config/configuration.yaml(1 hunks)custom_components/ocpp/chargepoint.py(3 hunks)custom_components/ocpp/const.py(1 hunks)custom_components/ocpp/ocppv16.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
custom_components/ocpp/ocppv16.py (2)
custom_components/ocpp/chargepoint.py (2)
value(85-87)value(90-92)tests/test_charge_point_v16.py (2)
value(4252-4258)value(4261-4263)
🔇 Additional comments (5)
config/configuration.yaml (1)
50-50: LGTM!The new configuration option is properly formatted and demonstrates the feature with a clear test value.
custom_components/ocpp/const.py (1)
31-31: LGTM!The new constant follows the existing naming convention and is properly positioned in the file.
custom_components/ocpp/chargepoint.py (2)
54-54: LGTM!The import is correctly added and follows the existing pattern.
284-284: LGTM!The refactoring to use
get_remote_id_tag()improves maintainability and enables configuration-driven behavior.custom_components/ocpp/ocppv16.py (1)
629-630: Verify connector-specific metric update in remote transaction start.The
start_transactionmethod (line 621) accepts aconnector_idparameter but updates the global metricself._metrics[0][cstat.id_tag.value]rather than connector-specific metrics. However, theon_start_transactionhandler (line 1084) uses the connector_id in its metric key:self._metrics[(connector_id, cstat.id_tag.value)].Clarify the design intent: Is the global metric update at line 630 intentional (tracking the remote_id_tag used globally across all connectors) or should it be changed to
self._metrics[(connector_id, cstat.id_tag.value)]to track per-connector remote start operations? This matters especially if the same charge point has multiple connectors and you callstart_transactionwith different connector IDs.
remote_id_tagas configuration option in configuration.yamlId Tagwas set by using wall box, it was not set back to_remote_id_tagwhen using home assistant to start afterwardSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.