From 4ab1723c9978ead437bd9ae85d05991bebd69506 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 8 Mar 2023 10:24:28 +0100 Subject: [PATCH] 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 defined --- .../ha-more-info-view-light-color-picker.ts | 18 +++++++++++------- .../more-info/controls/more-info-light.ts | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/dialogs/more-info/components/lights/ha-more-info-view-light-color-picker.ts b/src/dialogs/more-info/components/lights/ha-more-info-view-light-color-picker.ts index 29f1158628..59828417c2 100644 --- a/src/dialogs/more-info/components/lights/ha-more-info-view-light-color-picker.ts +++ b/src/dialogs/more-info/components/lights/ha-more-info-view-light-color-picker.ts @@ -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); diff --git a/src/dialogs/more-info/controls/more-info-light.ts b/src/dialogs/more-info/controls/more-info-light.ts index e708e9b30f..cac953da44 100644 --- a/src/dialogs/more-info/controls/more-info-light.ts +++ b/src/dialogs/more-info/controls/more-info-light.ts @@ -148,7 +148,7 @@ class MoreInfoLight extends LitElement { ` : null} - ${supportsEffects + ${supportsEffects && this.stateObj.attributes.effect_list ? html` - ${this.stateObj.attributes.effect_list!.map( + ${this.stateObj.attributes.effect_list.map( (effect: string) => html`