Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the extract_fan_speeds() helper by addressing cases where the components payload is empty or malformed. It also bumps the package version and updates the release notes accordingly.
- Added a type check for data in extract_fan_speeds() to gracefully handle non-dictionary inputs.
- Updated the version number in the package initializer.
- Enhanced the release notes with details on various fixes and improvements.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pypowerwall/tedapi/init.py | Added a type check and minor refactoring in extract_fan_speeds() to handle invalid data inputs. |
| pypowerwall/init.py | Updated version bump from (0, 12, 9) to (0, 12, 10). |
| RELEASE.md | Added detailed release notes for version v0.12.10, including bug fixes and new features. |
|
|
||
| # Helper Function | ||
| def extract_fan_speeds(self, data) -> Dict[str, Dict[str, str]]: | ||
| if not isinstance(data, dict): |
There was a problem hiding this comment.
While returning an empty dict prevents crashes when data is not a dictionary, consider adding a log warning to help diagnose unexpected, malformed inputs in production.
Suggested change
| if not isinstance(data, dict): | |
| if not isinstance(data, dict): | |
| logging.warning("Expected 'data' to be a dictionary, but got %s. Returning an empty dictionary.", type(data).__name__) |
Owner
Author
There was a problem hiding this comment.
If component fails to poll, we will get a error in the log and a None response. This handles that particular case without removing visibility into polling issues.
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.
v0.12.10 - Power Flow and Other Fixes
Closes #167