From 30a461c55c3f4bc9a77681655eb8ef569d177d3f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 10 Apr 2023 17:13:25 -1000 Subject: [PATCH] bail early --- homeassistant/components/recorder/history/modern.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/recorder/history/modern.py b/homeassistant/components/recorder/history/modern.py index f03dd73a57d..6a15ae774bf 100644 --- a/homeassistant/components/recorder/history/modern.py +++ b/homeassistant/components/recorder/history/modern.py @@ -9,7 +9,6 @@ from operator import itemgetter from typing import Any, cast from sqlalchemy import ( - Column, CompoundSelect, Integer, Select, @@ -690,10 +689,9 @@ def _sorted_states_to_dict( # Append all changes to it for metadata_id, group in states_iter: - attr_cache: dict[str, dict[str, Any]] = {} - prev_state: Column | str | None = None if not (entity_id := metadata_id_to_entity_id.get(metadata_id)): continue + attr_cache: dict[str, dict[str, Any]] = {} ent_results = result[entity_id] if ( not minimal_response @@ -712,6 +710,7 @@ def _sorted_states_to_dict( ) continue + prev_state: str | None = None # With minimal response we only provide a native # State for the first and last response. All the states # in-between only provide the "state" and the