Skip to content

Remove legacy hours_list/hour_N sensor formats, keep evcc only (#314)#327

Merged
MaStr merged 3 commits into
mainfrom
claude/implement-evcc-sensor-time-IGFnY
Apr 14, 2026
Merged

Remove legacy hours_list/hour_N sensor formats, keep evcc only (#314)#327
MaStr merged 3 commits into
mainfrom
claude/implement-evcc-sensor-time-IGFnY

Conversation

@MaStr
Copy link
Copy Markdown
Owner

@MaStr MaStr commented Apr 14, 2026

Summary

Closes #314.

Drops the legacy hours_list and hour_N attribute 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 evcc forecast list must now carry all three fields — start, end and value — to be considered valid; entries missing any of them are skipped.

Changes

  • src/batcontrol/forecastsolar/forecast_homeassistant_ml.py
    • Removed _parse_forecast_hours_list and _parse_forecast_hour_n.
    • Renamed _parse_forecast_format1_parse_forecast_evcc.
    • _parse_forecast_evcc_entry now requires start, end and value.
    • _parse_forecast_from_attributes only inspects the evcc forecast list and raises a clearer ValueError when no usable data is present.
    • Updated module docstring to list only the supported sensor.
  • config/batcontrol_config_dummy.yaml — default entity_id now points at sensor.solar_forecast_ml_evcc_solar_prognose.
  • scripts/test_solar_forecast_ha_ml.py — same default ENTITY_ID update.
  • tests/test_forecast_solar_homeassistant_ml.py
    • ha_entity_state fixture rewritten to emit the evcc format (rolling 14-hour window anchored at the current hour in the test timezone).
    • Removed the hours_list / hour_N tests; added coverage asserting those legacy formats now raise ValueError.
    • Updated the "invalid entries skipped" test so a missing end field is treated as invalid.
    • Converted remaining edge-case tests (zero values, large values, cache retrieval) to the evcc format.

Test plan

  • python -m pytest tests/test_forecast_solar_homeassistant_ml.py — 29/29 pass
  • Full suite still green for everything touched by this change (the 14 pre-existing errors in test_production_offset.py, test_core.py, test_inverter_factory.py are unrelated to this PR and reproduce on main).

https://claude.ai/code/session_01CFyp1at1u49PAZf8nVQUim

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.
Copilot AI review requested due to automatic review settings April 14, 2026 19:30
Copy link
Copy Markdown
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 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 forecast entries requiring start, end, and value.
  • 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.

Comment thread src/batcontrol/forecastsolar/forecast_homeassistant_ml.py Outdated
Comment thread tests/test_forecast_solar_homeassistant_ml.py Outdated
Comment thread tests/test_forecast_solar_homeassistant_ml.py Outdated
Comment thread tests/test_forecast_solar_homeassistant_ml.py Outdated
Comment thread tests/test_forecast_solar_homeassistant_ml.py Outdated
Comment thread src/batcontrol/forecastsolar/forecast_homeassistant_ml.py Outdated
claude added 2 commits April 14, 2026 19:35
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.
Copilot AI review requested due to automatic review settings April 14, 2026 19:42
Copy link
Copy Markdown
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/batcontrol/forecastsolar/forecast_homeassistant_ml.py
Comment thread tests/test_forecast_solar_homeassistant_ml.py
@MaStr MaStr merged commit 89802aa into main Apr 14, 2026
17 checks passed
@MaStr MaStr deleted the claude/implement-evcc-sensor-time-IGFnY branch April 14, 2026 19:53
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.

Remove unused sensor result types for pv-ML homeassist sensor

3 participants