Skip to content

Add inverter base class and related interfaces#170

Open
Awienert wants to merge 26 commits intoohAnd:developfrom
Awienert:feature/inverterbaseclass
Open

Add inverter base class and related interfaces#170
Awienert wants to merge 26 commits intoohAnd:developfrom
Awienert:feature/inverterbaseclass

Conversation

@Awienert
Copy link

@Awienert Awienert commented Nov 30, 2025

Draft – Proposal for New Inverter Architecture

This PR is a draft and a proposal introducing a new inverter architecture.

What's new

BaseInverter: shared abstract base class providing a unified interface and reducing duplicate logic.

InverterFactory: creates inverter instances based on config, making it easier to add new inverter types.

Why

cleaner structure

easier extensibility

consistent API for all inverters

@ohAnd ohAnd changed the base branch from main to develop December 7, 2025 19:30
…onius inverter interfaces with unit tests

- Created `inverter_factory.py` to manage inverter instantiation based on configuration.
- Introduced `NullInverter` class for display-only mode and EVCC integration, implementing no-op methods.
- Developed `VictronInverter` class as a stub for future Modbus/TCP integration.
- Added `FroniusLegacy` and `FroniusV2` classes with comprehensive unit tests covering initialization, capabilities, and API interactions.
- Implemented unit tests for `NullInverter`, `VictronInverter`, and `Fronius` inverters to ensure compliance with expected behaviors.
- Established test fixtures for consistent configuration across tests.
@ohAnd
Copy link
Owner

ohAnd commented Dec 14, 2025

@Awienert needed a longer journey ... ;-) - was a lot broken ...

But I followed your approach, but restructered a little...

So please finalize your specific integrations for victron src/interfaces/inverters/victron.py

And if done and tested we can go to develop branch.

@Awienert
Copy link
Author

@ohAnd Sorry for the broken parts — my environment was working 🙂
It is now open for different inverters. I will create the Victron integration ASAP.

@Awienert
Copy link
Author

Awienert commented Feb 4, 2026

@ohAnd Du sag mal kann ich meinen Branches irgendwie in HA testen, möchte das mit Victron Hardware testen ob es funktioniert. Ein reiner Unittest reicht mir hier nicht aus. Ich dachte ich kannd as repository in HA hinzufügen aber das klappt irgendwie nicht.
VG
Andreas

ohAnd added 4 commits February 7, 2026 10:07
Comprehensive refactoring of inverter test structure to improve maintainability,
reduce code duplication, and enforce consistent interface compliance across all
inverter implementations.

Key Changes:
- Created BaseInverterTestSuite with 13 common interface compliance tests
  that all inverter implementations must pass
- Consolidated 3 duplicate Victron test files into single test suite
- Refactored Fronius (legacy/v2) and NullInverter tests to extend base suite
- Removed 6 redundant test methods across test files
- Fixed 330-line code duplication in test_victron_inverter.py
- Reorganized file structure: moved test_base_inverter.py to proper location
  (tests/interfaces → tests/interfaces/inverters/)
- Added comprehensive type hints and resolved all type checking errors:
  * Added pylint disable comments for pytest class attribute patterns
  * Fixed protected-access warnings for _encode_words testing
  * Resolved unused argument warnings in mock functions
  * Achieved pylint rating of 10.00/10 across all test files

Impact:
- Test count optimized: 125 → 134 tests (removed duplicates, added coverage)
- Test files reduced: 7 → 6 files
- All 134 tests passing (0.26s runtime)
- Consistent interface compliance validation across all inverter types
- Improved maintainability through shared test patterns
- Zero type checking errors (Pylance/mypy/pylint clean)

Files Modified:
- tests/interfaces/inverters/base_inverter_tests.py (new)
- tests/interfaces/inverters/test_base_inverter.py (moved & updated)
- tests/interfaces/inverters/test_victron_inverter.py (refactored)
- tests/interfaces/inverters/test_victron.py (consolidated)
- tests/interfaces/inverters/test_fronius_legacy.py (refactored)
- tests/interfaces/inverters/test_fronius_v2.py (refactored)
- tests/interfaces/inverters/test_null_inverter.py (refactored)

Files Removed:
- tests/interfaces/test_base_inverter.py (relocated)
@ohAnd
Copy link
Owner

