From ddc092a3a46fe77afe8f52e8f7bfff5a86c76008 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski <75446+jpawlowski@users.noreply.github.com> Date: Tue, 9 Dec 2025 18:36:37 +0000 Subject: [PATCH] fix(statistics): handle None median value in price statistics calculation --- .../coordinator/period_handlers/period_statistics.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/tibber_prices/coordinator/period_handlers/period_statistics.py b/custom_components/tibber_prices/coordinator/period_handlers/period_statistics.py index 90de761..5b158d9 100644 --- a/custom_components/tibber_prices/coordinator/period_handlers/period_statistics.py +++ b/custom_components/tibber_prices/coordinator/period_handlers/period_statistics.py @@ -107,7 +107,8 @@ def calculate_period_price_statistics(period_price_data: list[dict]) -> dict[str } price_mean = round(sum(prices_minor) / len(prices_minor), 2) - price_median = round(calculate_median(prices_minor), 2) + median_value = calculate_median(prices_minor) + price_median = round(median_value, 2) if median_value is not None else 0.0 price_min = round(min(prices_minor), 2) price_max = round(max(prices_minor), 2) price_spread = round(price_max - price_min, 2)