From 48f832afd9cb5ea846d655e7eb3ea7937520822b Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Wed, 17 Apr 2024 06:53:43 +0100 Subject: [PATCH] fix: fixed tariff override data having rate value in pounds and pence for consistency BREAKING CHANGE: If you were using tariff override rate information, you may need to adjust your use due to changes in how value is reported --- .../electricity/previous_accumulative_cost_override.py | 3 ++- .../octopus_energy/gas/previous_accumulative_cost_override.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py index 9cdc5ea2..9ac4a47d 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py @@ -27,6 +27,7 @@ from ..utils.attributes import dict_to_typed_dict from ..utils.requests import calculate_next_refresh from ..coordinators.previous_consumption_and_rates import PreviousConsumptionCoordinatorResult +from ..utils import private_rates_to_public_rates from ..api_client import (ApiException, OctopusEnergyApiClient) @@ -178,7 +179,7 @@ async def async_update(self): }, consumption_and_cost["charges"])) } - self._hass.bus.async_fire(EVENT_ELECTRICITY_PREVIOUS_CONSUMPTION_OVERRIDE_RATES, { "mpan": self._mpan, "serial_number": self._serial_number, "tariff_code": self._tariff_code, "rates": rate_data }) + self._hass.bus.async_fire(EVENT_ELECTRICITY_PREVIOUS_CONSUMPTION_OVERRIDE_RATES, { "mpan": self._mpan, "serial_number": self._serial_number, "tariff_code": self._tariff_code, "rates": private_rates_to_public_rates(rate_data) }) self._attributes["last_evaluated"] = current self._request_attempts = 1 diff --git a/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py b/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py index 0d22126c..22ab64dd 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py @@ -30,6 +30,7 @@ from ..utils.attributes import dict_to_typed_dict from ..utils.requests import calculate_next_refresh from ..coordinators.previous_consumption_and_rates import PreviousConsumptionCoordinatorResult +from ..utils import private_rates_to_public_rates from ..const import DOMAIN, EVENT_GAS_PREVIOUS_CONSUMPTION_OVERRIDE_RATES, MINIMUM_CONSUMPTION_DATA_LENGTH, REFRESH_RATE_IN_MINUTES_PREVIOUS_CONSUMPTION @@ -177,7 +178,7 @@ async def async_update(self): "calorific_value": self._calorific_value } - self._hass.bus.async_fire(EVENT_GAS_PREVIOUS_CONSUMPTION_OVERRIDE_RATES, { "mprn": self._mprn, "serial_number": self._serial_number, "tariff_code": self._tariff_code, "rates": rate_data }) + self._hass.bus.async_fire(EVENT_GAS_PREVIOUS_CONSUMPTION_OVERRIDE_RATES, { "mprn": self._mprn, "serial_number": self._serial_number, "tariff_code": self._tariff_code, "rates": private_rates_to_public_rates(rate_data) }) self._attributes["last_evaluated"] = current self._attempts_to_retrieve = 1