Fix mysensors white value (#3508)

* Fix turning on mysensors light with white value attribute in kwargs.
* Fix import order in check_config.py.
This commit is contained in:
Martin Hjelmare 2016-09-24 23:45:01 +02:00 committed by GitHub
parent 36921748ed
commit 986873834a
2 changed files with 18 additions and 14 deletions

View File

@ -138,17 +138,20 @@ class MySensorsLight(mysensors.MySensorsDeviceEntity, Light):
rgb = self._rgb rgb = self._rgb
white = self._white white = self._white
hex_color = self._values.get(self.value_type) 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 \ if new_rgb is None and new_white is None:
kwargs[ATTR_WHITE_VALUE] != self._white: return
white = kwargs[ATTR_WHITE_VALUE] if new_rgb is not None:
rgb = list(new_rgb)
if ATTR_RGB_COLOR in kwargs and \ if rgb is None:
kwargs[ATTR_RGB_COLOR] != self._rgb: return
rgb = list(kwargs[ATTR_RGB_COLOR]) if new_white is not None and hex_template == '%02x%02x%02x%02x':
if white is not None and hex_template == '%02x%02x%02x%02x': rgb.append(new_white)
rgb.append(white)
hex_color = hex_template % tuple(rgb) hex_color = hex_template % tuple(rgb)
if len(rgb) > 3:
white = rgb.pop()
self.gateway.set_child_value( self.gateway.set_child_value(
self.node_id, self.child_id, self.value_type, hex_color) self.node_id, self.child_id, self.value_type, hex_color)

View File

@ -2,12 +2,13 @@
import argparse import argparse
import logging import logging
import os import os
from collections import OrderedDict
from glob import glob from glob import glob
from platform import system from platform import system
from unittest.mock import patch from unittest.mock import patch
from typing import Dict, List, Sequence from typing import Dict, List, Sequence
from collections import OrderedDict
import homeassistant.bootstrap as bootstrap import homeassistant.bootstrap as bootstrap
import homeassistant.config as config_util import homeassistant.config as config_util
import homeassistant.loader as loader import homeassistant.loader as loader