Skip to content

Homewizard kWh/P1 meter in pv mode: report 0 instead of a negative #36649

Done

Description

@RutgerLubbers

Problem

For a Homewizard kWh meter (HWE-KWH1) used as a PV meter (type: homewizard, usage: pv), evcc logs:

pv … power: -1316W is negative - check configuration if sign is correct

The negative is expected, not a misconfiguration. The device is a net meter: it reports one signed value, active_power_w, positive when the site imports and negative when it exports. It sits behind the inverter and can't separate gross production from local consumption, so when the house draws more than the inverter produces, the net flow is import and evcc negates it into a phantom negative "production".

Where it comes from

meter/homewizard/connection.go inverts the reading for pv usage:

func (c *Connection) CurrentPower() (float64, error) {
    res, err := c.dataG.Get()
    if c.usage == "pv" {
        return -res.ActivePowerW, err   // import (+1316) -> "production" (-1316)
    }
    return res.ActivePowerW, err
}

The negative then trips the warning in core/site.go → updatePvMeters():

if power < -500 {
    site.log.WARN.Printf("pv %d power: %.0fW is negative - check configuration if sign is correct", i+1, power)
}

This has come up before (#4882, #19996, "HomeWizard P1 meter problem"); the negation was added in #17150 ("Homewizard: Handle PV Usage").

Fix

Cut the inverted reading off at 0 in connection.go, only for usage == "pv":

- 	if c.usage == "pv" {
- 		return -res.ActivePowerW, err
- 	}
+ 	if c.usage == "pv" {
+ 		return max(0, -res.ActivePowerW), err
+ 	}

Same for Powers and Currents, so the per-phase values stay consistent with the total.

This is safe because every place evcc uses PV power for control already floors it at 0:

  • aggregate PV: pvPower := lo.SumBy(mm, max(0, m.Power)) — core/site.go
  • home consumption: homePower := state.gridPower + max(0, state.pvPower) + …
  • green share: greenPower := math.Max(0, state.pvPower) + …

So cutting off at the source doesn't change the charging math. It also doesn't touch production energy or the forecast: TotalEnergy() for pv returns the export registers (TotalPowerExportT1..T4), and the forecast scaling compares daily energy — neither uses this reading. I'll leave TotalEnergy() unchanged. The change is device-scoped: it only affects the homewizard meter in pv mode, and that device is always a net meter.

Trade-off

The per-meter PV value is kept signed on purpose: for a real production source (a real inverter, a CT) a negative is a real event — a hybrid inverter charging its battery, or a CT on the wrong side — and the warning is how that shows up. Cutting off at the source means the homewizard path can no longer tell "net meter (negative expected)" from "inverted CT / wiring fault (negative unexpected)". Since this device is always a net meter, I think that's fine.

Alternative

Alternatively, suppress the is negative warning for this case instead of changing the value. That leaves the per‑meter value at the raw negative, and switching it off for everyone would also silence the warning for meter types where a negative is a real event — so it would need to be scoped to the homewizard net meter, not disabled for all.

Questions

  1. Is there a reason to keep the homewizard pv value signed rather than cut off at 0, given the device is always a net meter?
  2. Is connection.go the right place, or should the cutoff be a config knob (e.g. a "net meter" / "floor PV at 0" flag) so it's explicit rather than device-specific?
  3. Is this homewizard-only, or a general "net meter used as PV" case that other single-direction meters also hit?

I'm happy to help with the patch, in whichever direction the maintainers prefer.

Activity

  1. added
    devices
    on Nov 27, 2026
  2. github-actions commented on Nov 27, 2026

    @github-actions
    Contributor

    Thanks for the detailed write-up. Confirmed: meter/homewizard/connection.go negates ActivePowerW, ActivePowerL1W..L3W and the currents for usage == "pv", and the warning comes from core/site.go. Whether to clamp at the source, add a config option, or scope the warning is a design decision for the maintainers, so I'm not preparing a change here.

    Note that clamping per-phase values independently would not necessarily sum to the clamped total, so that would need care.

    cc @thierolm @andig

    🤖 Generated with Claude Code

  3. andig commented on Nov 27, 2026

    @andig
    Member

    positive when the site imports and negative when it exports

    Then it's a grid meter and not a pv meter!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    devices

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions