mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +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
|
||||
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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user