From ffb4b4df96125e73f0744a2928faa09e0afc7764 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 4 Dec 2021 13:37:42 +0100 Subject: [PATCH] Only report deprecated device_state_attributes once (#60980) --- homeassistant/helpers/entity.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 86c8fa86af5..cd04f9db184 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -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 {})