Skip to content

Commit

Permalink
New release (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave authored Aug 5, 2024
2 parents e5302e3 + 50a7bdf commit 0c608ed
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 17 deletions.
17 changes: 8 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@

### Bug Fixes

* fixed event based sensors (e.g. current_day_rates) to be situated in the correct domain ([239093f](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/239093f46ac9cf2327d901fa438cd933a4a5bebc))
* Removed certain sensors for Octopus Home Pro as data is not available ([85ad59c](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/85ad59c16ed8f3820c7d42abc3ca8b633117bb4d))
* removed last_evaluated attribute as this duplicates data already available via HA sensors and removed data_last_retrieved and target_times_last_evaluated from being stored by the recorder ([20603f5](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/20603f554e1ecd33396d672587bc54a6c63b441f))
* Updated unloading of account to properly close existing connections ([e56e62d](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/e56e62d328b5e0cdf6e03a14bfc2238a10f42dcc))
* fixed event based sensors (e.g. current_day_rates) to be situated in the correct domain (30 minutes dev time) ([239093f](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/239093f46ac9cf2327d901fa438cd933a4a5bebc))
* Removed certain sensors for Octopus Home Pro as data is not available (5 minutes dev time) ([85ad59c](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/85ad59c16ed8f3820c7d42abc3ca8b633117bb4d))
* removed last_evaluated attribute as this duplicates data already available via HA sensors and removed data_last_retrieved and target_times_last_evaluated from being stored by the recorder (2 hours dev time) ([20603f5](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/20603f554e1ecd33396d672587bc54a6c63b441f))
* Updated unloading of account to properly close existing connections (15 minutes dev time) ([e56e62d](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/e56e62d328b5e0cdf6e03a14bfc2238a10f42dcc))


### Features

* Added hours mode for target rate sensors which allow the sensor to come on the minimum or maximum specified number of hours (2.5 hours dev time) ([a57f5c7](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/a57f5c77b096cb3c893d5da4e258eea72c195ffe))
* **custom:** fixed issue with duel rate tariffs changing to non DD rates. Toggle is now available in config. ([e427419](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/e42741981f6c4cbf71e6932160363485e0dd51ed))
* **custom:** removed deprecated default tariff override sensors ([21bf804](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/21bf80402248458e56f96c831fe9e73d0e71312c))
* fixed issue with duel rate tariffs changing to non DD rates. Toggle is now available in config. (40 mins dev time) ([e427419](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/e42741981f6c4cbf71e6932160363485e0dd51ed))
* removed deprecated default tariff override sensors (5 minutes dev time) ([21bf804](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/21bf80402248458e56f96c831fe9e73d0e71312c))


### BREAKING CHANGES

* last_evaluated attribute has been removed from all entities. You should use the inbuilt last_updated
state/attribute provided by HA

Removed data_last_retrieved and
* Removed data_last_retrieved and
target_times_last_evaluated from being stored in the database to try and reduce footprint. This
follows HA guidelines around attributes that change frequently
* **custom:** Removed the deprecated default tariff override sensors. If you still require this feature, you
* Removed the deprecated default tariff override sensors. If you still require this feature, you
should be using the new way to define them. See
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/setup/tariff_comparison/ for more
details
Expand Down
2 changes: 2 additions & 0 deletions custom_components/octopus_energy/api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,8 @@ async def async_get_intelligent_device(self, account_id: str) -> IntelligentDevi
device["chargePointModel"],
float(device["chargePointPowerInKw"]) if "chargePointPowerInKw" in device and device["chargePointPowerInKw"] is not None else None
)
else:
_LOGGER.debug('Skipping intelligent device as id is not available')
else:
_LOGGER.error("Failed to retrieve intelligent device")

Expand Down
2 changes: 1 addition & 1 deletion custom_components/octopus_energy/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from custom_components.octopus_energy.config.tariff_comparison import async_validate_tariff_comparison_config, merge_tariff_comparison_config
import voluptuous as vol
import logging

Expand Down Expand Up @@ -76,6 +75,7 @@

DATA_SCHEMA_ACCOUNT,
)
from .config.tariff_comparison import async_validate_tariff_comparison_config, merge_tariff_comparison_config

from .utils import get_active_tariff

