-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for SPH inverters using V1 API #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Implements complete V1 API support for SPH (type 5) hybrid inverters, parallel to existing MIN device support. Changes: - Add DeviceType enum to distinguish device types - Implement 10 SPH methods in OpenApiV1: * sph_detail() - Get device details * sph_energy() - Get current energy data * sph_energy_history() - Get historical data (7-day max) * sph_settings() - Get all inverter settings * sph_read_parameter() - Read specific parameters * sph_write_parameter() - Write parameters * sph_write_ac_charge_time() - Configure AC charge periods (1-3) * sph_write_ac_discharge_time() - Configure AC discharge periods (1-3) * sph_read_ac_charge_times() - Read all charge periods * sph_read_ac_discharge_times() - Read all discharge periods - Add documentation to docs/openapiv1.md - Include working example script (examples/sph_example.py) Technical details: - SPH devices use 'mix' endpoints internally (device/mix/*) - AC charge/discharge periods support 3 time windows each - Methods follow same patterns as existing MIN implementation - All endpoints match official Growatt V1 API documentation
…d SPH devices with V1 API
|
Hi @GraemeDBlue - please have a look at this and let me know what you think. I think this minimal approach as layed out in the design rationale would be approved quite easily by the maintainer. |
@johanzander right, so bit confused then as you said "Keep your internal implementation work (which is solid)" , but none of my work is retained at all anyway, are you only needing me as i have an SPH device? |
|
To be honest, I gave instructions to AI agent to align implementation to current python library architecture and keep changes to minimum in initial PR. Doing large refactoring and feature development in same PR makes it very hard to review test and approve. |
How do you want to handle the conflicts then ? |
|
I follow the principles in the Perfect PR recommendation: _Make your PRs as small as possible. A PR should only refactor one thing, fix one thing, add one feature, or adjust a single subject in the documentation. If you want to change multiple things, please create multiple PRs. Smaller PRs have a smaller scope, need less time to review, conflict less often, and generally need fewer review iterations. Only change one thing at a time. This is the same as the previous point but a bit more specific. It is tempting to improve those one or two lines you've noticed nearby, but please don't. Put those in a separate PR. Unrelated changes in your PR are distracting and often lead to questions. In contrast, in an independent PR, it would be a quick and simple review and merge._ Hence, my recommendation is that you review/test this small PR, create a new PR to get this in. There shouldn't be any merge conflicts towards the master 1.7.1 version. then for each improvement you want to commit to the library, you create a new PR, cherry picking the change from your own "upstream" version. This is exactly how I work with the Home Assistant integration, one small increment at a time, based on my now upstream version. This can be frustrating and I know the feeling when done a lot of work - my first PR to the HA Growatt integration was a huge refactoring and lots of features that got rejected immediately and I got asked to break it down into many smaller PRs. |
while is as expected |
GraemeDBlue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are only 18 params , your requests are trying to do 19 , example scripts seem to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds complete V1 API support for SPH (type 5) hybrid inverters to the growattServer library. The implementation mirrors the existing MIN inverter architecture and maintains full backward compatibility with zero breaking changes.
Changes:
- Added DeviceType enum for type-safe device identification
- Implemented 10 new SPH-specific API methods following the established MIN method patterns
- Added comprehensive documentation and working example script
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| growattServer/open_api_v1.py | Added DeviceType enum and 10 SPH-specific methods (detail, energy, settings, parameters, AC charge/discharge configuration) using MIX API endpoints |
| growattServer/init.py | Exported DeviceType enum for public API access |
| examples/sph_example.py | Added comprehensive example demonstrating all SPH methods with commented write operations |
| docs/openapiv1/sph_settings.md | New documentation detailing SPH settings methods and parameters |
| docs/openapiv1.md | Updated main documentation with SPH methods table and reorganized method sections by device type |
| README.md | Updated library description to mention SPH support alongside MIN |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@johanzander comments above |
|
Great! So I have Claude Code writing the code, and you have Copilot reviewing the changes , what a development :-). Feel free to adress it yourself, otherwise I can fix it shortly, when I have credits again. |
|
all review comments adressed, please have a look. |
|
@johanzander could you not add https://github.com/indykoning/PyPi_GrowattServer/pull/125/files#diff-5461eaaa755cb6e17a88c081974c81b6a81e6b81d5f29015fb2ed33645732b59R148-R150 to the examples , having to keep editing the file to add my token is just annoying, and also encourages anyone else who uses this to use their own real token and not raise issues about it not working |
GraemeDBlue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small fix for the sph examples to run "out the box"
- sph_read_ac_charge_times now returns dict with charge_power, charge_stop_soc, mains_enabled, and periods - sph_read_ac_discharge_times now returns dict with discharge_power, discharge_stop_soc, and periods - Made device_sn optional when settings_data is provided (avoids redundant API calls) - Updated example to demonstrate new return structure - Updated documentation with new signatures and return types
|
|
|
GraemeDBlue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid params for readMixParam https://www.showdoc.com.cn/262556420217021/6129766954561259
|
@johanzander thanks for adding token as env variable , but some bad params now for some reason that were not a problem before |
|
|
…ove docs and examples
|
pls. have a look @GraemeDBlue and see if everything works correctly |
Overview
Adds complete V1 API support for SPH (type 5) hybrid inverters
Design Rationale (per indykoning#125 discussion)
What's Included
10 new SPH methods:
Documentation:
Technical Details
Testing