Skip to content

Feature: Allow configuring time range for price comparison average - #404

Open
spyro2000 wants to merge 14 commits into
solectrus:developfrom
spyro2000:feat/custom-average-timerange
Open

Feature: Allow configuring time range for price comparison average#404
spyro2000 wants to merge 14 commits into
solectrus:developfrom
spyro2000:feat/custom-average-timerange

Conversation

@spyro2000

Copy link
Copy Markdown

This PR addresses the issue where the 24-hour average price is dragged down by low prices in the following night (common in winter), preventing the charger from recognizing the current night's prices as "cheap".
It introduces two new configuration variables:

  • CHARGER_PRICE_COMPARISON_HOUR_START
  • CHARGER_PRICE_COMPARISON_HOUR_END

If these are set (e.g., to 6 and 22), the system will calculate the reference "average price" using only the prices within that time window (the daytime). This higher daytime average makes the current night's prices appear cheaper by comparison, triggering the charge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread .env.test Outdated
Comment thread .env.example
Comment thread Gemfile Outdated
Comment thread test/test_helper.rb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these changes required? I prefer not to change this file.

Comment thread Gemfile
gem 'timecop'

# Used for interacting with C libraries (moved out of the default standard library in Ruby 3.4)
gem 'fiddle'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this really required on Windows? On MacOS and Linux, it is not.

Maybe we should write:

gem 'fiddle', platforms: :windows

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.

3 participants