mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Small code quality improvements for subscribe_entities (#68026)
This commit is contained in:
parent
0070e27c04
commit
68310a426b
@ -175,18 +175,16 @@ def compressed_state_dict_add(state: State) -> dict[str, Any]:
|
||||
Sends c (context) as a string if it only contains an id.
|
||||
"""
|
||||
if state.context.parent_id is None and state.context.user_id is None:
|
||||
context: dict[str, Any] | str = state.context.id # type: ignore[unreachable]
|
||||
context: dict[str, Any] | str = state.context.id
|
||||
else:
|
||||
context = state.context.as_dict()
|
||||
compressed_state: dict[str, Any] = {
|
||||
COMPRESSED_STATE_STATE: state.state,
|
||||
COMPRESSED_STATE_ATTRIBUTES: state.attributes,
|
||||
COMPRESSED_STATE_CONTEXT: context,
|
||||
COMPRESSED_STATE_LAST_CHANGED: state.last_changed.timestamp(),
|
||||
}
|
||||
if state.last_changed == state.last_updated:
|
||||
compressed_state[COMPRESSED_STATE_LAST_CHANGED] = state.last_changed.timestamp()
|
||||
else:
|
||||
compressed_state[COMPRESSED_STATE_LAST_CHANGED] = state.last_changed.timestamp()
|
||||
if state.last_changed != state.last_updated:
|
||||
compressed_state[COMPRESSED_STATE_LAST_UPDATED] = state.last_updated.timestamp()
|
||||
return compressed_state
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user