Skip to content

Commit 5792bc5

Browse files
committed
Support more-info entity in action editor and add divider to template card interactions
1 parent d8a90ff commit 5792bc5

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎src/cards/template-card/template-card-editor.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { customElement, property, state } from "lit/decorators.js";
33
import memoizeOne from "memoize-one";
44
import { assert } from "superstruct";
55
import {
6+
atLeastHaVersion,
67
fireEvent,
78
HASSDomEvent,
89
LocalizeFunc,
@@ -95,7 +96,11 @@ export class MushroomTemplateCardEditor
9596
);
9697

9798
private _schema = memoizeOne(
98-
(localize: LocalizeFunc, entityId: string | undefined) =>
99+
(
100+
localize: LocalizeFunc,
101+
entityId: string | undefined,
102+
supportDivider: boolean
103+
) =>
99104
[
100105
{
101106
name: "context",
@@ -178,6 +183,9 @@ export class MushroomTemplateCardEditor
178183
},
179184
},
180185
},
186+
...(supportDivider
187+
? ([{ name: "", type: "divider" }] as const)
188+
: []),
181189
{
182190
name: "icon_tap_action",
183191
selector: {
@@ -295,7 +303,11 @@ export class MushroomTemplateCardEditor
295303
return nothing;
296304
}
297305

298-
const schema = this._schema(this.hass.localize, this._config.entity);
306+
const schema = this._schema(
307+
this.hass.localize,
308+
this._config.entity,
309+
atLeastHaVersion(this.hass.connection.haVersion, 2026, 9)
310+
);
299311
const customLocalize = setupCustomlocalize(this.hass!);
300312

301313
const data = {

‎src/ha/data/lovelace.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export interface CallServiceActionConfig extends BaseActionConfig {
148148
export interface NavigateActionConfig extends BaseActionConfig {
149149
action: "navigate";
150150
navigation_path: string;
151+
navigation_replace?: boolean;
151152
}
152153

153154
export interface UrlActionConfig extends BaseActionConfig {
@@ -157,6 +158,7 @@ export interface UrlActionConfig extends BaseActionConfig {
157158

158159
export interface MoreInfoActionConfig extends BaseActionConfig {
159160
action: "more-info";
161+
entity?: string;
160162
}
161163

162164
export interface NoActionConfig extends BaseActionConfig {

‎src/ha/panels/lovelace/editor/structs/action-struct.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const actionConfigStructService = object({
5151
const actionConfigStructNavigate = object({
5252
action: literal("navigate"),
5353
navigation_path: string(),
54+
navigation_replace: optional(boolean()),
5455
confirmation: optional(actionConfigStructConfirmation),
5556
});
5657

@@ -60,6 +61,11 @@ const actionConfigStructAssist = type({
6061
start_listening: optional(boolean()),
6162
});
6263

64+
const actionConfigStructMoreInfo = type({
65+
action: literal("more-info"),
66+
entity: optional(string()),
67+
});
68+
6369
const actionConfigStructCustom = type({
6470
action: literal("fire-dom-event"),
6571
});
@@ -99,6 +105,9 @@ export const actionConfigStruct = dynamic<any>((value) => {
99105
case "assist": {
100106
return actionConfigStructAssist;
101107
}
108+
case "more-info": {
109+
return actionConfigStructMoreInfo;
110+
}
102111
}
103112
}
104113

‎src/utils/form/ha-form.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface HaDurationData {
1010

1111
export type HaFormSchema =
1212
| HaFormConstantSchema
13+
| HaFormDividerSchema
1314
| HaFormStringSchema
1415
| HaFormIntegerSchema
1516
| HaFormFloatSchema
@@ -70,6 +71,10 @@ export interface HaFormConstantSchema extends HaFormBaseSchema {
7071
value?: string;
7172
}
7273

74+
export interface HaFormDividerSchema extends HaFormBaseSchema {
75+
type: "divider";
76+
}
77+
7378
export interface HaFormIntegerSchema extends HaFormBaseSchema {
7479
type: "integer";
7580
default?: HaFormIntegerData;

0 commit comments

Comments
 (0)