Skip to content

Commit 64c2212

Browse files
authored
Bump min version to 2024.8 (#1659)
1 parent 39c83db commit 64c2212

File tree

10 files changed

+57
-95
lines changed

10 files changed

+57
-95
lines changed

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Mushroom",
33
"filename": "mushroom.js",
4-
"homeassistant": "2024.7.0b0",
4+
"homeassistant": "2024.8",
55
"render_readme": true
66
}

src/cards/alarm-control-panel-card/alarm-control-panel-card-editor.ts

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { html, nothing } from "lit";
22
import { customElement, state } from "lit/decorators.js";
33
import memoizeOne from "memoize-one";
44
import { assert } from "superstruct";
5-
import {
6-
LocalizeFunc,
7-
LovelaceCardEditor,
8-
atLeastHaVersion,
9-
fireEvent,
10-
} from "../../ha";
5+
import { LocalizeFunc, LovelaceCardEditor, fireEvent } from "../../ha";
116
import setupCustomlocalize from "../../localize";
127
import { computeActionsFormSchema } from "../../shared/config/actions-config";
138
import { APPEARANCE_FORM_SCHEMA } from "../../shared/config/appearance-config";
@@ -42,32 +37,28 @@ const states = [
4237
"armed_custom_bypass",
4338
];
4439

45-
const computeSchema = memoizeOne(
46-
(localize: LocalizeFunc, useCallService: boolean): HaFormSchema[] => [
47-
{
48-
name: "entity",
49-
selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } },
50-
},
51-
{ name: "name", selector: { text: {} } },
52-
{
53-
name: "icon",
54-
selector: { icon: {} },
55-
context: { icon_entity: "entity" },
56-
},
57-
...APPEARANCE_FORM_SCHEMA,
58-
{
59-
type: "multi_select",
60-
name: "states",
61-
options: states.map((state) => [
62-
state,
63-
localize(
64-
`ui.card.alarm_control_panel.${state.replace("armed", "arm")}`
65-
),
66-
]) as [string, string][],
67-
},
68-
...computeActionsFormSchema(actions, useCallService),
69-
]
70-
);
40+
const computeSchema = memoizeOne((localize: LocalizeFunc): HaFormSchema[] => [
41+
{
42+
name: "entity",
43+
selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } },
44+
},
45+
{ name: "name", selector: { text: {} } },
46+
{
47+
name: "icon",
48+
selector: { icon: {} },
49+
context: { icon_entity: "entity" },
50+
},
51+
...APPEARANCE_FORM_SCHEMA,
52+
{
53+
type: "multi_select",
54+
name: "states",
55+
options: states.map((state) => [
56+
state,
57+
localize(`ui.card.alarm_control_panel.${state.replace("armed", "arm")}`),
58+
]) as [string, string][],
59+
},
60+
...computeActionsFormSchema(actions),
61+
]);
7162

7263
@customElement(ALARM_CONTROl_PANEL_CARD_EDITOR_NAME)
7364
export class SwitchCardEditor
@@ -91,8 +82,7 @@ export class SwitchCardEditor
9182
return nothing;
9283
}
9384

94-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
95-
const schema = computeSchema(this.hass!.localize, useCallService);
85+
const schema = computeSchema(this.hass!.localize);
9686

