From 386f4fe3f51dd9e99662cbd11596e7a499a3e1ad Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 10 Apr 2023 12:57:38 -1000 Subject: [PATCH] tweak --- homeassistant/components/recorder/models/state.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/recorder/models/state.py b/homeassistant/components/recorder/models/state.py index 01a9e3a332b..c443525701a 100644 --- a/homeassistant/components/recorder/models/state.py +++ b/homeassistant/components/recorder/models/state.py @@ -144,8 +144,10 @@ def row_to_compressed_state( } row_last_updated_ts: float = row.last_updated_ts comp_state[COMPRESSED_STATE_LAST_UPDATED] = row_last_updated_ts - if row_last_updated_ts != ( - row_changed_changed_ts := getattr(row, "last_changed_ts", None) + if ( + (row_last_changed_ts := getattr(row, "last_changed_ts", None)) + and row_last_changed_ts + and row_last_updated_ts != row_last_changed_ts ): - comp_state[COMPRESSED_STATE_LAST_CHANGED] = row_changed_changed_ts + comp_state[COMPRESSED_STATE_LAST_CHANGED] = row_last_changed_ts return comp_state