Home Assistant custom integration that keeps net grid power at 0 W by auto-controlling PV inverter output limits via a self-tuning PID controller.
- Tests:
python -m pytest tests/ -v - Lint:
python -m ruff check custom_components/ tests/ - Type check:
python -m mypy custom_components/ - Install deps:
pip install -r requirements_test.txt(if present) orpip install pytest-homeassistant-custom-component
custom_components/zero_grid_controller/— integration codetests/— pytest tests (asyncio_mode=auto)manifest.json— domain=zero_grid_controller, version=0.1.0hacs.json— HACS metadata
coordinator.py—DataUpdateCoordinatorsubclass, runs every 5 s; HA lifecycle glue onlycontrol_engine.py— stateful pure control logic (PID, EWM, distribution, hysteresis); no HA importssensor_reader.py—SensorReaderprotocol for decoupled HA state accesspid.py— discrete PID with anti-windup and per-cycle integrator freezecalibrator.py— async step-response calibrationconfig_flow.py— wizard + options + array/battery/load subentry flowsarray.py—ArrayConfigdataclass (one per PV array subentry)battery.py—BatteryConfigdataclass (one per battery subentry)load.py—LoadConfigdataclass (one per controllable load subentry)
- Use
async deffor all platform setup and I/O operations _LOGGER = logging.getLogger(__name__)in every module- Config entries via
config_flow.py; sub-entries viasub_entries=true - Type hints required on all public functions (mypy strict)
- Ruff: line-length=88, rules E/F/W/I/UP/B/C4/SIM, E501 ignored
- Framework:
pytest-homeassistant-custom-component - Use
hassfixture forHomeAssistantinstance - Use
MockConfigEntryfrompytest_homeassistant_custom_component.common - Add
auto_enable_custom_integrationsautouse fixture per test module
- List of modified files
- Test error messages and tracebacks
- Current domain name and version