Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/components/ha-service-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,16 @@
? computeObjectId(this._value.action)
: undefined;

const descriptionPlaceholders =
domain && serviceName
? this.hass.services[domain][serviceName].description_placeholders

Check failure on line 469 in src/components/ha-service-control.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
: undefined;

const description =
(serviceName &&
this.hass.localize(
`component.${domain}.services.${serviceName}.description`
`component.${domain}.services.${serviceName}.description`,
descriptionPlaceholders
)) ||
serviceData?.description;

Expand Down Expand Up @@ -536,7 +542,8 @@
.disabled=${this.disabled}
.value=${this._value?.data?.entity_id}
.label=${this.hass.localize(
`component.${domain}.services.${serviceName}.fields.entity_id.description`
`component.${domain}.services.${serviceName}.fields.entity_id.description`,
descriptionPlaceholders
) || entityId.description}
@value-changed=${this._entityPicked}
allow-custom-entity
Expand Down Expand Up @@ -574,7 +581,8 @@
left-chevron
.expanded=${!dataField.collapsed}
.header=${this.hass.localize(
`component.${domain}.services.${serviceName}.sections.${dataField.key}.name`
`component.${domain}.services.${serviceName}.sections.${dataField.key}.name`,
descriptionPlaceholders
) ||
dataField.name ||
dataField.key}
Expand Down Expand Up @@ -610,7 +618,10 @@
serviceName: string | undefined
) {
return this.hass!.localize(
`component.${domain}.services.${serviceName}.sections.${dataField.key}.description`
`component.${domain}.services.${serviceName}.sections.${dataField.key}.description`,
domain && serviceName
? this.hass.services[domain][serviceName].description_placeholders

Check failure on line 623 in src/components/ha-service-control.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
: undefined
);
}

Expand Down Expand Up @@ -657,6 +668,10 @@
}

const showOptional = showOptionalToggle(dataField);
const descriptionPlaceholders =
domain && serviceName
? this.hass.services[domain][serviceName].description_placeholders

Check failure on line 673 in src/components/ha-service-control.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
: undefined;

return dataField.selector &&
(!dataField.advanced ||
Expand All @@ -678,14 +693,16 @@
></ha-checkbox>`}
<span slot="heading"
>${this.hass.localize(
`component.${domain}.services.${serviceName}.fields.${dataField.key}.name`
`component.${domain}.services.${serviceName}.fields.${dataField.key}.name`,
descriptionPlaceholders
) ||
dataField.name ||
dataField.key}</span
>
<span slot="description"
>${this.hass.localize(
`component.${domain}.services.${serviceName}.fields.${dataField.key}.description`
`component.${domain}.services.${serviceName}.fields.${dataField.key}.description`,
descriptionPlaceholders
) || dataField?.description}</span
>
<ha-selector
Expand Down
17 changes: 14 additions & 3 deletions src/components/ha-service-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@
`;
}

const descriptionPlaceholders =
this.hass.services[domain][service].description_placeholders;

Check failure on line 96 in src/components/ha-service-picker.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.

const serviceName =
localize(`component.${domain}.services.${service}.name`) ||
localize(
`component.${domain}.services.${service}.name`,
descriptionPlaceholders
) ||
services[domain][service].name ||
service;

Expand Down Expand Up @@ -163,16 +169,21 @@
const serviceId = `${domain}.${service}`;
const domainName = domainToName(localize, domain);

const descriptionPlaceholders =
this.hass.services[domain][service].description_placeholders;

Check failure on line 173 in src/components/ha-service-picker.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.

const name =
this.hass.localize(
`component.${domain}.services.${service}.name`
`component.${domain}.services.${service}.name`,
descriptionPlaceholders
) ||
services[domain][service].name ||
service;

const description =
this.hass.localize(
`component.${domain}.services.${service}.description`
`component.${domain}.services.${service}.description`,
descriptionPlaceholders
) ||
services[domain][service].description ||
"";
Expand Down
8 changes: 6 additions & 2 deletions src/data/script_i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@

