Skip to content

feat: add support for reading and setting rfid_enabled - #695

Merged
firstof9 merged 1 commit into
mainfrom
feat/support-rfid-enabled
Sep 4, 2026
Merged

feat: add support for reading and setting rfid_enabled#695
firstof9 merged 1 commit into
mainfrom
feat/support-rfid-enabled

Conversation

@firstof9

@firstof9 firstof9 commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Description

Add support for reading and setting the rfid_enabled configuration setting on OpenEVSE chargers.
Both the property and the command method are version-gated to WiFi firmware version 4.1.4 or newer (when RFID support was introduced upstream), raising UnsupportedFeature on older versions.

Fixes #694

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 809263c0-9a6d-404e-9fc2-230273d18a2e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added the feature New Features label Sep 4, 2026

@secondof9 secondof9 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📋 Review Summary

Tip

Review Status: 🟢 APPROVED
Change Type: 🛠️ Refactor
Review Effort: 🟢 Low
Core Impact: Adds RFID-enabled property and command with proper version gating and type safety, following existing patterns in the library.


🚦 CI & Pipeline Health Summary

Check / Workflow Name Status Impact on Review
Analyze (actions) ✅ PASSED CodeQL/static analysis clean
Analyze (python) ✅ PASSED Python static analysis clean
CodeQL ✅ PASSED Security scan passed
build (3.13) ✅ PASSED Python 3.13 build clean
build (3.14) ✅ PASSED Python 3.14 build clean
codecov/patch ✅ PASSED Patch coverage maintained
coverage ✅ PASSED Coverage thresholds met
linkChecker ✅ PASSED Markdown link check passed
prek ✅ PASSED Pre-commit hooks passed
CodeRabbit ⏩ SKIPPED Auto-reviews disabled (org setting)

Note

CI Pipeline Clear: All 12 GitHub Actions workflows completed successfully.


🔍 Architectural Walkthrough

openevsehttp/commands.py
  • set_rfid_enabled (lines 700–720)
    • Follows the established async command pattern: version guard → type validation → POST → response normalization → error mapping → optimistic state update.
    • self._version_check("4.1.4") properly gates the feature to firmware 4.1.4+, raising UnsupportedFeature on older versions — matches set_charge_mode and other similar commands.
    • isinstance(enable, bool) validation guards against accidental int/str input (Python booleans are subclass of int, so isinstance(True, int) would be True — explicit bool check is correct here).
    • The endpoint, payload shape ({"rfid_enabled": enable}), and error message format are consistent with sibling commands (set_service_level, set_mqtt_vehicle_range_miles).
    • State update self._config["rfid_enabled"] = enable is optimistic (no GET round-trip) but acceptable since the firmware has just confirmed the value; consistent with divert_mode.
openevsehttp/properties.py
  • rfid_enabled (lines 572–578)
    • Property returns bool | None to signal "key absent" without raising — caller can distinguish "not supported" (raises UnsupportedFeature) from "supported but unknown" (None).
    • self._config.get("rfid_enabled") is the right defensive read; the parallel command's optimistic write guarantees the key is set after a successful set_rfid_enabled, but on a fresh update() the firmware may omit the key when the feature is configured off in another way.
    • No I/O in getter — purely reflects the cached _config dict. Good.
    • Version guard mirrors current_power's structure.
tests/test_commands.py & tests/test_properties.py
  • Test coverage is comprehensive:
    • test_set_rfid_enabled covers: old-firmware gate (UnsupportedFeature), True success path, False success path, TypeError on non-bool, CommandFailedError on "msg": "error".
    • test_rfid_enabled_property covers: old-firmware raise, supported firmware True, supported firmware False, key absent returns None.
    • The test_simple_properties parametrized table now includes RFID rows for test_charger, test_charger_v2, and test_charger_new — verifying the gate and the value across the fixture matrix.
    • The test does not add a mock_aioclient.post for the TypeError branch (correct — the TypeError fires before any HTTP call), and does add one for the CommandFailedError branch (correct — the request must complete to surface a bad response).
    • # type: ignore[arg-type] on the "invalid" str argument keeps ruff/mypy happy without weakening the test.

🔗 Related / Outside-Diff Context

(Include this section ONLY if addressing files not directly modified in the PR diff)

  • openevsehttp/client.py: Not modified in this PR. Consumers should still rely on the client's update() cycle to refresh _config so the rfid_enabled property stays current; the new property is read-only with respect to the network.
  • Downstream ha-openevse integration (not in this repo): When this version is bumped there, expose the new rfid_enabled as a switch entity backed by set_rfid_enabled and the cached property — the optimistic write means the switch state will reflect the user action immediately without an extra round-trip.

@firstof9
firstof9 merged commit 3c49579 into main Sep 4, 2026
13 checks passed
@firstof9
firstof9 deleted the feat/support-rfid-enabled branch September 4, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add support for reading and setting rfid_enabled

2 participants