Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ grouped under `Unreleased` until that changes.

### Changed

- goodwe is now a pinned fork (0.4.10 + upstream PR #156 + UDP fixes): a
late inverter response to an earlier attempt is accepted instead of lost,
each retry waits longer (1, 1.5, 2.25, then 3 s), and stray datagrams no
longer trigger instant retries. The inverter timeout went from 1 s to
0.6 s (replies take at most ~0.3 s, and a slower one is still accepted)
and retries per request from 60 to 5, so a dead link fails after ~8 s
instead of stalling the poll loop for a minute. Run
`pip install -r requirements.txt` after pulling.
- Optional off-grid shadow scan guard (off by default):
`OFF_GRID_SHADOW_SCAN_GUARD=on` turns shadow scan off while the inverter is
off-grid and restores the previous value after the grid has been up for
Expand Down
12 changes: 11 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
# noise (see docs/superpowers/notes/2026-09-08-backup-threshold-investigation.md -
# a flat constant for now, pending the adaptive-threshold formula explored
# there).
# Replies take 90-300 ms (by size), so a lost packet is noticed after
# 0.6 s instead of 1 s; a reply slower than that is still accepted, since
# the forked goodwe keeps the socket open across retries. Each retry waits
# longer (0.6, 0.9, 1.35, then 1.8 s), so 5 retries give up after ~8 s -
# longer than the loss bursts seen on the Wi-Fi link (a few s), short
# enough that a dead link doesn't stall the 1 Hz loop (and control writes)
# for minutes before reconnecting.
INVERTER_TIMEOUT_S = 0.6
INVERTER_RETRIES = 5
BACKUP_ACTIVE_THRESHOLD_W = float(os.environ.get('BACKUP_ACTIVE_THRESHOLD_W', 35))
MQTT_HOST = os.environ.get('MQTT_HOST') or None
MQTT_PORT = int(os.environ.get('MQTT_PORT', 1883))
Expand Down Expand Up @@ -270,7 +279,8 @@ async def _get_inverter_data_with_retry(self):

async def _get_inverter_data(self):
logger.info(f'Connecting to {self._inverter_address}')
self._inverter = await goodwe.connect(self._inverter_address, family='ET', timeout=1, retries=60)
self._inverter = await goodwe.connect(self._inverter_address, family='ET', timeout=INVERTER_TIMEOUT_S,
retries=INVERTER_RETRIES)
logger.info(f'Connected to the inverter')
if control_runtime_instance is not None:
control_runtime_instance.attach(self._inverter)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ contourpy==1.3.3
cycler==0.12.1
Flask==3.1.3
fonttools==4.64.0
goodwe==0.4.10
# Fork of 0.4.10 + upstream PR #156 + late-response/retry-timeout fixes (branch udp-late-replies)
goodwe @ git+https://github.com/piomar123/goodwe.git@v0.4.10-piomar.1
holidays==0.83
idna==3.19
itsdangerous==2.2.0
Expand Down
Loading