From 4b3d4b275e85fdc58896bdd338a58f176a2728c7 Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Tue, 15 Jan 2019 19:12:23 -0500 Subject: [PATCH] Zha light.turn_on service fixes. (#20085) Set color only if light supports color mode. Set color temp only light supports color temp. Update entity's brightness only if Zigbee command to set the brightness was sent successfuly. --- homeassistant/components/zha/light.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 5b06e8fa321..c1a875e465a 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -155,7 +155,8 @@ class Light(ZhaEntity, light.Light): duration = kwargs.get(light.ATTR_TRANSITION, DEFAULT_DURATION) duration = duration * 10 # tenths of s - if light.ATTR_COLOR_TEMP in kwargs: + if light.ATTR_COLOR_TEMP in kwargs and \ + self.supported_features & light.SUPPORT_COLOR_TEMP: temperature = kwargs[light.ATTR_COLOR_TEMP] try: res = await self._endpoint.light_color.move_to_color_temp( @@ -168,7 +169,8 @@ class Light(ZhaEntity, light.Light): return self._color_temp = temperature - if light.ATTR_HS_COLOR in kwargs: + if light.ATTR_HS_COLOR in kwargs and \ + self.supported_features & light.SUPPORT_COLOR: self._hs_color = kwargs[light.ATTR_HS_COLOR] xy_color = color_util.color_hs_to_xy(*self._hs_color) try: @@ -187,7 +189,6 @@ class Light(ZhaEntity, light.Light): if self._brightness is not None: brightness = kwargs.get( light.ATTR_BRIGHTNESS, self._brightness or 255) - self._brightness = brightness # Move to level with on/off: try: res = await self._endpoint.level.move_to_level_with_on_off( @@ -201,6 +202,7 @@ class Light(ZhaEntity, light.Light): self.entity_id, ex) return self._state = 1 + self._brightness = brightness self.async_schedule_update_ha_state() return