diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index 5abe395a8d7..771d85e3569 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -2056,7 +2056,7 @@ def _sorted_statistics_to_dict( # noqa: C901 seen_statistic_ids: set[str] = set() key_func = itemgetter(metadata_id_idx) for meta_id, group in groupby(stats, key_func): - stats_list = stats_by_meta_id[meta_id] = list(group) + stats_by_meta_id[meta_id] = list(group) seen_statistic_ids.add(metadata[meta_id]["statistic_id"]) # Set all statistic IDs to empty lists in result set to maintain the order