BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
532 stars 49 forks source link

Exception: Failed to find rate for consumption between 2024-05-31 04:30:00+00:00 and 2024-05-31 05:00:00+00:00 #890

Closed plord12 closed 4 days ago

plord12 commented 3 weeks ago

Describe the bug

Overnight my automations stopped working. I noticed sensor.octopus_energyelectricity__current_rate set to Unknown from 5:30am onwards.

Reproduction steps

Presumably, have intelligent go tariff and try to retrieve data.

Expected behaviour

No execption and sensor.octopus_energyelectricity__current_rate set to the correct value.

Tariff Code

Tariff is set to Unknown on current_rate sensor

Integration Version

11.0.2

Home Assistant Version

2024.5.5

Fresh Install?

Not specified

Home Assistant Logs

Logs include -

2024-05-31 07:20:03.521 DEBUG (MainThread) [custom_components.octopus_energy.electricity.current_rate] Updating OctopusEnergyElectricityCurrentRate for '2000060597358/18P5031988'
2024-05-31 07:20:03.533 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 65, 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 "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/octopus_energy/electricity/current_accumulative_consumption.py", line 121, in _handle_coordinator_update
    consumption_and_cost = calculate_electricity_consumption_and_cost(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 67, 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-05-31 04:30:00+00:00 and 2024-05-31 05:00:00+00:00
2024-05-31 07:20:03.539 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 65, 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 "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/octopus_energy/electricity/current_accumulative_consumption.py", line 121, in _handle_coordinator_update
    consumption_and_cost = calculate_electricity_consumption_and_cost(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/octopus_energy/electricity/__init__.py", line 67, 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-05-31 04:30:00+00:00 and 2024-05-31 05:00:00+00:00

Confirmation

plord12 commented 3 weeks ago

Oh, I noticed the json response from octopus didn't include data beyond 4:30 -

2024-05-31 07:39:03.497 DEBUG (MainThread) [custom_components.octopus_energy.coordinators.electricity_rates] Rates adjusted: [{'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 29, 23, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 29, 23, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 29, 23, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 0, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 0, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 0, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 0, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 1, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 1, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 1, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 1, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 2, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 2, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 2, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 2, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 3, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 3, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 3, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 3, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 4, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 4, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 4, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 4, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 5, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 5, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 5, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 5, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 6, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 6, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 6, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 6, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 7, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 7, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 7, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 7, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 8, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 8, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 8, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 8, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 9, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 9, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 9, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 9, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 10, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 10, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 10, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 10, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 11, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 11, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 11, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 11, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 12, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 12, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 12, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 12, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 13, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 13, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 13, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 13, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 14, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 14, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 14, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 14, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 15, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 15, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 15, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 15, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 16, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 16, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 16, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 16, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 17, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 17, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 17, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 17, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 18, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 18, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 18, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 18, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 19, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 19, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 19, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 19, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 20, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 20, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 20, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 20, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 21, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 21, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 21, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 21, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 22, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 27.274275, 'start': datetime.datetime(2024, 5, 30, 22, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 22, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 22, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 23, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 23, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 30, 23, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 30, 23, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 0, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 0, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 0, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 0, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 1, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 1, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 1, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 1, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 2, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 2, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 2, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 2, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 3, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 3, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 3, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 3, 30, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 4, 0, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}, {'value_inc_vat': 7.49994, 'start': datetime.datetime(2024, 5, 31, 4, 0, tzinfo=datetime.timezone.utc), 'end': datetime.datetime(2024, 5, 31, 4, 30, tzinfo=datetime.timezone.utc), 'tariff_code': 'E-1R-INTELLI-VAR-22-10-14-H', 'is_capped': False}]; dispatches: <custom_components.octopus_energy.api_client.intelligent_dispatches.IntelligentDispatches object at 0xffff2800a5a0>
BottlecapDave commented 3 weeks ago

Hello. Assuming you're on intelligent, it looks like the OE APIs are failing to return any rate information after 2024-05-31 05:30:00. This is not something I'm in control of, so unfortunately there's nothing I can do. I've posted in the forums which will hopefully get someone's attention.

plord12 commented 3 weeks ago

Note that the exception seems to stop the rest of the current_rate attributes from being populated (eg Tariff).

plord12 commented 3 weeks ago

The intelligent_dispatching entity was set to off at midnight (which my automations rely on) ... even with the truncated response I would have expected this to stay on until the data ran out.

plord12 commented 3 weeks ago

Hello. Assuming you're on intelligent, it looks like the OE APIs are failing to return any rate information after 2024-05-31 05:30:00. This is not something I'm in control of, so unfortunately there's nothing I can do. I've posted in the forums which will hopefully get someone's attention.

Thanks.

I see the same with curl BTW -

$ curl -u APIKEY https://api.octopus.energy/v1/products/INTELLI-VAR-22-10-14/electricity-tariffs/E-1R-INTELLI-VAR-22-10-14-H/standard-unit-rates/ | jq
{
  "count": 1199,
  "next": "https://api.octopus.energy/v1/products/INTELLI-VAR-22-10-14/electricity-tariffs/E-1R-INTELLI-VAR-22-10-14-H/standard-unit-rates/?page=2",
  "previous": null,
  "results": [
    {
      "value_exc_vat": 7.1428,
      "value_inc_vat": 7.49994,
      "valid_from": "2024-05-30T22:30:00Z",
      "valid_to": "2024-05-31T04:30:00Z",
      "payment_method": null
    },
    {
      "value_exc_vat": 25.9755,
      "value_inc_vat": 27.274275,
      "valid_from": "2024-05-30T04:30:00Z",
      "valid_to": "2024-05-30T22:30:00Z",
      "payment_method": null
    },
    ....
paulmthomas2 commented 3 weeks ago

I think this is same issue, as my live usage from my home-mini is not updating in home assistant as of this morning. It does update (I think) when I reload the integration, and then stops again. I did get gas data updated in the last hour also.

Re: the API - i'm getting live usage data in OctoAid app, which suggests the API is still functioning (at least in that respect).

Log below: This error originated from a custom integration.

Logger: homeassistant Source: custom_components/octopus_energy/electricity/init.py:67 integration: Octopus Energy (documentation, issues) First occurred: 06:49:28 (272 occurrences) Last logged: 08:19:39

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/octopus_energy/electricity/init.py", line 65, 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 "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners update_callback() File "/config/custom_components/octopus_energy/electricity/current_accumulative_consumption.py", line 121, in _handle_coordinator_update consumption_and_cost = calculate_electricity_consumption_and_cost( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/octopus_energy/electricity/init.py", line 67, 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-05-31 04:30:00+00:00 and 2024-05-31 05:00:00+00:00

paulmthomas2 commented 3 weeks ago

Worth noting that as of around 08:55 (UTC+1), this seems to be working again for me at least. Thanks

plord12 commented 3 weeks ago

Worth noting that as of around 08:55 (UTC+1), this seems to be working again for me at least. Thanks

Yes me too :-)

The curl request is now returning the right data -

{
  "count": 1203,
  "next": "https://api.octopus.energy/v1/products/INTELLI-VAR-22-10-14/electricity-tariffs/E-1R-INTELLI-VAR-22-10-14-H/standard-unit-rates/?page=2",
  "previous": null,
  "results": [
    {
      "value_exc_vat": 7.1428,
      "value_inc_vat": 7.49994,
      "valid_from": "2024-06-01T22:30:00Z",
      "valid_to": "2024-06-02T04:30:00Z",
      "payment_method": null
    },
    {
      "value_exc_vat": 25.9755,
      "value_inc_vat": 27.274275,
      "valid_from": "2024-06-01T04:30:00Z",
      "valid_to": "2024-06-01T22:30:00Z",
      "payment_method": null
    },
   ...
Stewbo1 commented 3 weeks ago

Back online here as of 08:58! Thanks

plord12 commented 3 weeks ago

The intelligent_dispatching entity was set to off at midnight (which my automations rely on) ... even with the truncated response I would have expected this to stay on until the data ran out.

Can this part be fixed ? Ie with data onto up to 5:30 BST we should see intelligent_dispatching on until 5:30.

BottlecapDave commented 3 weeks ago

Can this part be fixed ? Ie with data onto up to 5:30 BST we should see intelligent_dispatching on until 5:30.

This is difficult to fix as I need a full days worth of rate information to work out if a tariff has an off peak rate. OE doesn't any information other than rates to work out if a tariff has off peak rates and I want this integration to adapt automatically to tariff changes as much as possible without code changes.

Because the API was only returning a single rate it couldn't calculate if this was or wasn't the off peak cost and therefore couldn't determine if the dispatching sensor should turn on/off during this time.

I've raised https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/891 to try and detach some logic so if a planned dispatch occurred during this time it would turn on.

plord12 commented 3 weeks ago

Can this part be fixed ? Ie with data onto up to 5:30 BST we should see intelligent_dispatching on until 5:30.

This is difficult to fix as I need a full days worth of rate information to work out if a tariff has an off peak rate. OE doesn't any information other than rates to work out if a tariff has off peak rates and I want this integration to adapt automatically to tariff changes as much as possible without code changes.

Because the API was only returning a single rate it couldn't calculate if this was or wasn't the off peak cost and therefore couldn't determine if the dispatching sensor should turn on/off during this time.

I've raised #891 to try and detach some logic so if a planned dispatch occurred during this time it would turn on.

Ah, I see, many thanks for the explanation.

Would the graphql getProperties call help ? ie the same as the octopus webpage uses. This returns -

...
              "agreements": [
                {
                  "id": 20394001,
                  "validFrom": "2023-11-14T00:00:00+00:00",
                  "validTo": null,
                  "isRevoked": false,
                  "unitRateUplifts": [],
                  "tariff": {
                    "__typename": "HalfHourlyTariff",
                    "standingCharge": 61.2675,
                    "preVatStandingCharge": 58.35,
                    "displayName": "Intelligent Octopus Go",
                    "fullName": "Intelligent Octopus Go October 2022 v1",
                    "unitRates": [
                      {
                        "value": 7.49994,
                        "validFrom": "2024-05-30T22:30:00+00:00",
                        "validTo": "2024-05-31T04:30:00+00:00",
                        "__typename": "UnitRate"
                      },
                      {
                        "value": 27.274275,
                        "validFrom": "2024-05-31T04:30:00+00:00",
                        "validTo": "2024-05-31T22:30:00+00:00",
                        "__typename": "UnitRate"
                      },
                      {
                        "value": 7.49994,
                        "validFrom": "2024-05-31T22:30:00+00:00",
                        "validTo": "2024-06-01T04:30:00+00:00",
                        "__typename": "UnitRate"
                      },
                      {
                        "value": 27.274275,
                        "validFrom": "2024-06-01T04:30:00+00:00",
                        "validTo": "2024-06-01T22:30:00+00:00",
                        "__typename": "UnitRate"
                      },
                      {
                        "value": 7.49994,
                        "validFrom": "2024-06-01T22:30:00+00:00",
                        "validTo": "2024-06-02T04:30:00+00:00",
                        "__typename": "UnitRate"
                      }
                    ],
                    "productCode": "INTELLI-VAR-22-10-14"
                  },
                  "__typename": "ElectricityAgreementType"
                }
              ],
...
BottlecapDave commented 3 weeks ago

In this instance the graphql endpoint was effected by the same issue (I assume they're the same underlying service). I avoid the graphql endpoints for rate information as it makes it impossible for me to test tariffs I'm not on.