Skip to content

Fix bug in extract_fan_speeds() #168

Merged
jasonacox merged 2 commits into
mainfrom
v0.12.10
Apr 18, 2025
Merged

Fix bug in extract_fan_speeds() #168
jasonacox merged 2 commits into
mainfrom
v0.12.10

Conversation

@jasonacox
Copy link
Copy Markdown
Owner

v0.12.10 - Power Flow and Other Fixes

Closes #167

@jasonacox jasonacox requested a review from Copilot April 17, 2025 04:38
Copy link
Copy Markdown
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

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):
Copy link

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

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

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__)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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.

@jasonacox jasonacox merged commit a71ed42 into main Apr 18, 2025
25 checks passed
@jasonacox jasonacox deleted the v0.12.10 branch April 18, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in extract_fan_speeds()

2 participants