Skip to content

Make Fronius inverter and controller IDs configurable#239

Merged
MaStr merged 5 commits intomainfrom
copilot/update-fronius-ids-configuration
Dec 1, 2025
Merged

Make Fronius inverter and controller IDs configurable#239
MaStr merged 5 commits intomainfrom
copilot/update-fronius-ids-configuration

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

  • Add configuration parameters to batcontrol_config_dummy.yaml for Fronius inverter_id and controller_id
  • Update FroniusWR class to read inverter_id and controller_id from config with defaults
  • Replace hardcoded '1' inverter ID in get_SOC() method
  • Replace hardcoded '0' controller ID in get_capacity() method
  • Create tests to verify configurable IDs work correctly
  • Run linting and testing
  • Address code review feedback (remove unused import, refactor tests, remove duplicate code)
  • Security scan completed - no vulnerabilities found
  • Add ID verification during initialization
  • Output complete JSON response when verification fails for debugging
  • All tests passing (130 passed)
Original prompt

This section details on the original issue you should resolve

<issue_title>Fronius IDs hardcoded</issue_title>
<issue_description>In fronius.py are multiple ID Numbers hardcoded.
For each subtype (Controler, Inverter) the ID must be configured via batcontrol_config.yaml.

In some cases the IDs are varying, so it needs to be a configuration. The current value needs to be the default.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 1, 2025
Copilot AI and others added 3 commits December 1, 2025 16:54
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
@MaStr
Copy link
Owner

MaStr commented Dec 1, 2025

@copilot please add a verification of the given ids against the urls (do a test call to the method) to the Fronius class. If there is an issue, please create some code, that outputs the complete json result of the corresponding call.

Copilot AI changed the title [WIP] Update Fronius IDs to be configurable via yaml Make Fronius inverter and controller IDs configurable Dec 1, 2025
Copilot AI requested a review from MaStr December 1, 2025 17:03
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

@copilot please add a verification of the given ids against the urls (do a test call to the method) to the Fronius class. If there is an issue, please create some code, that outputs the complete json ...

Added ID verification in commit 0716062. The _verify_fronius_ids() method is now called during initialization and:

  • Makes test calls to the powerflow and storage APIs
  • Verifies the configured IDs exist in the actual responses
  • Logs complete JSON data with available IDs when verification fails
  • Raises RuntimeError with available IDs in the error message

Tests added for both valid and invalid ID scenarios.

@MaStr MaStr marked this pull request as ready for review December 1, 2025 18:14
@MaStr MaStr requested a review from Copilot December 1, 2025 18:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes Fronius inverter and controller IDs configurable instead of hardcoded, addressing issue #238. The implementation includes configuration parameters with sensible defaults, ID verification during initialization, and comprehensive test coverage.

Key Changes:

  • Added configurable fronius_inverter_id (default: '1') and fronius_controller_id (default: '0') parameters
  • Implemented ID verification method that validates configured IDs against actual API responses
  • Updated get_SOC() and get_capacity() methods to use configurable IDs

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
config/batcontrol_config_dummy.yaml Added optional configuration parameters for Fronius inverter_id and controller_id with defaults documented
src/batcontrol/inverter/fronius.py Implemented configurable IDs with string conversion, added _verify_fronius_ids() validation method, updated ID usage in get_SOC() and get_capacity(), minor code formatting improvements
tests/batcontrol/inverter/test_fronius_ids.py Comprehensive test suite covering default values, custom IDs, type conversion, ID verification in methods, and error handling for invalid IDs

@MaStr MaStr merged commit 0d9fd4a into main Dec 1, 2025
26 checks passed
@MaStr MaStr deleted the copilot/update-fronius-ids-configuration branch December 1, 2025 18:27
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.

Fronius IDs hardcoded

3 participants