From 493d78f070e60421d06165645bd0a06e95ad3c10 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 May 2023 19:59:15 -0500 Subject: [PATCH] Avoid dict comp in statistic_during_period if there is no conversion (#93699) --- homeassistant/components/recorder/statistics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index 7dbe29cea7d..ee9662a2157 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -1478,7 +1478,9 @@ def statistic_during_period( state_unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) convert = _get_statistic_to_display_unit_converter(unit, state_unit, units) - return {key: convert(value) if convert else value for key, value in result.items()} + if not convert: + return result + return {key: convert(value) for key, value in result.items()} _type_column_mapping = {