diff --git a/src/panels/lovelace/components/hui-action-editor.ts b/src/panels/lovelace/components/hui-action-editor.ts index d6b57b239e..eed1d23c67 100644 --- a/src/panels/lovelace/components/hui-action-editor.ts +++ b/src/panels/lovelace/components/hui-action-editor.ts @@ -49,10 +49,15 @@ export class HuiActionEditor extends LitElement { return config.url_path || ""; } + get _service(): string { + const config = this.config as CallServiceActionConfig; + return config.service || ""; + } + private _serviceAction = memoizeOne( (config: CallServiceActionConfig): ServiceAction => { return { - service: config.service || "", + service: this._service, data: config.service_data, target: config.target, }; @@ -155,8 +160,25 @@ export class HuiActionEditor extends LitElement { } return; } + + let data; + switch (value) { + case "url": { + data = { url_path: this._url_path }; + break; + } + case "call-service": { + data = { service: this._service }; + break; + } + case "navigate": { + data = { navigation_path: this._navigation_path }; + break; + } + } + fireEvent(this, "value-changed", { - value: { action: value }, + value: { action: value, ...data }, }); } diff --git a/src/panels/lovelace/editor/types.ts b/src/panels/lovelace/editor/types.ts index c37c3e084d..762ed55d6e 100644 --- a/src/panels/lovelace/editor/types.ts +++ b/src/panels/lovelace/editor/types.ts @@ -120,13 +120,13 @@ const actionConfigStructConfirmation = union([ const actionConfigStructUrl = object({ action: literal("url"), - url_path: optional(string()), + url_path: string(), confirmation: optional(actionConfigStructConfirmation), }); const actionConfigStructService = object({ action: literal("call-service"), - service: optional(string()), + service: string(), service_data: optional(object()), target: optional( object({ @@ -140,7 +140,7 @@ const actionConfigStructService = object({ const actionConfigStructNavigate = object({ action: literal("navigate"), - navigation_path: optional(string()), + navigation_path: string(), confirmation: optional(actionConfigStructConfirmation), });