Add zones support to flux_led (#61072)

This commit is contained in:
J. Nick Koston 2021-12-20 06:45:34 -06:00 committed by GitHub
parent 3d75befe0a
commit abc7dcf6bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 122 additions and 2 deletions

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from flux_led.aio import AIOWifiLedBulb
from flux_led.const import COLOR_MODE_DIM as FLUX_COLOR_MODE_DIM
from flux_led.const import COLOR_MODE_DIM as FLUX_COLOR_MODE_DIM, MultiColorEffects
from homeassistant.components.light import (
COLOR_MODE_BRIGHTNESS,
@ -34,3 +34,12 @@ def _flux_color_mode_to_hass(
def _effect_brightness(brightness: int) -> int:
"""Convert hass brightness to effect brightness."""
return round(brightness / 255 * 100)
def _str_to_multi_color_effect(effect_str: str) -> MultiColorEffects:
"""Convert an multicolor effect string to MultiColorEffects."""
for effect in MultiColorEffects:
if effect.name.lower() == effect_str:
return effect
# unreachable due to schema validation
assert False # pragma: no cover