Skip to content

Futurerate - add automatic detection of Agile mode#3744

Merged
springfall2008 merged 7 commits intomainfrom
futurerate
Apr 8, 2026
Merged

Futurerate - add automatic detection of Agile mode#3744
springfall2008 merged 7 commits intomainfrom
futurerate

Conversation

@springfall2008
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 5, 2026 19:15
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

Adds an auto-detection mode for Octopus Agile tariffs to FutureRate so Predbat can decide when to fetch/calibrate Nordpool-based future rates without relying on manual import/export flags.

Changes:

  • Implement futurerate_adjust_auto in FutureRate to detect Agile via metric_octopus_import/export sensor attributes (tariff / tariff_code) and optionally skip fetching when neither side is Agile.
  • Add a new unit test suite covering Agile detection + auto-adjust behavior.
  • Document the new config option and bump Predbat version.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/energy-rates.md Documents futurerate_adjust_auto behavior and adds example YAML.
docs/apps-yaml.md Lists futurerate_adjust_auto in the apps.yaml options summary.
apps/predbat/futurerate.py Adds Agile detection and uses futurerate_adjust_auto to control fetching/calibration.
apps/predbat/tests/test_futurerate_auto.py New tests for Agile detection and auto-adjust logic.
apps/predbat/unit_test.py Registers the new futurerate auto-detection tests in the runner.
apps/predbat/predbat.py Version bump to v8.35.8.

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment on lines +61 to +65
def get_arg(self, arg, default=None, indirect=False):
"""Return value from args dict or the supplied default."""
return self.args.get(arg, default)

def set_arg(self, arg, value):
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

There’s trailing whitespace on the blank line after get_arg(...) which will typically fail the repo’s trailing-whitespace pre-commit hook. Please remove the spaces so the line is truly empty.

Copilot uses AI. Check for mistakes.
Comment on lines +249 to +252
"""When futurerate_url is not set, analysis returns empty regardless of auto flag."""
base = MockFutureRateBase()
base.args.pop("futurerate_url", None)
base.args["futurerate_auto"] = True
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

This test sets base.args["futurerate_auto"] = True, but FutureRate never reads futurerate_auto (the gating logic is based on futurerate_adjust_auto and/or futurerate_adjust_import/export). This assignment is misleading and can be removed or replaced with the correct flag to ensure the test is exercising the intended behavior.

Suggested change
"""When futurerate_url is not set, analysis returns empty regardless of auto flag."""
base = MockFutureRateBase()
base.args.pop("futurerate_url", None)
base.args["futurerate_auto"] = True
"""When futurerate_url is not set, analysis returns empty results."""
base = MockFutureRateBase()
base.args.pop("futurerate_url", None)

Copilot uses AI. Check for mistakes.
springfall2008 and others added 2 commits April 8, 2026 08:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@springfall2008 springfall2008 merged commit 6070e5a into main Apr 8, 2026
1 check passed
@springfall2008 springfall2008 deleted the futurerate branch April 8, 2026 07:32
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