Skip to content

Loadpoint: expected power for switch devices instead of min/max current - #35799

Open
naltatis wants to merge 5 commits into
masterfrom
fix/switch-device-expected-power
Open

naltatis wants to merge 5 commits into
masterfrom
fix/switch-device-expected-power

Conversation

@naltatis

@naltatis naltatis commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

fixes #35656, part of #19753

Loadpoints on chargers without current control (switchdevice) configure one expected power instead of phases and min/max current. For these, min current already is the "draw when on" and max only feeds estimates, so one value covers both.

  • Loadpoint: effectiveMaxCurrent follows min current for switch devices. Fixes plan duration and PV reserve computed with the 16 A default.
  • Loadpoint: setters keep min ≤ max for switch devices, raising min raises max and a lower max is clamped instead of rejected, since the config modal posts the stored max alongside the new min on every save.
  • Optimizer: switch devices enter as fixed loads, CMin == CMax, instead of a 0 to 3.7 kW range.
  • Config UI: "Expected power" in W with "≈ x A" hint replaces the electrics section. Stored as minCurrent, no new field or migration.
  • Loadpoint settings: currents section hidden for switch devices. A per-device value, not a runtime setting.
  • PropertyField: Int fields block decimal separator keys.
screenshot-20261104_150120

Follow-up: docs rename.

🤖 Generated with Claude Code

