Skip to content

Allow empty GetConfiguration to retrieve all keys#1927

Open
rishabhvaish wants to merge 1 commit intolbbrhzn:mainfrom
rishabhvaish:fix/allow-empty-get-configuration-1907
Open

Allow empty GetConfiguration to retrieve all keys#1927
rishabhvaish wants to merge 1 commit intolbbrhzn:mainfrom
rishabhvaish:fix/allow-empty-get-configuration-1907

Conversation

@rishabhvaish
Copy link

@rishabhvaish rishabhvaish commented Mar 23, 2026

The get_configuration service required ocpp_key as a mandatory field, but per OCPP 1.6 spec (section 7.22), sending a GetConfiguration request without any keys should return all configuration keys from the charge point. This was already partially supported — the v1.6 get_configuration method correctly sent an empty GetConfiguration() call when key was blank — but the service schema rejected requests without ocpp_key, and the response handler only returned the first key's value instead of all of them.

I've made ocpp_key optional in the service schema and updated the v1.6 handler to return a dict of all key-value pairs when no specific key is requested. When a key is provided, behavior is unchanged.

Fixes #1907

Summary by CodeRabbit

Release Notes

  • New Features

    • Added capability to retrieve all OCPP configuration keys at once by leaving the key parameter empty in the get_configuration service (v1.6 only).
  • Bug Fixes

    • Made the OCPP key parameter optional for the get_configuration service, enabling more flexible configuration queries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b111ab81-fc62-44a3-b212-ed69c8eb496c

📥 Commits

Reviewing files that changed from the base of the PR and between a3af550 and f4072a9.

📒 Files selected for processing (5)
  • custom_components/ocpp/api.py
  • custom_components/ocpp/chargepoint.py
  • custom_components/ocpp/ocppv16.py
  • custom_components/ocpp/services.yaml
  • tests/test_additional_charge_point_v16.py

📝 Walkthrough

Walkthrough

This change enables sending an empty GetConfiguration request to retrieve all configuration keys at once. The ocpp_key parameter is made optional across the API schema, service definition, and handler logic. When empty, the method returns all configuration entries as a dictionary; when specified, it returns the single value as before.

Changes

Cohort / File(s) Summary
Schema and Configuration Updates
custom_components/ocpp/api.py, custom_components/ocpp/services.yaml
Made ocpp_key optional in the service schema and request handler; added default empty string handling to allow empty requests that retrieve all configuration keys.
Return Type Updates
custom_components/ocpp/chargepoint.py
Extended get_configuration return type annotation to str | dict | None to accommodate both single values and bulk configuration responses.
Implementation Logic
custom_components/ocpp/ocppv16.py
Enhanced get_configuration to build and return a dictionary mapping all configuration entry keys to their values when key == ""; preserves existing single-value behavior when a specific key is provided.
Test Coverage
tests/test_additional_charge_point_v16.py
Updated test expectations to verify dictionary response containing multiple configuration entries when called with an empty key.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • lbbrhzn

Poem

🐰 A rabbit hops through config keys,
No longer bound by one reply,
Empty requests now set us free,
All values gathered, standing by! 🔧✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Allow empty GetConfiguration to retrieve all keys' directly and clearly describes the main change—enabling empty GetConfiguration requests to return all configuration keys.
Linked Issues check ✅ Passed The PR fully addresses issue #1907 by making ocpp_key optional, allowing empty GetConfiguration requests to return all configuration keys and values.
Out of Scope Changes check ✅ Passed All changes are directly related to enabling empty GetConfiguration requests: schema updates, handler logic, return type annotations, and corresponding test updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Send an Empty GetConfiguration Message

1 participant