diff --git a/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts b/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts index 240b9b3e1..a2097c5f5 100644 --- a/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts +++ b/src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts @@ -2,12 +2,7 @@ import { html, nothing } from "lit"; import { customElement, state } from "lit/decorators.js"; import memoizeOne from "memoize-one"; import { assert } from "superstruct"; -import { - LocalizeFunc, - LovelaceCardEditor, - atLeastHaVersion, - fireEvent, -} from "../../ha"; +import { LocalizeFunc, LovelaceCardEditor, fireEvent } from "../../ha"; import setupCustomlocalize from "../../localize"; import { computeActionsFormSchema } from "../../shared/config/actions-config"; import { APPEARANCE_FORM_SCHEMA } from "../../shared/config/appearance-config"; @@ -42,32 +37,28 @@ const states = [ "armed_custom_bypass", ]; -const computeSchema = memoizeOne( - (localize: LocalizeFunc, useCallService: boolean): HaFormSchema[] => [ - { - name: "entity", - selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } }, - }, - { name: "name", selector: { text: {} } }, - { - name: "icon", - selector: { icon: {} }, - context: { icon_entity: "entity" }, - }, - ...APPEARANCE_FORM_SCHEMA, - { - type: "multi_select", - name: "states", - options: states.map((state) => [ - state, - localize( - `ui.card.alarm_control_panel.${state.replace("armed", "arm")}` - ), - ]) as [string, string][], - }, - ...computeActionsFormSchema(actions, useCallService), - ] -); +const computeSchema = memoizeOne((localize: LocalizeFunc): HaFormSchema[] => [ + { + name: "entity", + selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } }, + }, + { name: "name", selector: { text: {} } }, + { + name: "icon", + selector: { icon: {} }, + context: { icon_entity: "entity" }, + }, + ...APPEARANCE_FORM_SCHEMA, + { + type: "multi_select", + name: "states", + options: states.map((state) => [ + state, + localize(`ui.card.alarm_control_panel.${state.replace("armed", "arm")}`), + ]) as [string, string][], + }, + ...computeActionsFormSchema(actions), +]); @customElement(ALARM_CONTROl_PANEL_CARD_EDITOR_NAME) export class SwitchCardEditor @@ -91,8 +82,7 @@ export class SwitchCardEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(this.hass!.localize, useCallService); + const schema = computeSchema(this.hass!.localize); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { type: "grid", name: "", @@ -32,7 +32,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [ { name: "icon_color", selector: { mush_color: {} } }, ], }, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(computeChipEditorComponentName("action")) @@ -61,8 +61,7 @@ export class EntityChipEditor extends LitElement implements LovelaceChipEditor { return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { name: "entity", selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } }, @@ -35,7 +35,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [ ], }, { name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } }, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(computeChipEditorComponentName("alarm-control-panel")) @@ -67,8 +67,7 @@ export class AlarmControlPanelChipEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { name: "entity", selector: { entity: { domain: WEATHER_ENTITY_DOMAINS } } }, { type: "grid", @@ -33,7 +33,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [ { name: "show_temperature", selector: { boolean: {} } }, ], }, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(computeChipEditorComponentName("weather")) @@ -68,8 +68,7 @@ export class WeatherChipEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { name: "entity", selector: { entity: { domain: PERSON_ENTITY_DOMAINS } } }, { name: "name", selector: { text: {} } }, { name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } }, ...APPEARANCE_FORM_SCHEMA, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(PERSON_CARD_EDITOR_NAME) @@ -64,8 +64,7 @@ export class SwitchCardEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { name: "entity", selector: { entity: { domain: SELECT_ENTITY_DOMAINS } } }, { name: "name", selector: { text: {} } }, { @@ -39,7 +39,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [ ], }, ...APPEARANCE_FORM_SCHEMA, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(SELECT_CARD_EDITOR_NAME) @@ -75,8 +75,7 @@ export class SelectCardEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` [ +const computeSchema = memoizeOne((): HaFormSchema[] => [ { name: "entity", selector: { entity: { domain: UPDATE_ENTITY_DOMAINS } } }, { name: "name", selector: { text: {} } }, { name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } }, @@ -38,7 +38,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [ { name: "collapsible_controls", selector: { boolean: {} } }, ], }, - ...computeActionsFormSchema(actions, useCallService), + ...computeActionsFormSchema(actions), ]); @customElement(UPDATE_CARD_EDITOR_NAME) @@ -77,8 +77,7 @@ export class UpdateCardEditor return nothing; } - const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8); - const schema = computeSchema(useCallService); + const schema = computeSchema(); return html` { - if (useCallService && actions) { - actions = actions.map((action) => { - if (action === "perform-action") { - return "call-service"; - } - return action; - }); - } return [ { name: "tap_action", diff --git a/src/utils/base-element.ts b/src/utils/base-element.ts index 139adc8d6..2b469a142 100644 --- a/src/utils/base-element.ts +++ b/src/utils/base-element.ts @@ -1,6 +1,6 @@ import { css, CSSResultGroup, LitElement, PropertyValues } from "lit"; import { property } from "lit/decorators.js"; -import { atLeastHaVersion, HomeAssistant } from "../ha"; +import { HomeAssistant } from "../ha"; import "../shared/badge-icon"; import "../shared/card"; import "../shared/shape-avatar"; @@ -18,13 +18,6 @@ export function computeDarkMode(hass?: HomeAssistant): boolean { export class MushroomBaseElement extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - protected firstUpdated(_changedProperties: PropertyValues): void { - this.toggleAttribute( - "pre-2024-8", - !atLeastHaVersion(this.hass.config.version, 2024, 8) - ); - } - protected updated(changedProps: PropertyValues): void { super.updated(changedProps); if (changedProps.has("hass") && this.hass) { @@ -50,12 +43,6 @@ export class MushroomBaseElement extends LitElement { ${themeColorCss} ${themeVariables} } - :host([pre-2024-8]) { - --spacing: var(--mush-spacing, 12px); - --control-height: var(--mush-control-height, 40px); - --control-spacing: var(--mush-spacing, 12px); - --icon-size: var(--mush-icon-size, 40px); - } `, ]; }