mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Only report deprecated device_state_attributes once (#60980)
This commit is contained in:
parent
216ecf3426
commit
ffb4b4df96
@ -241,6 +241,9 @@ class Entity(ABC):
|
|||||||
# If we reported this entity is updated while disabled
|
# If we reported this entity is updated while disabled
|
||||||
_disabled_reported = False
|
_disabled_reported = False
|
||||||
|
|
||||||
|
# If we reported this entity is using deprecated device_state_attributes
|
||||||
|
_deprecated_device_state_attributes_reported = False
|
||||||
|
|
||||||
# Protect for multiple updates
|
# Protect for multiple updates
|
||||||
_update_staged = False
|
_update_staged = False
|
||||||
|
|
||||||
@ -538,7 +541,10 @@ class Entity(ABC):
|
|||||||
extra_state_attributes = self.extra_state_attributes
|
extra_state_attributes = self.extra_state_attributes
|
||||||
# Backwards compatibility for "device_state_attributes" deprecated in 2021.4
|
# Backwards compatibility for "device_state_attributes" deprecated in 2021.4
|
||||||
# Warning added in 2021.12, will be removed in 2022.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()
|
report_issue = self._suggest_report_issue()
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Entity %s (%s) implements device_state_attributes. Please %s",
|
"Entity %s (%s) implements device_state_attributes. Please %s",
|
||||||
@ -546,6 +552,7 @@ class Entity(ABC):
|
|||||||
type(self),
|
type(self),
|
||||||
report_issue,
|
report_issue,
|
||||||
)
|
)
|
||||||
|
self._deprecated_device_state_attributes_reported = True
|
||||||
if extra_state_attributes is None:
|
if extra_state_attributes is None:
|
||||||
extra_state_attributes = self.device_state_attributes
|
extra_state_attributes = self.device_state_attributes
|
||||||
attr.update(extra_state_attributes or {})
|
attr.update(extra_state_attributes or {})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user