Skip to content

Add SPH inverter support to Growatt Server integration#165314

Draft
johanzander wants to merge 8 commits intohome-assistant:devfrom
johanzander:feature/growatt-sph-support
Draft

Add SPH inverter support to Growatt Server integration#165314
johanzander wants to merge 8 commits intohome-assistant:devfrom
johanzander:feature/growatt-sph-support

Conversation

@johanzander
Copy link
Contributor

@johanzander johanzander commented Mar 11, 2026

Proposed change

Adds support for Growatt SPH (Storage Power Hybrid) inverters via the Open API V1 (token authentication). SPH devices are identified as device type 5 in the V1 API.

Includes:

  • 34 sensor entities (battery SOC/voltage, PV power/voltage, energy totals, grid frequency, temperatures, import/export, last update)
  • Reuses existing mix_* translation keys where semantically equivalent
  • 4 new services: write_ac_charge_times, write_ac_discharge_times, read_ac_charge_times, read_ac_discharge_times for scheduling battery charge/discharge time periods on SPH devices

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Adds support for Growatt SPH (Storage Power Hybrid) inverters via the
Open API V1 (token authentication). SPH devices are identified as
device type 5 in the V1 API.

Includes:
- 34 sensor entities (battery SOC/voltage, PV power/voltage, energy
  totals, grid frequency, temperatures, import/export, last update)
- Reuses existing mix_* translation keys where semantically equivalent
- 4 new services: write_ac_charge_times, write_ac_discharge_times,
  read_ac_charge_times, read_ac_discharge_times for scheduling battery
  charge/discharge time periods on SPH devices

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Growatt SPH (Storage Power Hybrid) inverter support to the Growatt Server integration when using the Open API V1 (token authentication), including new SPH sensors and battery scheduling services.

Changes:

  • Recognize V1 device type 5 as sph and initialize coordinators/sensors for SPH devices.
  • Add SPH sensor entity definitions and corresponding translation strings.
  • Add 4 new SPH services for reading/writing AC charge/discharge time periods, with service UI selectors and icons.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/components/growatt_server/test_init.py Updates unsupported-device-type test now that V1 type 5 is supported.
homeassistant/components/growatt_server/init.py Maps Open API V1 device types to include SPH and allows SPH devices in setup.
homeassistant/components/growatt_server/coordinator.py Fetches SPH data via V1 APIs and adds SPH read/write scheduling helpers.
homeassistant/components/growatt_server/services.py Adds coordinator lookup generalized by device type and registers new SPH services.
homeassistant/components/growatt_server/services.yaml Defines UI selectors/fields for the new SPH services.
homeassistant/components/growatt_server/strings.json Adds SPH sensor translation keys and service strings.
homeassistant/components/growatt_server/icons.json Adds icons for the new SPH services.
homeassistant/components/growatt_server/sensor/init.py Wires SPH sensor descriptions into platform setup.
homeassistant/components/growatt_server/sensor/sph.py Introduces SPH sensor entity descriptions (34 sensors).

- Add SPH AC charge/discharge time services (write/read)
- Fix SPH coordinator: add timestamp parsing error handling
- Fix SPH coordinator: preserve upstream service architecture
- Add comprehensive tests for SPH sensors and services
- Update strings.json with SPH service descriptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

johanzander and others added 4 commits March 11, 2026 13:58
- Validate that period start/end are always provided together in SPH
  write services, raising ServiceValidationError instead of KeyError
- Update period time field descriptions to reflect HH:MM:SS support

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the 'both or neither' constraint on period start/end fields.
Each field now independently falls back to its cached value when omitted,
consistent with the services.yaml declaration of all period fields as
optional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Apply the read-merge-write pattern consistently: charge_power,
charge_stop_soc, mains_enabled, discharge_power, and discharge_stop_soc
now fall back to cached device values when not supplied, matching the
behaviour of the period fields. Range validation is retained for any
value that reaches the write call, whether user-supplied or from cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@johanzander johanzander marked this pull request as ready for review March 11, 2026 21:02
Copilot AI review requested due to automatic review settings March 11, 2026 21:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants