diff --git a/homeassistant/components/light/mysensors.py b/homeassistant/components/light/mysensors.py index 6f8e984b799..479fb717213 100644 --- a/homeassistant/components/light/mysensors.py +++ b/homeassistant/components/light/mysensors.py @@ -138,19 +138,22 @@ class MySensorsLight(mysensors.MySensorsDeviceEntity, Light): rgb = self._rgb white = self._white hex_color = self._values.get(self.value_type) + new_rgb = kwargs.get(ATTR_RGB_COLOR) + new_white = kwargs.get(ATTR_WHITE_VALUE) - if ATTR_WHITE_VALUE in kwargs and \ - kwargs[ATTR_WHITE_VALUE] != self._white: - white = kwargs[ATTR_WHITE_VALUE] - - if ATTR_RGB_COLOR in kwargs and \ - kwargs[ATTR_RGB_COLOR] != self._rgb: - rgb = list(kwargs[ATTR_RGB_COLOR]) - if white is not None and hex_template == '%02x%02x%02x%02x': - rgb.append(white) - hex_color = hex_template % tuple(rgb) - self.gateway.set_child_value( - self.node_id, self.child_id, self.value_type, hex_color) + if new_rgb is None and new_white is None: + return + if new_rgb is not None: + rgb = list(new_rgb) + if rgb is None: + return + if new_white is not None and hex_template == '%02x%02x%02x%02x': + rgb.append(new_white) + hex_color = hex_template % tuple(rgb) + if len(rgb) > 3: + white = rgb.pop() + self.gateway.set_child_value( + self.node_id, self.child_id, self.value_type, hex_color) if self.gateway.optimistic: # optimistically assume that light has changed state diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 8f84c89eb25..b3df02e8b34 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -2,12 +2,13 @@ import argparse import logging import os +from collections import OrderedDict from glob import glob from platform import system from unittest.mock import patch from typing import Dict, List, Sequence -from collections import OrderedDict + import homeassistant.bootstrap as bootstrap import homeassistant.config as config_util import homeassistant.loader as loader @@ -270,6 +271,6 @@ def dump_dict(layer, indent_count=3, listi=False, **kwargs): if isinstance(layer, Sequence): for i in layer: if isinstance(i, dict): - dump_dict(i, indent_count+2, True) + dump_dict(i, indent_count + 2, True) else: print(' ', indent_str, i)