[WiP] Homeassistant sensor as consumption forecast#214
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds HomeAssistant API-based consumption forecasting as an alternative to the existing CSV-based approach. It enables users to fetch historical consumption data from HomeAssistant via WebSocket API and generate weighted forecasts based on configurable historical periods.
- Implements a new
ForecastConsumptionHomeAssistantclass that fetches hourly consumption statistics from HomeAssistant using WebSocket API - Adds comprehensive test suite covering initialization, data fetching, caching, and forecast generation
- Updates configuration factory to support
homeassistant-apitype with backwards-compatible changes
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/batcontrol/forecastconsumption/forecast_homeassistant.py | New module implementing HomeAssistant-based consumption forecasting with WebSocket API integration |
| src/batcontrol/forecastconsumption/consumption.py | Updated factory to support HomeAssistant API forecasting type alongside CSV |
| tests/batcontrol/forecastconsumption/test_homeassistant.py | Comprehensive test suite for HomeAssistant forecaster with 15+ test cases |
| tests/batcontrol/forecastconsumption/init.py | Package initialization for tests |
| scripts/test_homeassistant_forecast.py | Test/demo script for manual verification of HomeAssistant integration |
| config/batcontrol_config_dummy.yaml | Configuration examples for both CSV and HomeAssistant API options |
| pyproject.toml | Added websockets dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| json.dumps({"type": "auth_ok"}), | ||
| # 3. statistics response | ||
| json.dumps({ | ||
| "id": 1,# |
There was a problem hiding this comment.
Remove stray '#' character at the end of the line.
Suggested change
| "id": 1,# | |
| "id": 1, |
| self, | ||
| start_time: datetime.datetime, | ||
| end_time: datetime.datetime | ||
| ) -> float: |
There was a problem hiding this comment.
Extra whitespace between '->' and 'float' in type annotation.
Suggested change
| ) -> float: | |
| ) -> float: |
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.
Use HA sensors for absolute Wh, which is used for displaying the energy graph, for calculating an consumption forecast.
I can't verify that for my self, because I am on the iobroker train. :)