Skip to content

Bug: Inverters permanently "lost" when probe() runs at night #42

@smcneece

Description

@smcneece

The Problem:

If pypvs initializes (or reinitializes) at night when inverters are offline, it never discovers them - and never recovers until a full HA restart during daytime.

We've had multiple users report this in the Enhanced SunPower integration, as well as I know users of the SunStrong integration have seen the issue.

  • Restart HA at night → inverters show 0 power forever (until next restart)
  • Restart HA during the day → everything works fine
  • Some users see it after 3-4 days (likely session timeout triggering reinit)

Root Cause

I traced through the pypvs code and think I found the issue in pvs.py:

The probe() method only runs once - when self._supported_features is empty:

async def update(self) -> PVSData:
    if not self._supported_features:  # Only runs once!
        await self.probe()

    for updater in self._updaters:
        await updater.update(data)

And in production_inverters.py, the probe catches exceptions and returns None:

async def probe(self, discovered_features) -> SupportedFeatures | None:
    try:
        await self._request_vars(VARS_MATCH_INVERTERS)
    except ENDPOINT_PROBE_EXCEPTIONS as e:
        _LOGGER.debug("No inverters found...")
        return None  # Not added to updaters list

So here's what happens:

  1. HA restarts at night (or session times out, or whatever triggers pypvs to reinit)
  2. update() is called, sees empty _supported_features, runs probe()
  3. Inverters are offline - PVS returns no data or an error
  4. PVSProductionInvertersUpdater.probe() catches the exception, returns None
  5. Inverters updater is not added to self._updaters
  6. self._supported_features is now set, so probe() will never run again
  7. All future update() calls skip the inverters entirely
  8. Only fix: restart HA during daytime so probe() runs when inverters are online

Suggested Fixes

A few options:

  1. Re-probe when inverter count is 0 during daytime - If we know it's daytime (sun is up) and we're seeing 0 inverters, something's wrong. Re-run probe.

  2. Always include inverters updater - Let update() handle empty/missing data gracefully instead of excluding the updater entirely from the list.

  3. Don't make permanent decisions at night - If probe fails to find inverters, maybe flag it as "needs re-probe" rather than "inverters don't exist."

  4. Periodic re-probe - Re-run probe every X hours to catch any devices that were offline during initial discovery.

References

Happy to help test any fixes. Thanks for maintaining pypvs!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions