From d53d59eb6c3e4f65bcbcf294dea9f0607c117810 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 f7703b0f1a4..8843e8542eb 100644 --- a/homeassistant/components/mqtt/light/schema_json.py +++ b/homeassistant/components/mqtt/light/schema_json.py @@ -256,7 +256,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: @@ -266,7 +268,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: @@ -276,12 +280,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: @@ -321,7 +329,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.""" @@ -363,7 +374,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 ( ColorMode.COLOR_TEMP in self._supported_color_modes @@ -378,7 +392,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):