mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Fix unneeded dict values for MATCH_ALL recorder attrs exclude (#120804)
* Small cleanup to handling MATCH_ALL recorder attrs exclude * Fix unneeded dict values for MATCH_ALL recorder attrs exclude The exclude is a set so the dict values were not needed * Fix unneeded dict values for MATCH_ALL recorder attrs exclude The exclude is a set so the dict values were not needed * Fix unneeded dict values for MATCH_ALL recorder attrs exclude The exclude is a set so the dict values were not needed
This commit is contained in:
parent
0ec07001bd
commit
66932e3d9a
@ -142,6 +142,13 @@ _DEFAULT_TABLE_ARGS = {
|
||||
"mariadb_engine": MYSQL_ENGINE,
|
||||
}
|
||||
|
||||
_MATCH_ALL_KEEP = {
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_STATE_CLASS,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
}
|
||||
|
||||
|
||||
class UnusedDateTime(DateTime):
|
||||
"""An unused column type that behaves like a datetime."""
|
||||
@ -597,19 +604,8 @@ class StateAttributes(Base):
|
||||
if MATCH_ALL in unrecorded_attributes:
|
||||
# Don't exclude device class, state class, unit of measurement
|
||||
# or friendly name when using the MATCH_ALL exclude constant
|
||||
_exclude_attributes = {
|
||||
k: v
|
||||
for k, v in state.attributes.items()
|
||||
if k
|
||||
not in (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_STATE_CLASS,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
)
|
||||
}
|
||||
exclude_attrs.update(_exclude_attributes)
|
||||
|
||||
exclude_attrs.update(state.attributes)
|
||||
exclude_attrs -= _MATCH_ALL_KEEP
|
||||
else:
|
||||
exclude_attrs = ALL_DOMAIN_EXCLUDE_ATTRS
|
||||
encoder = json_bytes_strip_null if dialect == PSQL_DIALECT else json_bytes
|
||||
|
Loading…
x
Reference in New Issue
Block a user