Skip to content

Forecast: make solar adjustment a server-side setting#31862

Merged
andig merged 2 commits into
masterfrom
feat/solar-adjusted-setting
Jul 17, 2026
Merged

Forecast: make solar adjustment a server-side setting#31862
andig merged 2 commits into
masterfrom
feat/solar-adjusted-setting

Conversation

@andig

@andig andig commented Jul 17, 2026

Copy link
Copy Markdown
Member

fixes #31832

Promotes the solar forecast adjustment from a browser-local UI preference to a server-side setting, per @naltatis' suggestion in the issue.

The "adjust to real production data" switch was stored only in localStorage (settings_solar_adjusted), so it silently reset whenever a browser dropped site storage, and it was per-client rather than per-installation. Meanwhile the optimizer applied the scale factor unconditionally, so the switch never matched what the optimizer actually did.

  • new solarAdjusted site setting, persisted in the settings table and published to the UI
  • POST /api/solaradjusted/{enable} plus a solarAdjusted MQTT setter
  • optimizer applies the scale factor only when the setting is enabled (effectiveSolarScale)
  • frontend reads the setting from the store instead of localStorage

forecast.solar.scale is still published unconditionally and is now always present, carrying 1 when unscaled. This keeps the percentage label on the toggle meaningful while the setting is off.

Default is off, matching the previous UI default. Note this changes optimizer behaviour: it no longer scales the solar forecast unless the setting is enabled.

Per-forecast granularity (as raised in the issue) is not included, since the scale value is calculated on totals.

🤖 Generated with Claude Code

@andig andig added enhancement New feature or request ux User experience/ interface labels Jul 17, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The changeAdjusted handler now only posts to the API and logs errors, but does not revert the checkbox state on failure, which can leave the UI out of sync with the actual server-side setting; consider either optimistic updating with rollback on error or re-reading solarAdjusted from the store after the request.
  • The new solarAdjusted flag is used in Energyflow.vue via a prop, but it’s only added as a prop to Site.vue here; double-check that all parent components wiring Energyflow pass the correct solarAdjusted value from the store so the forecast scaling behavior stays consistent across views.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `changeAdjusted` handler now only posts to the API and logs errors, but does not revert the checkbox state on failure, which can leave the UI out of sync with the actual server-side setting; consider either optimistic updating with rollback on error or re-reading `solarAdjusted` from the store after the request.
- The new `solarAdjusted` flag is used in `Energyflow.vue` via a prop, but it’s only added as a prop to `Site.vue` here; double-check that all parent components wiring `Energyflow` pass the correct `solarAdjusted` value from the store so the forecast scaling behavior stays consistent across views.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@naltatis

Copy link
Copy Markdown
Member

😆 I have a mostly identical unpublished PR locally.

@andig
andig merged commit a95a559 into master Jul 17, 2026
10 checks passed
@andig
andig deleted the feat/solar-adjusted-setting branch July 17, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"An reale Produktion anpassen" disables itself

2 participants