chore: sync custom_components/growatt_server to clean upstream - #35
Open
johanzander wants to merge 2 commits into
Open
chore: sync custom_components/growatt_server to clean upstream#35johanzander wants to merge 2 commits into
johanzander wants to merge 2 commits into
Conversation
Replaces custom_components/growatt_server wholesale with the current home-assistant/core upstream implementation (commit cd52154), with zero functional additions of our own — this is deliberately just the sync step, so it's reviewable/verifiable on its own before any wanted changes are layered back on top in a follow-up PR. Consequences of syncing to upstream: - Drops the duplicate SPH implementation (sph.py + wiring) in favor of upstream's own canonical version — merged via our own home-assistant/core#165314. - Drops throttle.py (ApiThrottleManager) and its test file/fixture — it was never wired into the real setup flow (no call sites), so this is inert code being removed, not a behavior change. Only deviations from a literal byte-for-byte copy, both genuine bugs in upstream's current source (verified directly against the GitHub API, not just our local clone, to rule out extraction issues on our side): - Two `except ValueError, TypeError:`-style clauses (invalid Python 3 syntax) in coordinator.py. - Missing `from __future__ import annotations` in number.py, sensor/__init__.py, and switch.py, each of which forward-references an entity class in a return-type annotation before its definition — without the future import this raises NameError at import time, before any test can even collect. Reproduced the exact failure standalone to confirm. Both are worth reporting upstream separately; fixing them here is required for "clean" to also mean "importable." Also restores repo-identity manifest.json fields (name, documentation, issue_tracker) that syncing wholesale would otherwise overwrite with upstream's own.
…tches Two pre-existing test-infrastructure bugs, unrelated to the vendor sync, found while trying to actually run this suite (it apparently never has been — no CI workflow runs pytest at all, only a release workflow): 1. Every test file imported from `homeassistant.components.growatt_server` instead of `custom_components.growatt_server`. Direct top-level imports resolve to whichever is actually pip-installed regardless, so this was silently testing the real published PyPI package's growatt_server, not this repo's code, whenever a compatible version happened to be installed. 2. `conftest.py` never wired up pytest-homeassistant-custom-component's `enable_custom_integrations` fixture (it's opt-in, not automatic). This is the piece that actually makes runtime component loading (`hass.config_entries.async_setup`) use this repo's custom_components/growatt_server instead of the real installed package. Confirmed via logs: before this fix, setup logged "Loaded growatt_server from homeassistant.components.growatt_server"; after, "Loaded growatt_server from custom_components.growatt_server". Also updates a handful of `GrowattV1ApiError(...)` test calls to the current required (error_code, error_msg) signature. Result: tests now genuinely exercise this repo's code. Pass count looks worse than before (33/89 vs whatever it was testing the wrong package), which is expected and correct — it's now surfacing real staleness in this suite's snapshots and error-message assertions against the current upstream-synced behavior, not evidence of a regression. That staleness is a separate, sizable follow-up (see PR description), not fixed here.
This was referenced Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure sync step, deliberately split out from what was PR #34 so this base can be verified as clean on its own before any wanted changes go on top (see follow-up PR).
Replaces
custom_components/growatt_serverwholesale with currenthome-assistant/coreupstream (cd52154), plus the minimal test-infrastructure fixes needed to actually validate that.Consequences of syncing to upstream:
sph.py+ wiring) in favor of upstream's own canonical version — merged via your own home-assistant/core#165314.throttle.py(ApiThrottleManager) and its test file/fixture — confirmed it was never wired into the real setup flow (zero call sites for_handle_throttled_setup,ApiThrottleManagernever instantiated anywhere). Removing dead code, not changing behavior.Only deviations from a literal byte-for-byte copy — both genuine bugs in upstream's current source, verified directly against the GitHub API (not just the local clone) to rule out extraction issues:
except ValueError, TypeError:-style clauses (invalid Python 3 syntax) incoordinator.py.from __future__ import annotationsinnumber.py,sensor/__init__.py,switch.py— each forward-references an entity class in a return-type annotation before its definition; without the future import this raisesNameErrorat import time. Reproduced the exact failure standalone to confirm before fixing.Both worth reporting upstream separately.
Also found and fixed, pre-existing and unrelated to the sync itself (discovered because this appears to be the first time this suite has actually been run — there's no CI workflow that runs pytest, only a release workflow):
homeassistant.components.growatt_serverinstead ofcustom_components.growatt_server— silently testing whatever's pip-installed, not this repo's code.conftest.pynever wired uppytest-homeassistant-custom-component'senable_custom_integrationsfixture, sohass.config_entries.async_setuploaded the real installed package at runtime regardless of the test-file import fix above. Confirmed via setup logs before/after.GrowattV1ApiError(...)test calls using an outdated constructor signature.Known NOT fixed here, flagging for visibility:
test_config_flow.pyexpects aCONF_REGIONconstant/config-flow feature that was never implemented — looks like an intendedCONF_URL→region-selection rename that never landed. Real feature work, out of scope for a sync PR. Excluded from the test run below.test_migrate_legacy_*_config) fail because the migration-detection logic is gated onconfig_entry.minor_version < 1, but the tests'MockConfigEntrydoesn't set a version, so it never triggers. Pre-existing test bug, unrelated to anything changed here.tests/snapshots/*.ambr) and several service/switch error-message assertions are stale against upstream's actual current behavior (nicer translated field names, different entity structure) — regenerating them means reviewing a 16k+ line snapshot diff, which needs human eyes, not something to wave through in an agent session.Test plan
ruff checkclean on every changed file.python -m py_compileclean on every changed file.requires-python = \">=3.14.2\", plus currentpytest-homeassistant-custom-component/homeassistant/growattServer): 33 passed, 56 failed (excludingtest_config_flow.py). Confirmed the failures are upstream-sync-driven staleness (stale snapshots/messages) or pre-existing unrelated gaps (above), not regressions from this PR — happy to dig into any specific one you want prioritized.