Remove legacy hours_list/hour_N sensor formats, keep evcc only (#314)#327
Merged
Conversation
Drop the legacy hours_list and hour_N attribute parsers from the HA Solar Forecast ML provider and keep only the evcc Solar-Prognose format, which is the only variant we want to support going forward (0.8.0). Entries in the evcc 'forecast' list must now carry all three fields — start, end and value — to be considered valid; entries missing any of them are skipped. Also update the dummy config and standalone test script to point at the evcc sensor (sensor.solar_forecast_ml_evcc_solar_prognose), and adjust the test suite to exercise the evcc format exclusively.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes legacy HomeAssistant Solar Forecast ML sensor attribute formats (hours_list, hour_N) and keeps only the evcc Solar-Prognose forecast list format, aligning the provider with the planned 0.8.0 support scope.
Changes:
- Simplified HA ML forecast parsing to only accept evcc
forecastentries requiringstart,end, andvalue. - Updated test suite to generate and validate evcc-format forecasts and to assert legacy formats now fail.
- Updated default entity IDs in the dummy config and the HA test script to the evcc sensor.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/batcontrol/forecastsolar/forecast_homeassistant_ml.py |
Drops legacy parsers and enforces evcc-only parsing with clearer error messaging. |
tests/test_forecast_solar_homeassistant_ml.py |
Reworks fixtures/tests to evcc format and adds assertions for legacy-format rejection. |
config/batcontrol_config_dummy.yaml |
Updates example entity_id to evcc sensor. |
scripts/test_solar_forecast_ha_ml.py |
Updates default ENTITY_ID to evcc sensor. |
strftime('%z') renders the offset as '+0200' (no colon), which is
rejected by datetime.fromisoformat() on Python 3.9 and 3.10. Switch the
test fixtures to datetime.isoformat(), which emits '+02:00' with the
colon and works on all supported Python versions.
- Replace em dashes / arrows introduced by this PR with ASCII equivalents to comply with the repo's ASCII-only rule for code/logs/docs. - Freeze the provider module's datetime.now inside the ha_entity_state fixture so the fixture and the parser see the same reference hour, removing potential flakiness at hour/DST boundaries. - Simplify the "missing end" assertion to assert forecast[2] == 0.0 directly; the zero-fill guarantees the key is present.
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.
Summary
Closes #314.
Drops the legacy
hours_listandhour_Nattribute parsers from the HomeAssistant Solar Forecast ML provider and keeps only the evcc Solar-Prognose format, which is the only variant we want to support going forward (0.8.0). Entries in the evccforecastlist must now carry all three fields —start,endandvalue— to be considered valid; entries missing any of them are skipped.Changes
src/batcontrol/forecastsolar/forecast_homeassistant_ml.py_parse_forecast_hours_listand_parse_forecast_hour_n._parse_forecast_format1→_parse_forecast_evcc._parse_forecast_evcc_entrynow requiresstart,endandvalue._parse_forecast_from_attributesonly inspects the evccforecastlist and raises a clearerValueErrorwhen no usable data is present.config/batcontrol_config_dummy.yaml— defaultentity_idnow points atsensor.solar_forecast_ml_evcc_solar_prognose.scripts/test_solar_forecast_ha_ml.py— same defaultENTITY_IDupdate.tests/test_forecast_solar_homeassistant_ml.pyha_entity_statefixture rewritten to emit the evcc format (rolling 14-hour window anchored at the current hour in the test timezone).ValueError.endfield is treated as invalid.Test plan
python -m pytest tests/test_forecast_solar_homeassistant_ml.py— 29/29 passtest_production_offset.py,test_core.py,test_inverter_factory.pyare unrelated to this PR and reproduce onmain).https://claude.ai/code/session_01CFyp1at1u49PAZf8nVQUim