9787
return html`
9888
<ha-form

src/cards/chips-card/chips/action-chip-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html, LitElement, nothing } from "lit";
22
import { customElement, property, state } from "lit/decorators.js";
3-
import { atLeastHaVersion, fireEvent, HomeAssistant } from "../../../ha";
3+
import memoizeOne from "memoize-one";
4+
import { fireEvent, HomeAssistant } from "../../../ha";
45
import setupCustomlocalize from "../../../localize";
56
import { computeActionsFormSchema } from "../../../shared/config/actions-config";
67
import { GENERIC_LABELS } from "../../../utils/form/generic-fields";
@@ -10,7 +11,6 @@ import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chi
1011
import { ActionChipConfig } from "../../../utils/lovelace/chip/types";
1112
import { LovelaceChipEditor } from "../../../utils/lovelace/types";
1213
import { DEFAULT_ACTION_ICON } from "./action-chip";
13-
import memoizeOne from "memoize-one";
1414

1515
const actions: UiAction[] = [
1616
"navigate",
@@ -20,7 +20,7 @@ const actions: UiAction[] = [
2020
"none",
2121
];
2222

23-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
23+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2424
{
2525
type: "grid",
2626
name: "",
@@ -32,7 +32,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
3232
{ name: "icon_color", selector: { mush_color: {} } },
3333
],
3434
},
35-
...computeActionsFormSchema(actions, useCallService),
35+
...computeActionsFormSchema(actions),
3636
]);
3737

3838
@customElement(computeChipEditorComponentName("action"))
@@ -61,8 +61,7 @@ export class EntityChipEditor extends LitElement implements LovelaceChipEditor {
6161
return nothing;
6262
}
6363

64-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
65-
const schema = computeSchema(useCallService);
64+
const schema = computeSchema();
6665

6766
return html`
6867
<ha-form

src/cards/chips-card/chips/alarm-control-panel-chip-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html, LitElement, nothing } from "lit";
22
import { customElement, property, state } from "lit/decorators.js";
3-
import { atLeastHaVersion, fireEvent, HomeAssistant } from "../../../ha";
3+
import memoizeOne from "memoize-one";
4+
import { fireEvent, HomeAssistant } from "../../../ha";
45
import setupCustomlocalize from "../../../localize";
56
import { computeActionsFormSchema } from "../../../shared/config/actions-config";
67
import { GENERIC_LABELS } from "../../../utils/form/generic-fields";
@@ -10,7 +11,6 @@ import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chi
1011
import { AlarmControlPanelChipConfig } from "../../../utils/lovelace/chip/types";
1112
import { LovelaceChipEditor } from "../../../utils/lovelace/types";
1213
import { ALARM_CONTROl_PANEL_ENTITY_DOMAINS } from "../../alarm-control-panel-card/const";
13-
import memoizeOne from "memoize-one";
1414

1515
const actions: UiAction[] = [
1616
"more-info",
@@ -21,7 +21,7 @@ const actions: UiAction[] = [
2121
"none",
2222
];
2323

24-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
24+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2525
{
2626
name: "entity",
2727
selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } },
@@ -35,7 +35,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
3535
],
3636
},
3737
{ name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } },
38-
...computeActionsFormSchema(actions, useCallService),
38+
...computeActionsFormSchema(actions),
3939
]);
4040

4141
@customElement(computeChipEditorComponentName("alarm-control-panel"))
@@ -67,8 +67,7 @@ export class AlarmControlPanelChipEditor
6767
return nothing;
6868
}
6969

70-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
71-
const schema = computeSchema(useCallService);
70+
const schema = computeSchema();
7271

