feat(output): publish aggregated inverter config as a sensor - #4655
Merged
Conversation
The static inputs the prediction runs from - the AC and battery power limits, the system topology and the planning scalars - are aggregated across every inverter in fetch_inverter_data() but were never published. Anything backed by CONFIG_ITEMS already has an input_number/switch/select entity, but these come from apps.yaml or are read off the inverters, so the only way to see them was to turn on debug logging and read the log. Publish them as sensor.<prefix>_inverter_config. The state is the fleet AC inverter limit in kW, which makes the headline number graphable, and the rest of the detail sits in the attributes. Power values are held internally in kW per minute and are converted to kW here to match the existing power sensors, which also carry device_class power. Note the export_limit attribute is the inverter's AC export power cap, which is a different thing to the predbat.export_limit plan sensor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The feature is well-scoped, follows existing publishing patterns, and includes targeted unit-test coverage; only a minor naming nit was found.
Pull request overview
Adds a new Home Assistant sensor to expose Predbat’s aggregated “static prediction inputs” (inverter/battery power caps, topology, and planning scalars) so users can inspect the effective configuration without enabling debug logs.
Changes:
- Publish
sensor.<prefix>_inverter_configfromfetch_inverter_data(), with fleet AC inverter limit as state and detailed configuration as attributes (with internal kW/min → kW conversion). - Document the new sensor and its attributes in the output-data documentation.
- Add a unit test that validates conversion, zero-value publishing, and multi-inverter aggregation via the real
fetch_inverter_data()path; register it inTEST_REGISTRY.
File summaries
| File | Description |
|---|---|
| docs/output-data.md | Documents the new aggregated inverter-config sensor and clarifies attribute meanings. |
| apps/predbat/execute.py | Publishes the new aggregated config sensor each inverter-data refresh cycle. |
| apps/predbat/tests/test_inverter_config_sensor.py | Adds regression coverage for the new sensor’s values and conversions. |
| apps/predbat/unit_test.py | Registers the new test in the unit test runner. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Publishes the static inputs the prediction runs from as a single new entity,
sensor.<prefix>_inverter_config.These values are aggregated across every inverter in
fetch_inverter_data()but were never published. Anything backed byCONFIG_ITEMSalready gets aninput_number/switch/selectentity of its own, but these come fromapps.yamlor are read back off the inverters, so until now the only way to see them was to turn on debug logging and read the log.soc_maxwas the one exception, already exposed as an attribute ofpredbat.soc_kw.The state is the fleet AC inverter limit in kW - the headline number, so it is graphable - with the rest in the attributes:
inverter_limit,export_limit,pv_ac_limitbattery_rate_max_charge,battery_rate_max_charge_dc,battery_rate_max_discharge,battery_rate_max_export,battery_rate_minsoc_max,reservenum_inverters,num_cars,inverter_can_charge_during_exportmetric_standing_charge,forecast_minutes,plan_interval_minutesPower values are held internally in kW per minute and are converted to kW here to match the existing power sensors, which also carry
device_class: power.Published from the end of
fetch_inverter_data(), next topublish_inverter_data(), so it refreshes each cycle and also viaquick_inverter_data_update().Notes
export_limitattribute is the inverter's AC export power cap, which is a different thing to thepredbat.export_limitplan sensor. Called out in the docs.battery_charge_power_curveand friends) and the inverter-state-dependent values (reserve_current,current_charge_limit,charge_rate_now,discharge_rate_now) are deliberately left out - this sensor is the static configuration.Testing
New
test_inverter_config_sensor, registered inTEST_REGISTRY, covering the kW/minute to kW conversion, a zero limit not being dropped, and the aggregation across two stub inverters through the realfetch_inverter_data()path.The test moves every value away from the fixture defaults to prove each is published from the attribute it claims to come from, so it snapshots and restores
my_predbatstate - all tests share onePredBatinstance, and leaking a 48 hourforecast_minutesintomodel_kernelran the C++ kernel off the end of the fixture's 24 hours of step data../run_all --quickpasses (4 slow tests skipped), pre-commit clean.🤖 Generated with Claude Code