Add guard for non color lights (#9186)

This commit is contained in:
Bram Kragten 2021-05-17 16:24:39 +02:00 committed by GitHub
parent 5abb3dd8c1
commit 4f731baa00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,15 +282,18 @@ class MoreInfoLight extends LitElement {
stateObj.attributes.color_mode === LightColorModes.RGBWW
? Math.round((stateObj.attributes.rgbww_color[4] * 100) / 255)
: undefined;
this._colorBrightnessSliderValue = Math.round(
(Math.max(...getLightCurrentModeRgbColor(stateObj).slice(0, 3)) * 100) /
255
);
this._colorPickerColor = getLightCurrentModeRgbColor(stateObj).slice(
0,
3
) as [number, number, number];
const currentRgbColor = getLightCurrentModeRgbColor(stateObj);
this._colorBrightnessSliderValue = currentRgbColor
? Math.round((Math.max(...currentRgbColor.slice(0, 3)) * 100) / 255)
: undefined;
this._colorPickerColor = currentRgbColor?.slice(0, 3) as [
number,
number,
number
];
} else {
this._brightnessSliderValue = 0;
}