7372
return html`
7473
<ha-form

src/cards/chips-card/chips/weather-chip-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html, LitElement, nothing } from "lit";
22
import { customElement, property, state } from "lit/decorators.js";
3-
import { atLeastHaVersion, fireEvent, HomeAssistant } from "../../../ha";
3+
import memoizeOne from "memoize-one";
4+
import { fireEvent, HomeAssistant } from "../../../ha";
45
import setupCustomlocalize from "../../../localize";
56
import { computeActionsFormSchema } from "../../../shared/config/actions-config";
67
import { GENERIC_LABELS } from "../../../utils/form/generic-fields";
@@ -9,7 +10,6 @@ import { UiAction } from "../../../utils/form/ha-selector";
910
import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chip-element";
1011
import { WeatherChipConfig } from "../../../utils/lovelace/chip/types";
1112
import { LovelaceChipEditor } from "../../../utils/lovelace/types";
12-
import memoizeOne from "memoize-one";
1313

1414
const WEATHER_ENTITY_DOMAINS = ["weather"];
1515
const WEATHER_LABELS = ["show_conditions", "show_temperature"];
@@ -23,7 +23,7 @@ const actions: UiAction[] = [
2323
"none",
2424
];
2525

26-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
26+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2727
{ name: "entity", selector: { entity: { domain: WEATHER_ENTITY_DOMAINS } } },
2828
{
2929
type: "grid",
@@ -33,7 +33,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
3333
{ name: "show_temperature", selector: { boolean: {} } },
3434
],
3535
},
36-
...computeActionsFormSchema(actions, useCallService),
36+
...computeActionsFormSchema(actions),
3737
]);
3838

3939
@customElement(computeChipEditorComponentName("weather"))
@@ -68,8 +68,7 @@ export class WeatherChipEditor
6868
return nothing;
6969
}
7070

71-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
72-
const schema = computeSchema(useCallService);
71+
const schema = computeSchema();
7372

7473
return html`
7574
<ha-form

src/cards/person-card/person-card-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { html, nothing } from "lit";
22
import { customElement, state } from "lit/decorators.js";
3+
import memoizeOne from "memoize-one";
34
import { assert } from "superstruct";
4-
import { LovelaceCardEditor, atLeastHaVersion, fireEvent } from "../../ha";
5+
import { LovelaceCardEditor, fireEvent } from "../../ha";
56
import setupCustomlocalize from "../../localize";
67
import { computeActionsFormSchema } from "../../shared/config/actions-config";
78
import { APPEARANCE_FORM_SCHEMA } from "../../shared/config/appearance-config";
@@ -12,7 +13,6 @@ import { UiAction } from "../../utils/form/ha-selector";
1213
import { loadHaComponents } from "../../utils/loader";
1314
import { PERSON_CARD_EDITOR_NAME, PERSON_ENTITY_DOMAINS } from "./const";
1415
import { PersonCardConfig, personCardConfigStruct } from "./person-card-config";
15-
import memoizeOne from "memoize-one";
1616

1717
const actions: UiAction[] = [
1818
"more-info",
@@ -23,12 +23,12 @@ const actions: UiAction[] = [
2323
"none",
2424
];
2525

26-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
26+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2727
{ name: "entity", selector: { entity: { domain: PERSON_ENTITY_DOMAINS } } },
2828
{ name: "name", selector: { text: {} } },
2929
{ name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } },
3030
...APPEARANCE_FORM_SCHEMA,
31-
...computeActionsFormSchema(actions, useCallService),
31+
...computeActionsFormSchema(actions),
3232
]);
3333

3434
@customElement(PERSON_CARD_EDITOR_NAME)
@@ -64,8 +64,7 @@ export class SwitchCardEditor
6464
return nothing;
6565
}
6666

67-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
68-
const schema = computeSchema(useCallService);
67+
const schema = computeSchema();
6968

7069
return html`
7170
<ha-form

src/cards/select-card/select-card-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { html, nothing } from "lit";
22
import { customElement, state } from "lit/decorators.js";
3+
import memoizeOne from "memoize-one";
34
import { assert } from "superstruct";
4-
import { LovelaceCardEditor, atLeastHaVersion, fireEvent } from "../../ha";
5+
import { LovelaceCardEditor, fireEvent } from "../../ha";
56
import setupCustomlocalize from "../../localize";
67
import { computeActionsFormSchema } from "../../shared/config/actions-config";
78
import { APPEARANCE_FORM_SCHEMA } from "../../shared/config/appearance-config";
@@ -12,7 +13,6 @@ import { UiAction } from "../../utils/form/ha-selector";
1213
import { loadHaComponents } from "../../utils/loader";
1314
import { SELECT_CARD_EDITOR_NAME, SELECT_ENTITY_DOMAINS } from "./const";
1415
import { SelectCardConfig, selectCardConfigStruct } from "./select-card-config";
15-
import memoizeOne from "memoize-one";
1616

1717
const actions: UiAction[] = [
1818
"more-info",
@@ -23,7 +23,7 @@ const actions: UiAction[] = [
2323
"none",
2424
];
2525

26-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
26+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2727
{ name: "entity", selector: { entity: { domain: SELECT_ENTITY_DOMAINS } } },
2828
{ name: "name", selector: { text: {} } },
2929
{
@@ -39,7 +39,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
3939
],
4040
},
4141
...APPEARANCE_FORM_SCHEMA,
42-
...computeActionsFormSchema(actions, useCallService),
42+
...computeActionsFormSchema(actions),
4343
]);
4444

4545
@customElement(SELECT_CARD_EDITOR_NAME)
@@ -75,8 +75,7 @@ export class SelectCardEditor
7575
return nothing;
7676
}
7777

78-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
79-
const schema = computeSchema(useCallService);
78+
const schema = computeSchema();
8079

8180
return html`
8281
<ha-form

