From 0e2fe3b72825daf6c89a17843ba61c2836be2eb2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 4 Apr 2024 20:27:27 -1000 Subject: [PATCH] Avoid timestamp conversion in core State when equal to last_updated (#114911) --- homeassistant/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homeassistant/core.py b/homeassistant/core.py index f8540ae7e70..f94a7d4c1bb 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -1680,11 +1680,15 @@ class State: @cached_property def last_changed_timestamp(self) -> float: """Timestamp of last change.""" + if self.last_changed == self.last_updated: + return self.last_updated_timestamp return self.last_changed.timestamp() @cached_property def last_reported_timestamp(self) -> float: """Timestamp of last report.""" + if self.last_reported == self.last_updated: + return self.last_updated_timestamp return self.last_reported.timestamp() @cached_property