if (config.action) {
const [domain, serviceName] = config.action.split(".", 2);
const descriptionPlaceholders =
hass.services[domain][serviceName].description_placeholders;

Check failure on line 223 in src/data/script_i18n.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
const service =
hass.localize(`component.${domain}.services.${serviceName}.name`) ||
hass.services[domain][serviceName]?.name;
hass.localize(
`component.${domain}.services.${serviceName}.name`,
descriptionPlaceholders
) || hass.services[domain][serviceName]?.name;

if (config.metadata) {
return hass.localize(
Expand Down
8 changes: 6 additions & 2 deletions src/panels/config/automation/add-automation-element-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,17 @@
`,
key: `${SERVICE_PREFIX}${dmn}.${service}`,
name: `${domain ? "" : `${domainToName(localize, dmn)}: `}${
this.hass.localize(`component.${dmn}.services.${service}.name`) ||
this.hass.localize(
`component.${dmn}.services.${service}.name`,
this.hass.services[dmn][service].description_placeholders

Check failure on line 561 in src/panels/config/automation/add-automation-element-dialog.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
) ||
services[dmn][service]?.name ||
service
}`,
description:
this.hass.localize(
`component.${dmn}.services.${service}.description`
`component.${dmn}.services.${service}.description`,
this.hass.services[dmn][service].description_placeholders

Check failure on line 569 in src/panels/config/automation/add-automation-element-dialog.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
) ||
services[dmn][service]?.description ||
"",
Expand Down
17 changes: 14 additions & 3 deletions src/panels/developer-tools/action/developer-tools-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
? computeObjectId(this._serviceData?.action)
: undefined;

const descriptionPlaceholders =
domain && serviceName
? this.hass.services[domain][serviceName].description_placeholders

Check failure on line 140 in src/panels/developer-tools/action/developer-tools-action.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
: undefined;

return html`
<div class="content">
<p>
Expand Down Expand Up @@ -307,12 +312,14 @@
<td><pre>${field.key}</pre></td>
<td>
${this.hass.localize(
`component.${domain}.services.${serviceName}.fields.${field.key}.description`
`component.${domain}.services.${serviceName}.fields.${field.key}.description`,
descriptionPlaceholders
) || field.description}
</td>
<td>
${this.hass.localize(
`component.${domain}.services.${serviceName}.fields.${field.key}.example`
`component.${domain}.services.${serviceName}.fields.${field.key}.example`,
descriptionPlaceholders
) || field.example}
</td>
</tr>`
Expand Down Expand Up @@ -643,7 +650,11 @@
} catch (_err: any) {
value =
this.hass.localize(
`component.${domain}.services.${serviceName}.fields.${field.key}.example`
`component.${domain}.services.${serviceName}.fields.${field.key}.example`,
domain && serviceName
? this.hass.services[domain][serviceName]
.description_placeholders

Check failure on line 656 in src/panels/developer-tools/action/developer-tools-action.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

Property 'description_placeholders' does not exist on type 'HassService'.
: undefined
) || field.example;
}
example[field.key] = value;
Expand Down
4 changes: 3 additions & 1 deletion src/panels/logbook/ha-logbook-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ class HaLogbookRenderer extends LitElement {
? `${domainToName(this.hass.localize, item.context_domain)}:
${
this.hass.localize(
`component.${item.context_domain}.services.${item.context_service}.name`
`component.${item.context_domain}.services.${item.context_service}.name`,
this.hass.services[item.context_domain][item.context_service]
.description_placeholders
) ||
this.hass.services[item.context_domain]?.[item.context_service]?.name ||
item.context_service
Expand Down
5 changes: 4 additions & 1 deletion src/panels/lovelace/common/handle-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export const handleAction = async (
await hass.loadBackendTranslation("title");
const localize = await hass.loadBackendTranslation("services");
serviceName = `${domainToName(localize, domain)}: ${
localize(`component.${domain}.services.${service}.name`) ||
localize(
`component.${domain}.services.${service}.name`,
hass.services[domain][service].description_placeholders
) ||
serviceDomains[domain][service].name ||
service
}`;
Expand Down
Loading