mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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:
parent
36921748ed
commit
986873834a
@ -138,19 +138,22 @@ 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:
|
||||||
self.gateway.set_child_value(
|
white = rgb.pop()
|
||||||
self.node_id, self.child_id, self.value_type, hex_color)
|
self.gateway.set_child_value(
|
||||||
|
self.node_id, self.child_id, self.value_type, hex_color)
|
||||||
|
|
||||||
if self.gateway.optimistic:
|
if self.gateway.optimistic:
|
||||||
# optimistically assume that light has changed state
|
# optimistically assume that light has changed state
|
||||||
|
@ -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
|
||||||
@ -270,6 +271,6 @@ def dump_dict(layer, indent_count=3, listi=False, **kwargs):
|
|||||||
if isinstance(layer, Sequence):
|
if isinstance(layer, Sequence):
|
||||||
for i in layer:
|
for i in layer:
|
||||||
if isinstance(i, dict):
|
if isinstance(i, dict):
|
||||||
dump_dict(i, indent_count+2, True)
|
dump_dict(i, indent_count + 2, True)
|
||||||
else:
|
else:
|
||||||
print(' ', indent_str, i)
|
print(' ', indent_str, i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user