mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Improve warning messages on invalid received modes (#77909)
This commit is contained in:
parent
8b3ce8c58c
commit
d53d59eb6c
@ -256,7 +256,9 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
_LOGGER.warning("Invalid RGB color value received")
|
_LOGGER.warning(
|
||||||
|
"Invalid RGB color value received for entity %s", self.entity_id
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -266,7 +268,9 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
_LOGGER.warning("Invalid XY color value received")
|
_LOGGER.warning(
|
||||||
|
"Invalid XY color value received for entity %s", self.entity_id
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -276,12 +280,16 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
_LOGGER.warning("Invalid HS color value received")
|
_LOGGER.warning(
|
||||||
|
"Invalid HS color value received for entity %s", self.entity_id
|
||||||
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
color_mode = values["color_mode"]
|
color_mode = values["color_mode"]
|
||||||
if not self._supports_color_mode(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
|
return
|
||||||
try:
|
try:
|
||||||
if color_mode == ColorMode.COLOR_TEMP:
|
if color_mode == ColorMode.COLOR_TEMP:
|
||||||
@ -321,7 +329,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
self._color_mode = ColorMode.XY
|
self._color_mode = ColorMode.XY
|
||||||
self._xy = (x, y)
|
self._xy = (x, y)
|
||||||
except (KeyError, ValueError):
|
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):
|
def _prepare_subscribe_topics(self):
|
||||||
"""(Re)Subscribe to topics."""
|
"""(Re)Subscribe to topics."""
|
||||||
@ -363,7 +374,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
_LOGGER.warning("Invalid brightness value received")
|
_LOGGER.warning(
|
||||||
|
"Invalid brightness value received for entity %s",
|
||||||
|
self.entity_id,
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
ColorMode.COLOR_TEMP in self._supported_color_modes
|
ColorMode.COLOR_TEMP in self._supported_color_modes
|
||||||
@ -378,7 +392,10 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
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:
|
if self._supported_features and LightEntityFeature.EFFECT:
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user