@naltatis naltatis added enhancement New feature or request ux User experience/ interface heating Heating labels Nov 4, 2026
@github-actions github-actions Bot added the devices Specific device support label Nov 4, 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 found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="core/loadpoint_effective.go" line_range="220-221" />
<code_context>
 // effectiveMaxCurrent returns the effective max current
 func (lp *Loadpoint) effectiveMaxCurrent() float64 {
+	// no current control, min current is the expected draw
+	if lp.chargerHasFeature(api.SwitchDevice) {
+		return lp.effectiveMinCurrent()
+	}
+
</code_context>
<issue_to_address>
**Power-limited maximum is discarded**

When a switch-device charger exposes a power limiter whose reported minimum is below its maximum, a switch device also implements `api.PowerLimiter` and reports different minimum and maximum powers, so `effectiveMaxCurrent` returns the minimum-demand current and skips the existing maximum-power cap; plan durations and load estimates then use the lower demand instead of the device’s maximum power.

For switch devices with a power limiter, derive the effective maximum from the limiter’s maximum power rather than returning the effective minimum.
</issue_to_address>

### Comment 2
<location path="core/loadpoint_effective.go" line_range="220" />
<code_context>
 // effectiveMaxCurrent returns the effective max current
 func (lp *Loadpoint) effectiveMaxCurrent() float64 {
+	// no current control, min current is the expected draw
+	if lp.chargerHasFeature(api.SwitchDevice) {
+		return lp.effectiveMinCurrent()
+	}
</code_context>
<issue_to_address>
**Switch loads remain variable in optimizer**

When a switch device supports phase switching and retains an automatic phase configuration, `EffectiveMinPower` still uses `minActivePhases`, while `EffectiveMaxPower` uses `maxActivePhases`; for a switch device with automatic phase switching, those differ (1 vs. 3), so the optimizer receives different `CMin` and `CMax` instead of a fixed load.

Ensure switch devices use the same phase count for effective minimum and maximum power, or explicitly set optimizer `CMin` equal to `CMax` for them.
</issue_to_address>

### Comment 3
<location path="core/loadpoint_api.go" line_range="865" />
<code_context>
 	if current > lp.maxCurrent {
-		return errors.New("min current must be smaller or equal than max current")
+		if lp.chargerHasFeature(api.SwitchDevice) {
+			lp.setMaxCurrent(current)
+		} else {
+			return errors.New("min current must be smaller or equal than max current")
</code_context>
<issue_to_address>
**Stale maximum survives interrupted update**

When the process exits after `lp.setMaxCurrent` persists the raised value but before `lp.setMinCurrent` persists the expected value, `lp.setMaxCurrent` has already published and persisted the raised maximum while `lp.setMinCurrent` has not run, so a restart loads a higher maximum with the old minimum; if the charger is later changed from a switch device to a controllable charger, the stale maximum becomes an active limit.

Persist the paired min/max update atomically, or add recovery logic that reconciles the pair on startup.
</issue_to_address>

### Comment 4
<location path="assets/js/components/Config/LoadpointModal.vue" line_range="922" />
<code_context>
+			set(power: number) {
+				const current = powerToCurrent(
+					power,
+					this.minPhases,
+					this.voltage,
+					this.gridConnection
</code_context>
<issue_to_address>
**Expected power uses wrong phase count**

When a switch device’s configured phase count is unset or does not match its actual phases, `expectedPower` passes `minPhases` to `powerToCurrent`, so an unset count defaults to one and a stale count of three is used even for a single-phase device. `values.minCurrent` is then wrong, and the displayed estimate and effective power no longer match the entered power.

Use the switch device’s actual active phase count when converting expected power to `minCurrent`.

Also at `core/loadpoint_effective.go:220-221`.
</issue_to_address>

### Comment 5
<location path="assets/js/components/Config/LoadpointModal.vue" line_range="250-254" />
<code_context>
+								<PropertyField
+									id="loadpointExpectedPower"
+									v-model="expectedPower"
+									type="Int"
+									unit="W"
+									size="w-25 w-min-200"
+									required
+									@input="updateExpectedPower"
+								/>
+								<span class="evcc-gray text-nowrap power-hint">
</code_context>
<issue_to_address>
**Zero expected power is ignored**

When a user submits 0 W for expected power, `DynamicConfig.Apply` treats `minCurrent == 0` as unset and skips `SetMinCurrent`, so the previous expected draw remains in effect after saving.

Ensure submitting 0 W clears the expected draw instead of treating it as an omitted value.

Also at `assets/js/components/Config/LoadpointModal.vue:926`.
</issue_to_address>

### Comment 6
<location path="assets/js/components/Config/LoadpointModal.vue" line_range="243" />
<code_context>
+						<FormRow
+							v-if="chargerIsSwitchDevice"
+							id="loadpointExpectedPower"
+							:label="$t('config.loadpoint.expectedPowerLabel')"
+							:help="$t('config.loadpoint.expectedPowerHelp')"
+						>
</code_context>
<issue_to_address>
**Expected-power term lacks glossary entry**

The new “Expected power” label names the switch device's expected draw, but that concept has no entry in the glossary, leaving the user-facing terminology without an agreed translation for future strings.

Add a glossary entry for the expected-power concept and its translations.
</issue_to_address>

Linked issues

#35656 maxcurrent bei Switchsocket sollte gleich mincurrent gesetzt werden · 1 of 1 met

# Requirement Status Notes
1 Use the minimum current as the maximum current for switch devices so calculations do not use the default 16 A. ✅ Met For switch devices, effectiveMaxCurrent follows effectiveMinCurrent; plan power uses the effective maximum, and the setters raise or clamp the stored maximum when needed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread core/loadpoint_effective.go Resolved
Comment thread core/loadpoint_effective.go Resolved
Comment thread core/loadpoint_api.go Resolved

@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.

Linked issues

#35656 maxcurrent bei Switchsocket sollte gleich mincurrent gesetzt werden · 0 of 1 met

# Requirement Status Notes
1 Set switch-device maxcurrent equal to mincurrent so calculations do not use the default 16 A. 🟡 Partly met Effective maximum current now follows effective minimum current, but the stored maxcurrent remains 16 A when mincurrent is lower.

Comment thread core/loadpoint_api.go Resolved
@naltatis
naltatis requested a review from andig November 11, 2026 14:18
@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 4613843

#35656 maxcurrent bei Switchsocket sollte gleich mincurrent gesetzt werden · 1 of 1 met

# Requirement Status Notes
1 For switch sockets, use minCurrent as the effective maxCurrent so estimates do not use the default 16 A. ✅ Met effectiveMaxCurrent now returns effectiveMinCurrent for switch devices, and the setters keep the min/max relationship valid when values are changed.

@andig

andig commented Nov 13, 2026

Copy link
Copy Markdown
Member

Config UI: "Expected power" in W with "≈ x A" hint replaces the electrics section. Stored as minCurrent, no new field or migration.

Taking phases into account? We need to decide if min==max should be enforced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support enhancement New feature or request heating Heating ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

maxcurrent bei Switchsocket sollte gleich mincurrent gesetzt werden

2 participants