Skip to content

Site: add smart feed-in disable (aka zero feed-in) #21839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

andig
Copy link
Member

@andig andig commented Jun 14, 2025

Fix #21747, depends on #21813

Disable solar feed-in when feed-in becomes expensive for the user (i.e. network restriction visible due to feed-in tariff). Implemented by restricting the PV inverter to 0W feed-in power.
Requires supported inverter.

TODO

/cc @Maschga wenn Du magst könntest Du hier branchen und einen PR für RCT erstellen und testen.

@andig andig added enhancement New feature or request needs documentation Triggers issue creation in evcc-io/docs labels Jun 14, 2025
@andig andig marked this pull request as draft June 14, 2025 09:52
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @andig - I've reviewed your changes - here's some feedback:

  • The new rateAt helper ignores its t time.Time parameter and always uses time.Now()—update it to use the passed‐in time for consistency and testability.
  • The HTTP endpoints for smart-feed-in disabling (e.g. /smartfeedindisablelimit) use inconsistent casing compared to other routes—standardize on one naming convention for clarity.
  • There’s a lot of duplicated logic between smart-cost and smart-feed-in handling—consider extracting shared behaviour into a common helper to reduce code duplication.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new rateAt helper ignores its `t time.Time` parameter and always uses `time.Now()`—update it to use the passed‐in time for consistency and testability.
- The HTTP endpoints for smart-feed-in disabling (e.g. `/smartfeedindisablelimit`) use inconsistent casing compared to other routes—standardize on one naming convention for clarity.
- There’s a lot of duplicated logic between smart-cost and smart-feed-in handling—consider extracting shared behaviour into a common helper to reduce code duplication.

## Individual Comments

### Comment 1
<location> `core/site_tariffs.go:177` </location>
<code_context>
+	return site.GetTariff(usage).Type() != api.TariffTypePriceStatic
+}
+
+func rateAt(rates api.Rates, t time.Time) (api.Rate, error) {
+	rate, err := rates.At(time.Now())
+	if len(rates) > 0 && err != nil {
</code_context>

<issue_to_address>
rateAt ignores its time parameter and always uses time.Now()

The function should use the provided `t` parameter in `rates.At` to ensure correct evaluation at the intended time.
</issue_to_address>

### Comment 2
<location> `core/loadpoint/mock.go:925` </location>
<code_context>
 	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSmartCostLimit", reflect.TypeOf((*MockAPI)(nil).SetSmartCostLimit), limit)
 }

+// SetSmartFeedinLimit mocks base method.
+func (m *MockAPI) SetSmartFeedinLimit(limit *float64) {
+	m.ctrl.T.Helper()
</code_context>

<issue_to_address>
Avoid manual edits in a generated mock file

Regenerate the mock with mockgen to include the new methods, rather than editing the file manually.

Suggested implementation:

```golang

```

After removing the manual edit, you must run `mockgen` to regenerate `core/loadpoint/mock.go` with the updated interface that includes `SetSmartFeedinLimit`. This will ensure the mock is up-to-date and correctly generated.
</issue_to_address>

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.

@andig andig requested a review from premultiply June 14, 2025 10:14
@andig
Copy link
Member Author

andig commented Jun 27, 2025

@naltatis kannst du mit dem Merge helfen?

@andig
Copy link
Member Author

andig commented Jun 27, 2025

UI pack ich nicht…

@naltatis
Copy link
Member

@andig resolve the conflict - mostly. I've left one for you :D

@naltatis
Copy link
Member

do we need to control batteries or only pv? Batteries shouldn't feed-in, so no?

yes, for me it's an pv feature. Requirements for showing it in the ui: dynamic tariff + controllable pv inverter
Makes placement of the feature a little tricky since it does not fit in the existing "Battery settings" model. Guess we need a dedicate "Solar settings" modal only for this feature.

@andig
Copy link
Member Author

andig commented Jul 2, 2025

@naltatis back over to you?

@github-actions github-actions bot added the stale Outdated and ready to close label Jul 9, 2025
@naltatis naltatis self-assigned this Jul 9, 2025
@naltatis naltatis removed the stale Outdated and ready to close label Jul 9, 2025
@github-actions github-actions bot added the stale Outdated and ready to close label Jul 16, 2025
@github-actions github-actions bot removed the stale Outdated and ready to close label Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs documentation Triggers issue creation in evcc-io/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: zero feed in (when energy prices are negative)
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy