mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Improve performance of websocket_api _state_diff_event (#141696)
We can use last_updated_timestamp for the compare since its always calculated when the state is created and comparing floats is much faster than datetime objects
This commit is contained in:
parent
ba8f69d956
commit
d6b48003b6
@ -207,7 +207,7 @@ def _state_diff_event(
|
||||
additions[COMPRESSED_STATE_STATE] = new_state.state
|
||||
if old_state.last_changed != new_state.last_changed:
|
||||
additions[COMPRESSED_STATE_LAST_CHANGED] = new_state.last_changed_timestamp
|
||||
elif old_state.last_updated != new_state.last_updated:
|
||||
elif old_state.last_updated_timestamp != new_state.last_updated_timestamp:
|
||||
additions[COMPRESSED_STATE_LAST_UPDATED] = new_state.last_updated_timestamp
|
||||
if old_state_context.parent_id != new_state_context.parent_id:
|
||||
additions[COMPRESSED_STATE_CONTEXT] = {"parent_id": new_state_context.parent_id}
|
||||
|
Loading…
x
Reference in New Issue
Block a user