Catch issue where batteries is empty#3863
Merged
springfall2008 merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GivEnergy Cloud device-discovery logic to correctly classify certain “legacy” hybrid inverters as battery devices even when connections.batteries is empty, and adds a regression test to cover that production-shaped payload.
Changes:
- Treat inverters as battery devices when
inverter.info.batteryis present, even ifconnections.batteriesis empty. - Add a new GE Cloud test case covering the legacy device structure (e.g.
GIV-HY3.6) with emptyconnections.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/predbat/gecloud.py | Extends battery-device detection to include legacy payloads where battery details exist only under info.battery. |
| apps/predbat/tests/test_ge_cloud.py | Adds a regression test for device discovery when connections.batteries is empty but info.battery is populated. |
Comment on lines
1428
to
1432
| elif "gateway" in model: | ||
| result["gateway"] = serial | ||
| elif batteries: | ||
| elif batteries or info.get("battery"): | ||
| result["battery"].append(serial) | ||
| result["battery_meters"][serial] = meter_serials |
Comment on lines
+682
to
+686
| result = await ge_cloud.async_get_devices() | ||
|
|
||
| if result["battery"] != ["sa1919g001"]: | ||
| print("ERROR: Expected battery=['sa1919g001'] for legacy device, got {}".format(result)) | ||
| return 1 |
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.
No description provided.