Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240102.0 #19234

Merged
merged 13 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20240101.0"
version = "20240102.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
4 changes: 4 additions & 0 deletions src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
mdiFlash,
mdiFlower,
mdiFormatListBulleted,
mdiFormatListCheckbox,
mdiFormTextbox,
mdiGauge,
mdiGoogleAssistant,
Expand Down Expand Up @@ -64,6 +65,7 @@ import {
mdiTransmissionTower,
mdiWater,
mdiWaterPercent,
mdiWeatherPartlyCloudy,
mdiWeatherPouring,
mdiWeatherRainy,
mdiWeatherWindy,
Expand Down Expand Up @@ -128,6 +130,7 @@ export const FIXED_DOMAIN_ICONS = {
updater: mdiCloudUpload,
vacuum: mdiRobotVacuum,
wake_word: mdiChatSleep,
weather: mdiWeatherPartlyCloudy,
zone: mdiMapMarkerRadius,
};

Expand Down Expand Up @@ -166,6 +169,7 @@ export const FIXED_DEVICE_CLASS_ICONS = {
precipitation_intensity: mdiWeatherPouring,
pressure: mdiGauge,
reactive_power: mdiFlash,
shopping_List: mdiFormatListCheckbox,
signal_strength: mdiWifi,
sound_pressure: mdiEarHearing,
speed: mdiSpeedometer,
Expand Down
28 changes: 21 additions & 7 deletions src/components/ha-service-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -363,12 +372,14 @@ export class HaServiceControl extends LitElement {
)) ||
serviceData?.description;

return html`<ha-service-picker
.hass=${this.hass}
.value=${this._value?.service}
.disabled=${this.disabled}
@value-changed=${this._serviceChanged}
></ha-service-picker>
return html`${this.hidePicker
? nothing
: html`<ha-service-picker
.hass=${this.hass}
.value=${this._value?.service}
.disabled=${this.disabled}
@value-changed=${this._serviceChanged}
></ha-service-picker>`}
<div class="description">
${description ? html`<p>${description}</p>` : ""}
${this._manifest
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/data/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const CONDITION_GROUPS: AutomationElementGroup = {
icon: mdiDotsHorizontal,
members: {
template: {},
trigger: {},
},
},
} as const;
2 changes: 2 additions & 0 deletions src/data/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const serviceActionStruct: Describe<ServiceAction> = assign(
target: optional(targetStruct),
data: optional(object()),
response_variable: optional(string()),
metadata: optional(object()),
})
);

Expand Down Expand Up @@ -133,6 +134,7 @@ export interface ServiceAction extends BaseAction {
target?: HassServiceTarget;
data?: Record<string, unknown>;
response_variable?: string;
metadata?: Record<string, unknown>;
}

export interface DeviceAction extends BaseAction {
Expand Down
16 changes: 15 additions & 1 deletion src/data/script_i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ const tryDescribeAction = <T extends ActionType>(
const service =
hass.localize(`component.${domain}.services.${serviceName}.name`) ||
hass.services[domain][serviceName]?.name;

if (config.metadata) {
return hass.localize(
`${actionTranslationBaseKey}.service.description.service_name`,
{
domain: domainToName(hass.localize, domain),
name: service || config.service,
targets: formatListWithAnds(hass.locale, targets),
}
);
}

return hass.localize(
`${actionTranslationBaseKey}.service.description.service_based_on_name`,
{
Expand Down Expand Up @@ -404,7 +416,9 @@ const tryDescribeAction = <T extends ActionType>(
if (actionType === "device_action") {
const config = action as DeviceAction;
if (!config.device_id) {
return "Device action";
return hass.localize(
`${actionTranslationBaseKey}.device_id.description.no_device`
);
}
const localized = localizeDeviceAutomationAction(
hass,
Expand Down
6 changes: 3 additions & 3 deletions src/panels/calendar/dialog-calendar-event-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ class DialogCalendarEventEditor extends LitElement {
escapeKeyAction
.heading=${createCloseHeading(
this.hass,
isCreate
? this.hass.localize("ui.components.calendar.event.add")
: this._summary
this.hass.localize(
`ui.components.calendar.event.${isCreate ? "add" : "edit"}`
)
)}
>
<div class="content">
Expand Down
10 changes: 9 additions & 1 deletion src/panels/config/automation/action/ha-automation-action-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -190,7 +192,13 @@ export default class HaAutomationActionRow extends LitElement {
<h3 slot="header">
<ha-svg-icon
class="action-icon"
.path=${ACTION_ICONS[type!]}
.path=${type === "service" &&
"service" in this.action &&
this.action.service
? domainIconWithoutDefault(
computeDomain(this.action.service as string)
) || ACTION_ICONS[type!]
: ACTION_ICONS[type!]}
></ha-svg-icon>
${capitalizeFirstLetter(
describeAction(this.hass, this._entityReg, this.action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading