diff --git a/custom_components/octopus_energy/api_client/__init__.py b/custom_components/octopus_energy/api_client/__init__.py index 378b93b5..2b922c3b 100644 --- a/custom_components/octopus_energy/api_client/__init__.py +++ b/custom_components/octopus_energy/api_client/__init__.py @@ -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 @@ -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