Fix websocket_api _state_diff_event using json_encoder_default (#96905)
This commit is contained in:
parent
c80085367d
commit
dae264f79e
2 changed files with 19 additions and 1 deletions
|
@ -180,7 +180,10 @@ def _state_diff(
|
|||
if old_attributes.get(key) != value:
|
||||
additions.setdefault(COMPRESSED_STATE_ATTRIBUTES, {})[key] = value
|
||||
if removed := set(old_attributes).difference(new_attributes):
|
||||
diff[STATE_DIFF_REMOVALS] = {COMPRESSED_STATE_ATTRIBUTES: removed}
|
||||
# sets are not JSON serializable by default so we convert to list
|
||||
# here if there are any values to avoid jumping into the json_encoder_default
|
||||
# for every state diff with a removed attribute
|
||||
diff[STATE_DIFF_REMOVALS] = {COMPRESSED_STATE_ATTRIBUTES: list(removed)}
|
||||
return {ENTITY_EVENT_CHANGE: {new_state.entity_id: diff}}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue