mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
Reduce number of time calls needed to write state (#116297)
This commit is contained in:
@@ -2205,6 +2205,7 @@ class StateMachine:
|
||||
force_update: bool = False,
|
||||
context: Context | None = None,
|
||||
state_info: StateInfo | None = None,
|
||||
timestamp: float | None = None,
|
||||
) -> None:
|
||||
"""Set the state of an entity, add entity if it does not exist.
|
||||
|
||||
@@ -2244,7 +2245,8 @@ class StateMachine:
|
||||
# timestamp implementation:
|
||||
# https://github.com/python/cpython/blob/c90a862cdcf55dc1753c6466e5fa4a467a13ae24/Modules/_datetimemodule.c#L6387
|
||||
# https://github.com/python/cpython/blob/c90a862cdcf55dc1753c6466e5fa4a467a13ae24/Modules/_datetimemodule.c#L6323
|
||||
timestamp = time.time()
|
||||
if timestamp is None:
|
||||
timestamp = time.time()
|
||||
now = dt_util.utc_from_timestamp(timestamp)
|
||||
|
||||
if same_state and same_attr:
|
||||
|
||||
Reference in New Issue
Block a user