src/cards/update-card/update-card-editor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { html, nothing } from "lit";
22
import { customElement, state } from "lit/decorators.js";
3+
import memoizeOne from "memoize-one";
34
import { assert } from "superstruct";
4-
import { LovelaceCardEditor, atLeastHaVersion, fireEvent } from "../../ha";
5+
import { LovelaceCardEditor, fireEvent } from "../../ha";
56
import setupCustomlocalize from "../../localize";
67
import { computeActionsFormSchema } from "../../shared/config/actions-config";
78
import { APPEARANCE_FORM_SCHEMA } from "../../shared/config/appearance-config";
@@ -12,7 +13,6 @@ import { UiAction } from "../../utils/form/ha-selector";
1213
import { loadHaComponents } from "../../utils/loader";
1314
import { UPDATE_CARD_EDITOR_NAME, UPDATE_ENTITY_DOMAINS } from "./const";
1415
import { UpdateCardConfig, updateCardConfigStruct } from "./update-card-config";
15-
import memoizeOne from "memoize-one";
1616

1717
const UPDATE_LABELS = ["show_buttons_control"];
1818

@@ -25,7 +25,7 @@ const actions: UiAction[] = [
2525
"none",
2626
];
2727

28-
const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
28+
const computeSchema = memoizeOne((): HaFormSchema[] => [
2929
{ name: "entity", selector: { entity: { domain: UPDATE_ENTITY_DOMAINS } } },
3030
{ name: "name", selector: { text: {} } },
3131
{ name: "icon", selector: { icon: {} }, context: { icon_entity: "entity" } },
@@ -38,7 +38,7 @@ const computeSchema = memoizeOne((useCallService: boolean): HaFormSchema[] => [
3838
{ name: "collapsible_controls", selector: { boolean: {} } },
3939
],
4040
},
41-
...computeActionsFormSchema(actions, useCallService),
41+
...computeActionsFormSchema(actions),
4242
]);
4343

4444
@customElement(UPDATE_CARD_EDITOR_NAME)
@@ -77,8 +77,7 @@ export class UpdateCardEditor
7777
return nothing;
7878
}
7979

80-
const useCallService = !atLeastHaVersion(this.hass.config.version, 2024, 8);
81-
const schema = computeSchema(useCallService);
80+
const schema = computeSchema();
8281

8382
return html`
8483
<ha-form

src/shared/config/actions-config.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,8 @@ export type ActionsSharedConfig = {
1616
};
1717

1818
export const computeActionsFormSchema = (
19-
actions?: UiAction[],
20-
useCallService?: boolean
19+
actions?: UiAction[]
2120
): HaFormSchema[] => {
22-
if (useCallService && actions) {
23-
actions = actions.map((action) => {
24-
if (action === "perform-action") {
25-
return "call-service";
26-
}
27-
return action;
28-
});
29-
}
3021
return [
3122
{
3223
name: "tap_action",

0 commit comments

Comments
 (0)