Futurerate - add automatic detection of Agile mode#3744
Conversation
There was a problem hiding this comment.
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_autoinFutureRateto detect Agile viametric_octopus_import/exportsensor 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. |
| 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): |
There was a problem hiding this comment.
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.
| """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 |
There was a problem hiding this comment.
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.
| """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) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.