Expand Down
17 changes: 12 additions & 5 deletions custom_components/octopus_energy/coordinators/electricity_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from ..const import (
COORDINATOR_REFRESH_IN_SECONDS,
DATA_INTELLIGENT_DEVICE,
DOMAIN,
DATA_CLIENT,
DATA_ELECTRICITY_RATES_COORDINATOR_KEY,
Expand All @@ -30,6 +31,8 @@
from ..intelligent import adjust_intelligent_rates, is_intelligent_product
from ..utils.rate_information import get_unique_rates, has_peak_rates
from ..utils.tariff_cache import async_save_cached_tariff_total_unique_rates
from ..api_client.intelligent_device import IntelligentDevice
from ..api_client.intelligent_dispatches import IntelligentDispatches

_LOGGER = logging.getLogger(__name__)

Expand All @@ -52,8 +55,9 @@ async def async_refresh_electricity_rates_data(
target_serial_number: str,
is_smart_meter: bool,
is_export_meter: bool,
existing_rates_result: ElectricityRatesCoordinatorResult,
dispatches_result: IntelligentDispatchesCoordinatorResult,
existing_rates_result: ElectricityRatesCoordinatorResult | None,
intelligent_device: IntelligentDevice | None,
dispatches_result: IntelligentDispatchesCoordinatorResult | None,
planned_dispatches_supported: bool,
fire_event: Callable[[str, "dict[str, Any]"], None],
tariff_override = None,
Expand All @@ -68,7 +72,8 @@ async def async_refresh_electricity_rates_data(
return None

# We'll calculate the wrong value if we don't have our intelligent dispatches
if is_intelligent_product(tariff.product) and (dispatches_result is None or dispatches_result.dispatches is None):
if is_intelligent_product(tariff.product) and intelligent_device is not None and (dispatches_result is None or dispatches_result.dispatches is None):
_LOGGER.debug("Dispatches not available for intelligent tariff. Using existing rate information")
return existing_rates_result

new_rates = None
Expand Down Expand Up @@ -205,8 +210,9 @@ async def async_update_electricity_rates_data():
client: OctopusEnergyApiClient = hass.data[DOMAIN][account_id][DATA_CLIENT]
account_result = hass.data[DOMAIN][account_id][DATA_ACCOUNT] if DATA_ACCOUNT in hass.data[DOMAIN][account_id] else None
account_info = account_result.account if account_result is not None else None
dispatches: IntelligentDispatchesCoordinatorResult = hass.data[DOMAIN][account_id][DATA_INTELLIGENT_DISPATCHES] if DATA_INTELLIGENT_DISPATCHES in hass.data[DOMAIN][account_id] else None
rates = hass.data[DOMAIN][account_id][key] if key in hass.data[DOMAIN][account_id] else None
intelligent_device: IntelligentDevice | None = hass.data[DOMAIN][account_id][DATA_INTELLIGENT_DEVICE] if DATA_INTELLIGENT_DEVICE in hass.data[DOMAIN][account_id] else None
dispatches: IntelligentDispatchesCoordinatorResult | None = hass.data[DOMAIN][account_id][DATA_INTELLIGENT_DISPATCHES] if DATA_INTELLIGENT_DISPATCHES in hass.data[DOMAIN][account_id] else None
rates: ElectricityRatesCoordinatorResult | None = hass.data[DOMAIN][account_id][key] if key in hass.data[DOMAIN][account_id] else None

hass.data[DOMAIN][account_id][key] = await async_refresh_electricity_rates_data(
current,
Expand All @@ -217,6 +223,7 @@ async def async_update_electricity_rates_data():
is_smart_meter,
is_export_meter,
rates,
intelligent_device,
dispatches,
planned_dispatches_supported,
hass.bus.async_fire,
Expand Down
7 changes: 7 additions & 0 deletions custom_components/octopus_energy/electricity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import datetime
import logging

from ..utils.conversions import value_inc_vat_to_pounds
from ..utils import get_off_peak_cost

_LOGGER = logging.getLogger(__name__)

def __get_to(item):
return item["end"]

Expand Down Expand Up @@ -77,6 +80,10 @@ def calculate_electricity_consumption_and_cost(
}

return result
else:
_LOGGER.debug('Skipping electricity consumption and cost calculation as last reset has not changed')
else:
_LOGGER.debug(f'Skipping electricity consumption and cost calculation due to lack of data; consumption: {len(consumption_data) if consumption_data is not None else 0}; rates: {len(rate_data) if rate_data is not None else 0}; standing_charge: {standing_charge}')

def get_electricity_tariff_override_key(serial_number: str, mpan: str) -> str:
return f'electricity_previous_consumption_tariff_{serial_number}_{mpan}'
7 changes: 7 additions & 0 deletions custom_components/octopus_energy/gas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
from ..utils.conversions import value_inc_vat_to_pounds

_LOGGER = logging.getLogger(__name__)

def __get_to(item):
return item["end"]

Expand Down Expand Up @@ -91,6 +94,10 @@ def calculate_gas_consumption_and_cost(
"last_evaluated": last_calculated_timestamp,
"charges": charges
}
else:
_LOGGER.debug('Skipping gas consumption and cost calculation as last reset has not changed')
else:
_LOGGER.debug(f'Skipping gas consumption and cost calculation due to lack of data; consumption: {len(consumption_data) if consumption_data is not None else 0}; rates: {len(rate_data) if rate_data is not None else 0}; standing_charge: {standing_charge}')

def get_gas_tariff_override_key(serial_number: str, mprn: str) -> str:
return f'gas_previous_consumption_tariff_{serial_number}_{mprn}'
Loading

0 comments on commit 0c608ed

Please sign in to comment.