ohAnd commented Feb 7, 2026

@ohAnd Du sag mal kann ich meinen Branches irgendwie in HA testen, möchte das mit Victron Hardware testen ob es funktioniert. Ein reiner Unittest reicht mir hier nicht aus. Ich dachte ich kannd as repository in HA hinzufügen aber das klappt irgendwie nicht. VG Andreas

Hi Andreas,

hab's mal auf den letzten Stand aus develop hochgezogen und zumindest für "meinen" Bestand erfolgreich getestet. Und die inverter tests versucht ein wenig aufzuräumen ... ;-)

Bzgl. deiner Controls-Tests mit Victron bitte erstmal lokal testen - heisst: einfach in deiner Entwicklungsumgebung (z.B. VS Code) ausführen -> ...\EOS_connect> python.exe .\src\eos_connect.py - natürlich die Config entsprechend gefüllt haben. (siehe auch -> https://ohand.github.io/EOS_connect/developer/index.html#dev-setup)

Als HA addon kann man es ebenso "lokal" also ohne image builds etc innerhalb HA testen -> dazu den Inhalt aus dem Addon z.B. aus develop in den Ordner /addon/eos_connect_test kopieren -> die neue src mit deinen Änderungen reinschieben - config.yaml vom addon in der version hochziehen - das lokale addon wie externe Addons, dann in HA installieren ... -> ist im Netz allgemein gut beschrieben

Aber wenn es lokal bei dir läuft und den Victron mittels Override z.B. sauber ansteuert - dann können wir auch zeitnah in den develop gehen und damit die Basis Pipeline nutzen.

…dd cyclic VE.Bus setpoint keepalive

- Set ESS to External Control (register 2902 = 3)
- Control charge/discharge via VE.Bus AC power setpoints (IDs 37/40/41)
- Implement cyclic keepalive writing to prevent automatic reset to 0W
- Enables deterministic grid import/export control per phase
- Tested on real MultiPlus hardware
…cyclic VE.Bus setpoint keepalive (tested on real hardware)
@ohAnd
Copy link
Owner

ohAnd commented Feb 21, 2026

@Awienert wie weit bist du ;-) ... würde den Umbau des inverter interfaces gerne mit Deiner Integration abschliessen und in den dev übernehmen, damit wir weitere inverter aufnehmen können

…cyclic VE.Bus setpoint keepalive, avoid discharge, allow discharg and force chrage from grid tested on real hardware Victron Multiplus 3 Phase System
@Awienert
Copy link
Author

@ohAnd also Avoid Discharge, allow Charge und Charge from Grid funktionieren soweit. Getestet mit einem 3 Phasen System. Ist nicht ganz einfach mit Victron. Unittests müssen noch überarbeitet werden. Ich werde noch ein paar Worte schreiben wie es mit Victron umgestzt ist. Ich habe den aktuellen WIP gepushed. Eine neue Inverterklasse zu implementiren ist ja unabhäng von der Victron Klasse möglich. Die Basis steht ja.
VG

@ohAnd
Copy link
Owner

ohAnd commented Mar 1, 2026

Eine neue Inverterklasse zu implementiren ist ja unabhäng von der Victron Klasse möglich. Die Basis steht ja.

Jep, aber der Umbau auf die generische Art und Weise ist Teil dieses PRs --- daher wäre es gut, wenn wir hier zum Ende kommen, so dass #207 hier aufsetzen kann - über rebase auf develop, sobald dieser hier auf dev ist ... (hint for -> @chriszero)

sonst müsste erst der "noch unfertige" Victron wieder herausgebaut werden und in einem neuen PR dann final integriert werden...

@chriszero
Copy link

Sobald der PR gemerged ist, kümmere ich mich drum.

chriszero added a commit to chriszero/EOS_connect that referenced this pull request Mar 1, 2026
feat: Port InverterHA to BaseInverter architecture (PR ohAnd#170)

- Add src/interfaces/inverters/inverter_ha.py (BaseInverter subclass)
- Register 'homeassistant' type in InverterFactory and __init__.py
- Add tests/interfaces/inverters/test_inverter_ha.py with
  BaseInverterTestSuite compliance + 52 HA-specific tests (65 total)
- Prepared for rebase onto develop after PR ohAnd#170 merge
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.

3 participants