Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual reset cost tracker fails after 2 days #1155

Open
2 tasks done
BottlecapDave opened this issue Jan 2, 2025 · 2 comments
Open
2 tasks done

Manual reset cost tracker fails after 2 days #1155

BottlecapDave opened this issue Jan 2, 2025 · 2 comments
Assignees
Labels
bug Something isn't working stale The issue has not had any activity for a while

Comments

@BottlecapDave
Copy link
Owner

Describe the bug

When you have a cost tracker that hasn't been reset for more than 2 days (e.g. older than the previous available rates), then you start getting errors in the form of

Traceback (most recent call last):
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 41, in calculate_electricity_consumption_and_cost
    rate = next(r for r in rate_data if r["start"] == consumption_from and r["end"] == consumption_to)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/octopus_energy/cost_tracker/cost_tracker.py", line 225, in _async_calculate_cost
    self._recalculate_cost(current, consumption_data.tracked_consumption_data, consumption_data.untracked_consumption_data, rates_result.rates)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/cost_tracker/cost_tracker.py", line 276, in _recalculate_cost
    tracked_result = calculate_electricity_consumption_and_cost(
      tracked_consumption_data,
    ...<5 lines>...
      target_rate=target_rate
    )
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 43, in calculate_electricity_consumption_and_cost
    raise Exception(f"Failed to find rate for consumption between {consumption_from} and {consumption_to}")
Exception: Failed to find rate for consumption between 2024-12-31 08:00:00+00:00 and 2024-12-31 08:30:00+00:00

Reproduction steps

  1. Setup a cost tracker with manual reset enabled
  2. Don't reset the cost tracker for 2 days

Expected behaviour

The cost tracker should continue to work for more than two days or a repair notice should be raised stating the cost tracker needs resetting. Either way, the sensor should not throw an error

Tariff Code

N/A

Integration Version

13.5.1

Home Assistant Version

2024.12.5

Fresh Install?

Not specified

Home Assistant Logs

N/A

Confirmation

  • I confirm that I cannot find my solution within the documentation
  • I confirm that I cannot find my solution within the FAQ
@BottlecapDave BottlecapDave added the bug Something isn't working label Jan 2, 2025
@BottlecapDave BottlecapDave self-assigned this Jan 2, 2025
Copy link
Contributor

github-actions bot commented Feb 2, 2025

This issue has become stale because it has been open for 30 days with no activity. If you still think it's an issue, please respond soon.

@github-actions github-actions bot added the stale The issue has not had any activity for a while label Feb 2, 2025
@BottlecapDave BottlecapDave removed the stale The issue has not had any activity for a while label Feb 7, 2025
Copy link
Contributor

This issue has become stale because it has been open for 30 days with no activity. If you still think it's an issue, please respond soon.

@github-actions github-actions bot added the stale The issue has not had any activity for a while label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale The issue has not had any activity for a while
Projects
None yet
Development

No branches or pull requests

1 participant