Skip to content

Commit

Permalink
Merge branch 'develop' into feat/previous-consumption-history
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Jan 18, 2025
2 parents f10e75b + 68550fb commit 4ad28fd
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [13.5.3](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/compare/v13.5.2...v13.5.3) (2025-01-04)


### Bug Fixes

* Fixed issue with changing intelligent target time always throwing an error (30 minutes dev time) ([7ce15bd](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/commit/7ce15bd907e544bd7b24a76fc3140ab82517fdee))

## [13.5.2](https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/compare/v13.5.1...v13.5.2) (2025-01-03)


Expand Down
4 changes: 4 additions & 0 deletions _docs/entities/heat_pump.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ The following operation modes are available

In addition, there is the preset of `boost`, which activates boost mode for the zone for 1 hour. If you require boost to be on for a different amount of time, then you can use the [available service](../services.md#octopus_energyboost_heat_pump_zone).

!!! note

If you boost and a target temperature is not defined, then a default value will be set. This will be 50 degrees C for `water` zones and 30 degrees C for all other zones.

## Lifetime Seasonal Coefficient of Performance

`sensor.octopus_energy_heat_pump_{{HEAT_PUMP_ID}}_lifetime_scop`
Expand Down
3 changes: 3 additions & 0 deletions _docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ Allows you to boost a given heat pump zone for a set amount of time.
| `data.minutes` | `no` | The number of minutes to turn boost mode on for. This can be 0, 15, or 45. |
| `data.target_temperature` | `yes` | The optional target temperature to boost to. If not supplied, then the current target temperature will be used. |

!!! note

If you boost and a target temperature is both not provided and not defined on the sensor itself, then a default value will be set. This will be 50 degrees C for `water` zones and 30 degrees C for all other zones.

## octopus_energy.set_heat_pump_flow_temp_config

Expand Down
12 changes: 9 additions & 3 deletions custom_components/octopus_energy/api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,10 +1217,11 @@ async def async_get_electricity_consumption(self, mpan: str, serial_number: str,
for item in data:
item = self.__process_consumption(item)

# For some reason, the end point returns slightly more data than we requested, so we need to filter out
# the results
# For some reason, the end point sometimes returns slightly more data than we requested, so we need to filter out the results
if (period_from is None or as_utc(item["start"]) >= period_from) and (period_to is None or as_utc(item["end"]) <= period_to):
results.append(item)
else:
_LOGGER.debug(f'Skipping gas consumption item due to outside requested scope - period_from: {period_from}; period_to: {period_to}; item: {item}; mpan: {mpan}; serial_number: {serial_number}')

results.sort(key=self.__get_interval_end)
return results
Expand Down Expand Up @@ -1279,7 +1280,12 @@ async def async_get_gas_consumption(self, mprn: str, serial_number: str, period_
results = []
for item in data:
item = self.__process_consumption(item)
results.append(item)

# For some reason, the end point sometimes returns slightly more data than we requested, so we need to filter out the results
if (period_from is None or as_utc(item["start"]) >= period_from) and (period_to is None or as_utc(item["end"]) <= period_to):
results.append(item)
else:
_LOGGER.debug(f'Skipping gas consumption item due to outside requested scope - period_from: {period_from}; period_to: {period_to}; item: {item}; mprn: {mprn}; serial_number: {serial_number}')

results.sort(key=self.__get_interval_end)
return results
Expand Down
4 changes: 3 additions & 1 deletion custom_components/octopus_energy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import homeassistant.helpers.config_validation as cv

DOMAIN = "octopus_energy"
INTEGRATION_VERSION = "13.5.2"
INTEGRATION_VERSION = "13.5.3"

REFRESH_RATE_IN_MINUTES_ACCOUNT = 60
REFRESH_RATE_IN_MINUTES_INTELLIGENT = 3
Expand Down Expand Up @@ -174,6 +174,8 @@
REGEX_WEIGHTING = f"^({REGEX_WEIGHTING_NUMBERS}|{REGEX_WEIGHTING_START}|{REGEX_WEIGHTING_MIDDLE}|{REGEX_WEIGHTING_END})$"

DEFAULT_CALORIFIC_VALUE = 40.0
DEFAULT_BOOST_TEMPERATURE_WATER = 50
DEFAULT_BOOST_TEMPERATURE_HEAT = 30

DATA_SCHEMA_ACCOUNT = vol.Schema({
vol.Required(CONFIG_ACCOUNT_ID): str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ async def async_fetch_consumption_and_rates(
_LOGGER.debug("Dispatches not available for intelligent tariff. Using existing rate information")
return previous_data

if previous_data is not None and previous_data.rates[0]["start"] == period_from and previous_data.rates[-1]["end"] == period_to:
if (previous_data is not None and
previous_data.rates is not None and
len(previous_data.rates) > 0 and
previous_data.rates[0]["start"] == period_from and previous_data.rates[-1]["end"] == period_to):
_LOGGER.info('Previous rates are for our target consumption, so using previously retrieved rates and standing charges')
rate_data = previous_data.rates
standing_charge = { "value_inc_vat": previous_data.standing_charge }
Expand Down Expand Up @@ -302,7 +305,10 @@ async def async_fetch_consumption_and_rates(
_LOGGER.error(f"Could not determine tariff code for previous consumption for gas {identifier}/{serial_number}")
return previous_data

if previous_data is not None and previous_data.rates[0]["start"] == period_from and previous_data.rates[-1]["end"] == period_to:
if (previous_data is not None and
previous_data.rates is not None and
len(previous_data.rates) > 0 and
previous_data.rates[0]["start"] == period_from and previous_data.rates[-1]["end"] == period_to):
_LOGGER.info('Previous rates are for our target consumption, so using previously retrieved rates and standing charges')
rate_data = previous_data.rates
standing_charge = { "value_inc_vat": previous_data.standing_charge }
Expand Down
28 changes: 25 additions & 3 deletions custom_components/octopus_energy/heat_pump/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
from typing import List

from custom_components.octopus_energy.const import DOMAIN
from homeassistant.util.dt import (utcnow)
from homeassistant.exceptions import ServiceValidationError

Expand Down Expand Up @@ -32,6 +31,7 @@
from ..api_client.heat_pump import ConfigurationZone, HeatPump, Sensor, Zone
from ..coordinators.heat_pump_configuration_and_status import HeatPumpCoordinatorResult
from ..api_client import OctopusEnergyApiClient
from ..const import DEFAULT_BOOST_TEMPERATURE_HEAT, DEFAULT_BOOST_TEMPERATURE_WATER, DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -194,7 +194,18 @@ async def async_set_preset_mode(self, preset_mode):
if self._attr_preset_mode == PRESET_BOOST:
self._end_timestamp = utcnow()
self._end_timestamp += timedelta(hours=1)
await self._client.async_boost_heat_pump_zone(self._account_id, self._heat_pump_id, self._zone.configuration.code, self._end_timestamp, self._attr_target_temperature)

boost_temperature = self._attr_target_temperature
if boost_temperature is None:
boost_temperature = DEFAULT_BOOST_TEMPERATURE_WATER if self._zone.configuration.zoneType == "WATER" else DEFAULT_BOOST_TEMPERATURE_HEAT

await self._client.async_boost_heat_pump_zone(
self._account_id,
self._heat_pump_id,
self._zone.configuration.code,
self._end_timestamp,
boost_temperature
)
else:
zone_mode = self.get_zone_mode()
await self._client.async_set_heat_pump_zone_mode(self._account_id, self._heat_pump_id, self._zone.configuration.code, zone_mode, self._attr_target_temperature)
Expand Down Expand Up @@ -242,7 +253,18 @@ async def async_boost_heat_pump_zone(self, hours: int, minutes: int, target_temp
self._end_timestamp = utcnow()
self._end_timestamp += timedelta(hours=hours, minutes=minutes)
self._attr_preset_mode = PRESET_BOOST
await self._client.async_boost_heat_pump_zone(self._account_id, self._heat_pump_id, self._zone.configuration.code, self._end_timestamp, target_temperature if target_temperature is not None else self._attr_target_temperature)

boost_temperature = target_temperature if target_temperature is not None else self._attr_target_temperature
if boost_temperature is None:
boost_temperature = DEFAULT_BOOST_TEMPERATURE_WATER if self._zone.configuration.zoneType == "WATER" else DEFAULT_BOOST_TEMPERATURE_HEAT

await self._client.async_boost_heat_pump_zone(
self._account_id,
self._heat_pump_id,
self._zone.configuration.code,
self._end_timestamp,
boost_temperature
)

self.async_write_ha_state()

Expand Down
2 changes: 1 addition & 1 deletion custom_components/octopus_energy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"pydantic"
],
"ssdp": [],
"version": "13.5.2",
"version": "13.5.3",
"zeroconf": []
}

0 comments on commit 4ad28fd

Please sign in to comment.