-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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 listSo here's what happens:
- HA restarts at night (or session times out, or whatever triggers pypvs to reinit)
update()is called, sees empty_supported_features, runsprobe()- Inverters are offline - PVS returns no data or an error
PVSProductionInvertersUpdater.probe()catches the exception, returnsNone- Inverters updater is not added to
self._updaters self._supported_featuresis now set, so probe() will never run again- All future
update()calls skip the inverters entirely - Only fix: restart HA during daytime so probe() runs when inverters are online
Suggested Fixes
A few options:
-
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.
-
Always include inverters updater - Let
update()handle empty/missing data gracefully instead of excluding the updater entirely from the list. -
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."
-
Periodic re-probe - Re-run probe every X hours to catch any devices that were offline during initial discovery.
References
- Enhanced SunPower Discussion #48: Missing Energy production on all inverters but Powermeter shows production smcneece/ha-esunpower#48
- Enhanced SunPower Discussion #49: Need to reboot HA every few days to get PSV5 data collection smcneece/ha-esunpower#49
- Enhanced SunPower Issue Document GET requests also supported #39: [Bug]: No errors, but all power returns 0 while production in full swing smcneece/ha-esunpower#39
Happy to help test any fixes. Thanks for maintaining pypvs!