Skip to content

fix: preserve location-based PV installation saves and merged config - #277

Open
ohAnd wants to merge 1 commit into
developfrom
fix-274-pv_forecast--Location-based-PV-source-selected-but-no-PV-installations-configured
Open

fix: preserve location-based PV installation saves and merged config#277
ohAnd wants to merge 1 commit into
developfrom
fix-274-pv_forecast--Location-based-PV-source-selected-but-no-PV-installations-configured

Conversation

@ohAnd

@ohAnd ohAnd commented Aug 7, 2026

Copy link
Copy Markdown
Owner

This pull request introduces improved support and validation for PV forecast configuration, especially for location-based sources and legacy/unindexed template keys. The main changes ensure that PV installation entries are correctly synthesized from both indexed and unindexed keys, configuration dependencies are validated after merging, and the web wizard transforms payloads as needed. Comprehensive tests are added to cover these scenarios.

PV Forecast Configuration Handling:

  • The _build_pv_forecast function in merger.py now synthesizes a PV installation entry if unindexed template keys (like pv_forecast.name) are found, ensuring backward compatibility with legacy configs. Indexed keys take precedence if both exist. [1] [2]
  • The JavaScript setup wizard (wizard.js) transforms unindexed pv_forecast.* fields into indexed form (pv_forecast.0.*) for location-based sources, ensuring consistency in payloads sent to the backend.

Configuration Validation Improvements:

  • In api.py, cross-field dependency checks are now performed after merging the new config. This ensures that dependencies are validated against the fully updated configuration, including any changes to arrays like pv_forecast. [1] [2]

Testing Enhancements:

  • Added comprehensive tests to verify that:
    • Indexed and unindexed PV forecast keys are handled correctly, and indexed keys take precedence.
    • Saving a location-based PV source without installations is blocked, but succeeds when an installation is provided.
    • The system starts in a valid state when a location-based source and a complete installation are configured. [1] [2] [3]

Other Minor Improvements:

  • Added re import to merger.py for regular expression matching.
  • Ensured test fixtures initialize pv_forecast as an empty list for consistency.

- run dependency checks after merged config rebuild so pv_forecast.0.* entries are visible
- convert wizard PV template keys into indexed payload keys for location-based sources
- synthesize fallback pv_forecast from unindexed template keys in the merger
- add regression tests for API save flow, merged config rebuilding, and PV startup validation
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.

1 participant