From 4c0872b4e4d44ac651f8f3eb74a9a05abab7e6c9 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Fri, 9 Sep 2022 11:12:09 +0200 Subject: [PATCH] Improve warning messages on invalid received modes (#77909) --- .../components/mqtt/light/schema_json.py | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/mqtt/light/schema_json.py b/homeassistant/components/mqtt/light/schema_json.py index 295b43120d..14eca9569f 100644 --- a/homeassistant/components/mqtt/light/schema_json.py +++ b/homeassistant/components/mqtt/light/schema_json.py @@ -249,7 +249,9 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): except KeyError: pass except ValueError: - _LOGGER.warning("Invalid RGB color value received") + _LOGGER.warning( + "Invalid RGB color value received for entity %s", self.entity_id + ) return try: @@ -259,7 +261,9 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): except KeyError: pass except ValueError: - _LOGGER.warning("Invalid XY color value received") + _LOGGER.warning( + "Invalid XY color value received for entity %s", self.entity_id + ) return try: @@ -269,12 +273,16 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): except KeyError: pass except ValueError: - _LOGGER.warning("Invalid HS color value received") + _LOGGER.warning( + "Invalid HS color value received for entity %s", self.entity_id + ) return else: color_mode = values["color_mode"] if not self._supports_color_mode(color_mode): - _LOGGER.warning("Invalid color mode received") + _LOGGER.warning( + "Invalid color mode received for entity %s", self.entity_id + ) return try: if color_mode == ColorMode.COLOR_TEMP: @@ -314,7 +322,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): self._color_mode = ColorMode.XY self._xy = (x, y) except (KeyError, ValueError): - _LOGGER.warning("Invalid or incomplete color value received") + _LOGGER.warning( + "Invalid or incomplete color value received for entity %s", + self.entity_id, + ) def _prepare_subscribe_topics(self): """(Re)Subscribe to topics.""" @@ -351,7 +362,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): except KeyError: pass except (TypeError, ValueError): - _LOGGER.warning("Invalid brightness value received") + _LOGGER.warning( + "Invalid brightness value received for entity %s", + self.entity_id, + ) if ( self._supported_features @@ -366,7 +380,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): except KeyError: pass except ValueError: - _LOGGER.warning("Invalid color temp value received") + _LOGGER.warning( + "Invalid color temp value received for entity %s", + self.entity_id, + ) if self._supported_features and LightEntityFeature.EFFECT: with suppress(KeyError):