Only report deprecated device_state_attributes once (#60980)

pull/60993/head
Franck Nijhof 2021-12-04 13:37:42 +01:00 committed by GitHub
parent 216ecf3426
commit ffb4b4df96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -241,6 +241,9 @@ class Entity(ABC):
# If we reported this entity is updated while disabled
_disabled_reported = False
# If we reported this entity is using deprecated device_state_attributes
_deprecated_device_state_attributes_reported = False
# Protect for multiple updates
_update_staged = False
@ -538,7 +541,10 @@ class Entity(ABC):
extra_state_attributes = self.extra_state_attributes
# Backwards compatibility for "device_state_attributes" deprecated in 2021.4
# Warning added in 2021.12, will be removed in 2022.4
if self.device_state_attributes is not None:
if (
self.device_state_attributes is not None
and not self._deprecated_device_state_attributes_reported
):
report_issue = self._suggest_report_issue()
_LOGGER.warning(
"Entity %s (%s) implements device_state_attributes. Please %s",
@ -546,6 +552,7 @@ class Entity(ABC):
type(self),
report_issue,
)
self._deprecated_device_state_attributes_reported = True
if extra_state_attributes is None:
extra_state_attributes = self.device_state_attributes
attr.update(extra_state_attributes or {})