Send color_brightness to ESPHome devices on 1.20 (pre-color_mode) (#54670)

This commit is contained in:
Jesse Hills 2021-08-16 14:56:21 +12:00 committed by GitHub
parent d091068092
commit 41d932fcf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,8 +105,8 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
color_bri = max(rgb)
# normalize rgb
data["rgb"] = tuple(x / (color_bri or 1) for x in rgb)
data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = LightColorMode.RGB
if (rgbw_ha := kwargs.get(ATTR_RGBW_COLOR)) is not None:
@ -116,8 +116,8 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
# normalize rgb
data["rgb"] = tuple(x / (color_bri or 1) for x in rgb)
data["white"] = w
data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = LightColorMode.RGB_WHITE
if (rgbww_ha := kwargs.get(ATTR_RGBWW_COLOR)) is not None:
@ -144,8 +144,8 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity):
data["color_temperature"] = min_ct + ct_ratio * (max_ct - min_ct)
target_mode = LightColorMode.RGB_COLOR_TEMPERATURE
data["color_brightness"] = color_bri
if self._supports_color_mode:
data["color_brightness"] = color_bri
data["color_mode"] = target_mode
if (flash := kwargs.get(ATTR_FLASH)) is not None: