Skip to content

Fix energy consumption stats NaN/Inf/zero handling (#25) - #78

Open
dennismdejong wants to merge 1 commit into
cjaliaga:mainfrom
dennismdejong:issue-25-energy-stats
Open

dennismdejong wants to merge 1 commit into
cjaliaga:mainfrom
dennismdejong:issue-25-energy-stats

Conversation

@dennismdejong

Copy link
Copy Markdown

Fixes the Consumption class to handle problematic API response values:

  • NaN values: , string now converted to
  • Inf values: / now converted to
  • Zero total: now returns when all components are zero (previously returned )
  • String numbers: values like now correctly parsed to
  • Invalid types: non-numeric values return instead of crashing

Closes #25

- Add _sanitize_float() helper that converts NaN, Inf, None, and
  invalid values to None
- Fix total_consumption to return 0 instead of None when all
  components are valid zeros (a real zero reading vs no data)
- Handle string-encoded numbers from the API
- Handle float('inf') and float('-inf') values

Closes cjaliaga#25
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.

Energy generation stats broken?

1 participant