Repository navigation
Dynamic load feature - #2702
Dynamic load feature#2702
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a dynamic load feature that adjusts load predictions based on real-time consumption patterns. The feature analyzes recent load data to classify periods as "high", "low", or "baseline" and makes corresponding adjustments to predictions and car charging schedules.
- Adds dynamic load analysis functionality with real-time load classification
- Implements load baseline adjustments and car charging slot modifications
- Updates sensor outputs and dashboard items for better monitoring
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/predbat/predbat.py | Version bump and initialization of dynamic load variables |
| apps/predbat/plan.py | Core dynamic load logic implementation and sensor updates |
| apps/predbat/gecloud.py | Load period calculation and API pagination increase |
| apps/predbat/fetch.py | Configuration option and load baseline application |
| apps/predbat/energydataservice.py | Cleanup of debug print statements |
| apps/predbat/config.py | New configuration options for dynamic load features |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| # Last period load analysis | ||
| self.load_last_status = "baseline" | ||
| if self.load_last_period > self.battery_rate_max_discharge * MINUTE_WATT / 1000: |
There was a problem hiding this comment.
The magic number 1000 appears to be a unit conversion factor. Consider defining it as a named constant (e.g., WATTS_TO_KW = 1000) to improve code readability and maintainability.
| def dynamic_load(self): | ||
|
|
||
| # Last period load analysis | ||
| self.load_last_status = "baseline" | ||
| if self.load_last_period > self.battery_rate_max_discharge * MINUTE_WATT / 1000: | ||
| self.load_last_status = "high" | ||
| elif (self.load_last_period < self.battery_rate_max_discharge * 0.9 * MINUTE_WATT / 1000) and (self.load_last_period < self.car_charging_threshold * 0.9): |
There was a problem hiding this comment.
The magic number 0.9 appears twice in this condition. Consider defining it as a named constant (e.g., LOW_LOAD_FACTOR = 0.9) to improve maintainability and make the threshold configurable.
| def dynamic_load(self): | |
| # Last period load analysis | |
| self.load_last_status = "baseline" | |
| if self.load_last_period > self.battery_rate_max_discharge * MINUTE_WATT / 1000: | |
| self.load_last_status = "high" | |
| elif (self.load_last_period < self.battery_rate_max_discharge * 0.9 * MINUTE_WATT / 1000) and (self.load_last_period < self.car_charging_threshold * 0.9): | |
| LOW_LOAD_FACTOR = 0.9 | |
| def dynamic_load(self): | |
| # Last period load analysis | |
| self.load_last_status = "baseline" | |
| if self.load_last_period > self.battery_rate_max_discharge * MINUTE_WATT / 1000: | |
| self.load_last_status = "high" | |
| elif (self.load_last_period < self.battery_rate_max_discharge * self.LOW_LOAD_FACTOR * MINUTE_WATT / 1000) and (self.load_last_period < self.car_charging_threshold * self.LOW_LOAD_FACTOR): |
| self.dynamic_load_baseline = {} | ||
| if self.metric_dynamic_load_adjust: | ||
| minutes_now = self.minutes_now | ||
| minutes_end_slot = int((self.minutes_now + 30) / 30) * 30 |
There was a problem hiding this comment.
The magic number 30 (representing a 30-minute period) appears multiple times. Consider defining it as a named constant (e.g., SLOT_DURATION_MINUTES = 30) to improve maintainability.
| url += "&pageSize=8000" | ||
| else: | ||
| url += "?pageSize=4096" | ||
| url += "?pageSize=8000" |
There was a problem hiding this comment.
The magic number 8000 for page size should be defined as a named constant (e.g., GE_API_PAGE_SIZE = 8000) to improve maintainability and make it easier to adjust if needed.
fixes to logfile search on web fixes to code for dynamic load
No description provided.