mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Avoid timestamp conversion in core State when equal to last_updated (#114911)
This commit is contained in:
parent
5447a1a015
commit
0e2fe3b728
@ -1680,11 +1680,15 @@ class State:
|
|||||||
@cached_property
|
@cached_property
|
||||||
def last_changed_timestamp(self) -> float:
|
def last_changed_timestamp(self) -> float:
|
||||||
"""Timestamp of last change."""
|
"""Timestamp of last change."""
|
||||||
|
if self.last_changed == self.last_updated:
|
||||||
|
return self.last_updated_timestamp
|
||||||
return self.last_changed.timestamp()
|
return self.last_changed.timestamp()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def last_reported_timestamp(self) -> float:
|
def last_reported_timestamp(self) -> float:
|
||||||
"""Timestamp of last report."""
|
"""Timestamp of last report."""
|
||||||
|
if self.last_reported == self.last_updated:
|
||||||
|
return self.last_updated_timestamp
|
||||||
return self.last_reported.timestamp()
|
return self.last_reported.timestamp()
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user