diff --git a/src/components/ha-service-control.ts b/src/components/ha-service-control.ts index f1ae8ee54bac..119418355c64 100644 --- a/src/components/ha-service-control.ts +++ b/src/components/ha-service-control.ts @@ -4,7 +4,14 @@ import { HassServices, HassServiceTarget, } from "home-assistant-js-websocket"; -import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; +import { + css, + CSSResultGroup, + html, + LitElement, + PropertyValues, + nothing, +} from "lit"; import { customElement, property, query, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { ensureArray } from "../common/array/ensure-array"; @@ -83,6 +90,8 @@ export class HaServiceControl extends LitElement { @property({ type: Boolean }) public showAdvanced?: boolean; + @property({ type: Boolean, reflect: true }) public hidePicker?: boolean; + @state() private _value!: this["value"]; @state() private _checkedKeys = new Set(); @@ -363,12 +372,14 @@ export class HaServiceControl extends LitElement { )) || serviceData?.description; - return html` + return html`${this.hidePicker + ? nothing + : html``}
${description ? html`

${description}

` : ""} ${this._manifest @@ -735,6 +746,9 @@ export class HaServiceControl extends LitElement { margin: var(--service-control-padding, 0 16px); padding: 16px 0; } + :host([hidePicker]) p { + padding-top: 0; + } .checkbox-spacer { width: 32px; } diff --git a/src/data/script.ts b/src/data/script.ts index f0b5e7151b51..08910dc88fcb 100644 --- a/src/data/script.ts +++ b/src/data/script.ts @@ -52,6 +52,7 @@ export const serviceActionStruct: Describe = assign( target: optional(targetStruct), data: optional(object()), response_variable: optional(string()), + metadata: optional(object()), }) ); @@ -133,6 +134,7 @@ export interface ServiceAction extends BaseAction { target?: HassServiceTarget; data?: Record; response_variable?: string; + metadata?: Record; } export interface DeviceAction extends BaseAction { diff --git a/src/data/script_i18n.ts b/src/data/script_i18n.ts index 4b07b84f0ed5..3d7d8c5a1da4 100644 --- a/src/data/script_i18n.ts +++ b/src/data/script_i18n.ts @@ -168,8 +168,11 @@ const tryDescribeAction = ( const service = hass.localize(`component.${domain}.services.${serviceName}.name`) || hass.services[domain][serviceName]?.name; + return hass.localize( - `${actionTranslationBaseKey}.service.description.service_based_on_name`, + `${actionTranslationBaseKey}.service.description.${ + config.metadata ? "service_name" : "service_based_on_name" + }`, { name: service ? `${domainToName(hass.localize, domain)}: ${service}` diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index f09c901c8e1a..0e58c0e8b2b5 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -29,6 +29,8 @@ import { classMap } from "lit/directives/class-map"; import { storage } from "../../../../common/decorators/storage"; import { dynamicElement } from "../../../../common/dom/dynamic-element-directive"; import { fireEvent } from "../../../../common/dom/fire_event"; +import { computeDomain } from "../../../../common/entity/compute_domain"; +import { domainIconWithoutDefault } from "../../../../common/entity/domain_icon"; import { capitalizeFirstLetter } from "../../../../common/string/capitalize-first-letter"; import { handleStructError } from "../../../../common/structs/handle-errors"; import "../../../../components/ha-alert"; @@ -190,7 +192,13 @@ export default class HaAutomationActionRow extends LitElement {

${capitalizeFirstLetter( describeAction(this.hass, this._entityReg, this.action) diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index dca4bab6acde..ce312a7bd399 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -191,6 +191,7 @@ export default class HaAutomationAction extends LitElement { } else if (isService(action)) { actions = this.actions.concat({ service: getService(action), + metadata: {}, }); } else { const elClass = customElements.get( diff --git a/src/translations/en.json b/src/translations/en.json index c176cf65c96a..e771c8fe1910 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2914,6 +2914,7 @@ "description": { "service_based_on_template": "Call a service based on a template on {targets}", "service_based_on_name": "Call a service ''{name}'' on {targets}", + "service_name": "''{name}'' on {targets}", "service": "Call a service", "target_template": "templated {name}", "target_unknown_entity": "unknown entity",