Don't assume that effect list is not null (#15764)
* Don't assume that effect list is not null * Don't assume that rgb, rgbw and rgbww are definedpull/15779/head
parent
4f1c4bdcb9
commit
4ab1723c99
|
@ -201,10 +201,11 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
|||
this._brightnessAdjusted = undefined;
|
||||
if (
|
||||
stateObj.attributes.color_mode === LightColorMode.RGB &&
|
||||
stateObj.attributes.rgb_color &&
|
||||
!lightSupportsColorMode(stateObj, LightColorMode.RGBWW) &&
|
||||
!lightSupportsColorMode(stateObj, LightColorMode.RGBW)
|
||||
) {
|
||||
const maxVal = Math.max(...stateObj.attributes.rgb_color!);
|
||||
const maxVal = Math.max(...stateObj.attributes.rgb_color);
|
||||
|
||||
if (maxVal < 255) {
|
||||
this._brightnessAdjusted = maxVal;
|
||||
|
@ -216,16 +217,19 @@ class MoreInfoViewLightColorPicker extends LitElement {
|
|||
: undefined;
|
||||
|
||||
this._wvSliderValue =
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBW
|
||||
? Math.round((stateObj.attributes.rgbw_color![3] * 100) / 255)
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBW &&
|
||||
stateObj.attributes.rgbw_color
|
||||
? Math.round((stateObj.attributes.rgbw_color[3] * 100) / 255)
|
||||
: undefined;
|
||||
this._cwSliderValue =
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBWW
|
||||
? Math.round((stateObj.attributes.rgbww_color![3] * 100) / 255)
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBWW &&
|
||||
stateObj.attributes.rgbww_color
|
||||
? Math.round((stateObj.attributes.rgbww_color[3] * 100) / 255)
|
||||
: undefined;
|
||||
this._wwSliderValue =
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBWW
|
||||
? Math.round((stateObj.attributes.rgbww_color![4] * 100) / 255)
|
||||
stateObj.attributes.color_mode === LightColorMode.RGBWW &&
|
||||
stateObj.attributes.rgbww_color
|
||||
? Math.round((stateObj.attributes.rgbww_color[4] * 100) / 255)
|
||||
: undefined;
|
||||
|
||||
const currentRgbColor = getLightCurrentModeRgbColor(stateObj);
|
||||
|
|
|
@ -148,7 +148,7 @@ class MoreInfoLight extends LitElement {
|
|||
</md-outlined-icon-button>
|
||||
`
|
||||
: null}
|
||||
${supportsEffects
|
||||
${supportsEffects && this.stateObj.attributes.effect_list
|
||||
? html`
|
||||
<ha-button-menu
|
||||
corner="BOTTOM_START"
|
||||
|
@ -169,7 +169,7 @@ class MoreInfoLight extends LitElement {
|
|||
>
|
||||
<ha-svg-icon .path=${mdiCreation}></ha-svg-icon>
|
||||
</md-outlined-icon-button>
|
||||
${this.stateObj.attributes.effect_list!.map(
|
||||
${this.stateObj.attributes.effect_list.map(
|
||||
(effect: string) => html`
|
||||
<mwc-list-item
|
||||
.value=${effect}
|
||||
|
|
Loading…
Reference in New Issue