mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-24 19:04:19 +02:00
* Update test_switch.py * Update test_switch.py * test is now done. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix the test only. test is backwards compatible with the old method. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix _supported_to_attributes everything works now. * pre-commit fixes cannot fix the `function too complex` problem. * ignore test_switch.py in `pre-commit-config.yaml` * Add ignore C901 to test_supported_features * remove commented out code --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bas Nijholt <basnijholt@gmail.com> Co-authored-by: Bas Nijholt <bas@nijho.lt>
This commit is contained in:
parent
adf0d0cf30
commit
47c5ea93e0
2 changed files with 100 additions and 15 deletions
|
|
@ -155,12 +155,13 @@ from .const import (
|
|||
)
|
||||
|
||||
_SUPPORT_OPTS = {
|
||||
"brightness": SUPPORT_BRIGHTNESS,
|
||||
"color_temp": SUPPORT_COLOR_TEMP,
|
||||
"color": SUPPORT_COLOR,
|
||||
"transition": SUPPORT_TRANSITION,
|
||||
COLOR_MODE_BRIGHTNESS: SUPPORT_BRIGHTNESS,
|
||||
COLOR_MODE_COLOR_TEMP: SUPPORT_COLOR_TEMP,
|
||||
CONST_COLOR: SUPPORT_COLOR,
|
||||
ATTR_TRANSITION: SUPPORT_TRANSITION,
|
||||
}
|
||||
|
||||
|
||||
VALID_COLOR_MODES = {
|
||||
COLOR_MODE_BRIGHTNESS: ATTR_BRIGHTNESS,
|
||||
COLOR_MODE_COLOR_TEMP: ATTR_COLOR_TEMP_KELVIN,
|
||||
|
|
@ -642,16 +643,18 @@ def _expand_light_groups(hass: HomeAssistant, lights: list[str]) -> list[str]:
|
|||
def _supported_to_attributes(supported):
|
||||
supported_attributes = {}
|
||||
supports_colors = False
|
||||
for mode, attr in VALID_COLOR_MODES.items():
|
||||
if mode not in supported:
|
||||
continue
|
||||
supported_attributes[attr] = True
|
||||
if (
|
||||
not supports_colors
|
||||
and mode != COLOR_MODE_BRIGHTNESS
|
||||
and mode != COLOR_MODE_COLOR_TEMP
|
||||
):
|
||||
supports_colors = True
|
||||
for mode in supported:
|
||||
attr = VALID_COLOR_MODES.get(mode)
|
||||
if attr:
|
||||
supported_attributes[attr] = True
|
||||
if attr in COLOR_ATTRS:
|
||||
supports_colors = True
|
||||
# ATTR_SUPPORTED_FEATURES only
|
||||
elif mode in _SUPPORT_OPTS:
|
||||
supported_attributes[mode] = True
|
||||
if CONST_COLOR in supported_attributes:
|
||||
supports_colors = True
|
||||
supported_attributes.pop(CONST_COLOR)
|
||||
return supported_attributes, supports_colors
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue