From 79d339c4446a775304568d6bfd1cff4f9da80939 Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Mon, 27 May 2024 11:41:26 +0100 Subject: [PATCH] fix: Added some additional checks around cost tracker attributes --- custom_components/octopus_energy/cost_tracker/cost_tracker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/octopus_energy/cost_tracker/cost_tracker.py b/custom_components/octopus_energy/cost_tracker/cost_tracker.py index 36f9c31d..59f7bef4 100644 --- a/custom_components/octopus_energy/cost_tracker/cost_tracker.py +++ b/custom_components/octopus_energy/cost_tracker/cost_tracker.py @@ -171,8 +171,8 @@ async def _async_calculate_cost(self, event: Event[EventStateChangedData]): old_last_reset = parse_datetime(old_state.attributes["last_reset"]) consumption_data = add_consumption(current, - self._attributes["tracked_charges"], - self._attributes["untracked_charges"], + self._attributes["tracked_charges"] if "tracked_charges" in self._attributes else [], + self._attributes["untracked_charges"] if "untracked_charges" in self._attributes else [], float(new_state.state), None if old_state.state is None or old_state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else float(old_state.state), new_last_reset,