From ae33670b33b07eaa757191e1feecc22e71ee3f16 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Wed, 26 Jul 2023 11:37:13 +0200 Subject: [PATCH] Add guard for missing xy color support in Matter light platform (#97251) --- homeassistant/components/matter/light.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/matter/light.py b/homeassistant/components/matter/light.py index 02919baa8f1..52a6b4162fe 100644 --- a/homeassistant/components/matter/light.py +++ b/homeassistant/components/matter/light.py @@ -337,10 +337,16 @@ class MatterLight(MatterEntity, LightEntity): # set current values if self.supports_color: - self._attr_color_mode = self._get_color_mode() - if self._attr_color_mode == ColorMode.HS: + self._attr_color_mode = color_mode = self._get_color_mode() + if ( + ColorMode.HS in self._attr_supported_color_modes + and color_mode == ColorMode.HS + ): self._attr_hs_color = self._get_hs_color() - else: + elif ( + ColorMode.XY in self._attr_supported_color_modes + and color_mode == ColorMode.XY + ): self._attr_xy_color = self._get_xy_color() if self.supports_color_temperature: