Skip to content

Fix for plan interval minutes, Fix Solcast Timezone issue - #2875

Merged
springfall2008 merged 6 commits into
mainfrom
fixes10
Nov 7, 2025
Merged

Fix for plan interval minutes, Fix Solcast Timezone issue#2875
springfall2008 merged 6 commits into
mainfrom
fixes10

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors the handling of plan_interval_minutes from using getattr() with a fallback default value to storing it as an instance variable. The changes aim to improve code maintainability by eliminating repetitive getattr() calls throughout the codebase and centralizing access to this configuration value.

Key Changes

  • Moved plan_interval_minutes initialization earlier in the reset() method (line 337) in predbat.py
  • Added plan_interval_minutes as an instance variable in web interface classes (WebInterface and MCPServer)
  • Replaced getattr(self.base, "plan_interval_minutes", 30) and getattr(self, "plan_interval_minutes", 30) calls with direct access to self.plan_interval_minutes across multiple modules

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
predbat.py Moved plan_interval_minutes initialization and version bump to v8.27.5
web.py Added instance variable and replaced 5 getattr() calls with direct access
web_mcp.py Added instance variable and replaced 1 getattr() call with direct access
plan.py Removed local variables and replaced with direct access (4 locations)
output.py Removed local variables and replaced with direct access (8 locations)
octopus.py Added instance variable and replaced 2 getattr() calls with direct access
futurerate.py Added instance variable and replaced 1 getattr() call with direct access
fetch.py Replaced 6 getattr() calls with direct access
execute.py Replaced 2 getattr() calls with direct access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/predbat/predbat.py Outdated
self.text_plan = "Computing please wait..."
self.prediction_cache_enable = True
self.base_load = 0
self.plan_interval_minutes = 30

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

The configuration value for plan_interval_minutes is no longer being read from self.args. The old line 628 self.plan_interval_minutes = self.args.get(\"plan_interval_minutes\", 30) was removed, which means users can no longer configure this value via YAML. This should be changed to self.plan_interval_minutes = self.args.get(\"plan_interval_minutes\", 30) to restore the ability to configure this parameter, or the line should be moved to after the args are available if they're not available at line 337.

Suggested change
self.plan_interval_minutes = 30
self.plan_interval_minutes = self.args.get("plan_interval_minutes", 30)

Copilot uses AI. Check for mistakes.
@springfall2008 springfall2008 changed the title Fix for plan interval minutes Fix for plan interval minutes, Fix Solcast Timezone issue Nov 7, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/predbat/solcast.py
max_kwh = 9999

self.now_utc = datetime.now(timezone.utc)
self.now_utc = datetime.now(self.local_tz)

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

This changes the timezone from UTC to local timezone. The variable name now_utc suggests it should remain in UTC. If this change is intentional, the variable should be renamed to reflect that it's no longer UTC, or the timezone argument should be removed to keep it as UTC.

Suggested change
self.now_utc = datetime.now(self.local_tz)
self.now_utc = datetime.now(timezone.utc)

Copilot uses AI. Check for mistakes.
Comment thread apps/predbat/octopus.py
# Update time every minute
self.now = datetime.now()
self.now_utc = datetime.now(timezone.utc).astimezone()
self.now_utc = datetime.now(self.local_tz)

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

This changes the timezone from UTC to local timezone. The variable name now_utc suggests it should contain UTC time. The original code used datetime.now(timezone.utc).astimezone() which converts to local time but the variable name indicates UTC is expected. This change may introduce bugs if other code relies on now_utc being in UTC timezone.

Suggested change
self.now_utc = datetime.now(self.local_tz)
self.now_utc = datetime.now(timezone.utc)

Copilot uses AI. Check for mistakes.
@springfall2008
springfall2008 merged commit 91f60d5 into main Nov 7, 2025
1 check passed
@springfall2008
springfall2008 deleted the fixes10 branch November 7, 2025 19:50
iangregory pushed a commit to iangregory/batpred that referenced this pull request Dec 3, 2025
…2008#2875)

* Tidy up plan interval minutes

* Fix

* Solcast fixes

* Fixes

* Octopus TZ fix

* Fix
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.

2 participants