diff --git a/homeassistant/components/recorder/models/state.py b/homeassistant/components/recorder/models/state.py index a939661752f..e9538fb0753 100644 --- a/homeassistant/components/recorder/models/state.py +++ b/homeassistant/components/recorder/models/state.py @@ -151,8 +151,8 @@ def row_to_compressed_state( else: row_last_updated_ts: float = row.last_updated_ts comp_state[COMPRESSED_STATE_LAST_UPDATED] = row_last_updated_ts - if ( - row_changed_changed_ts := row.last_changed_ts - ) and row_last_updated_ts != row_changed_changed_ts: + if row_last_updated_ts != ( + row_changed_changed_ts := getattr(row, "last_changed_ts", None) + ): comp_state[COMPRESSED_STATE_LAST_CHANGED] = row_changed_changed_ts return comp_state