Don't show edit favorite colors button if the light doesn't support it (#16750)

This commit is contained in:
Paul Bottein 2023-06-05 09:39:36 +02:00 committed by GitHub
parent 21f983572c
commit 9f3e8abe69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,10 @@ export const lightSupportsBrightness = (entity: LightEntity) =>
modesSupportingBrightness.includes(mode)
) || false;
export const lightSupportsFavoriteColors = (entity: LightEntity) =>
lightSupportsColor(entity) ||
lightSupportsColorMode(entity, LightColorMode.COLOR_TEMP);
export const getLightCurrentModeRgbColor = (
entity: LightEntity
): number[] | undefined =>

View File

@ -37,6 +37,7 @@ import {
lightSupportsBrightness,
lightSupportsColor,
lightSupportsColorMode,
lightSupportsFavoriteColors,
} from "../../../data/light";
import type { HomeAssistant } from "../../../types";
import { moreInfoControlStyle } from "../components/ha-more-info-control-style";
@ -206,7 +207,9 @@ class MoreInfoLight extends LitElement {
`
: nothing}
</div>
${this.entry && (this.editMode || hasFavoriteColors)
${this.entry &&
lightSupportsFavoriteColors(this.stateObj) &&
(this.editMode || hasFavoriteColors)
? html`
<ha-more-info-light-favorite-colors
.hass=${this.hass}

View File

@ -32,6 +32,7 @@ import {
ExtEntityRegistryEntry,
getExtendedEntityRegistryEntry,
} from "../../data/entity_registry";
import { lightSupportsFavoriteColors } from "../../data/light";
import { SearchableDomains } from "../../data/search";
import { haStyleDialog } from "../../resources/styles";
import "../../state-summary/state-card-content";
@ -359,7 +360,10 @@ export class MoreInfoDialog extends LitElement {
</ha-list-item>
`
: nothing}
${this._entry && domain === "light"
${this._entry &&
stateObj &&
domain === "light" &&
lightSupportsFavoriteColors(stateObj)
? html`
<ha-list-item
graphic="icon"