Add translation key for area controls
parent
08e7ff0c0b
commit
93347d9546
|
@ -24,7 +24,6 @@ import type {
|
||||||
import { AREA_CONTROLS } from "./types";
|
import { AREA_CONTROLS } from "./types";
|
||||||
|
|
||||||
interface AreaControlsButton {
|
interface AreaControlsButton {
|
||||||
translationKey: string;
|
|
||||||
iconPath: string;
|
iconPath: string;
|
||||||
onService: string;
|
onService: string;
|
||||||
offService: string;
|
offService: string;
|
||||||
|
@ -34,7 +33,6 @@ interface AreaControlsButton {
|
||||||
|
|
||||||
export const AREA_CONTROLS_BUTTONS: Record<AreaControl, AreaControlsButton> = {
|
export const AREA_CONTROLS_BUTTONS: Record<AreaControl, AreaControlsButton> = {
|
||||||
light: {
|
light: {
|
||||||
translationKey: "light",
|
|
||||||
iconPath: mdiLightbulb,
|
iconPath: mdiLightbulb,
|
||||||
filter: {
|
filter: {
|
||||||
domain: "light",
|
domain: "light",
|
||||||
|
@ -44,7 +42,6 @@ export const AREA_CONTROLS_BUTTONS: Record<AreaControl, AreaControlsButton> = {
|
||||||
offService: "light.turn_off",
|
offService: "light.turn_off",
|
||||||
},
|
},
|
||||||
fan: {
|
fan: {
|
||||||
translationKey: "fan",
|
|
||||||
iconPath: mdiFan,
|
iconPath: mdiFan,
|
||||||
filter: {
|
filter: {
|
||||||
domain: "fan",
|
domain: "fan",
|
||||||
|
@ -54,7 +51,6 @@ export const AREA_CONTROLS_BUTTONS: Record<AreaControl, AreaControlsButton> = {
|
||||||
offService: "fan.turn_off",
|
offService: "fan.turn_off",
|
||||||
},
|
},
|
||||||
cover: {
|
cover: {
|
||||||
translationKey: "cover",
|
|
||||||
iconPath: mdiBlindsHorizontal,
|
iconPath: mdiBlindsHorizontal,
|
||||||
filter: {
|
filter: {
|
||||||
domain: "cover",
|
domain: "cover",
|
||||||
|
@ -210,10 +206,6 @@ class HuiAreaControlsCardFeature
|
||||||
class=${active ? "active" : ""}
|
class=${active ? "active" : ""}
|
||||||
style=${styleMap({ "--active-color": color })}
|
style=${styleMap({ "--active-color": color })}
|
||||||
.control=${control}
|
.control=${control}
|
||||||
.label=${this.hass!.localize(
|
|
||||||
// @ts-ignore
|
|
||||||
`ui.dialogs.more_info_control.lawn_mower.${button.translationKey}`
|
|
||||||
)}
|
|
||||||
@click=${this._handleButtonTap}
|
@click=${this._handleButtonTap}
|
||||||
>
|
>
|
||||||
<ha-svg-icon .path=${button.iconPath}></ha-svg-icon>
|
<ha-svg-icon .path=${button.iconPath}></ha-svg-icon>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
HaFormSchema,
|
HaFormSchema,
|
||||||
|
@ -35,7 +36,7 @@ export class HuiAreaControlsCardFeatureEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
private _schema = memoizeOne(
|
private _schema = memoizeOne(
|
||||||
(customizeControls: boolean) =>
|
(localize: LocalizeFunc, customizeControls: boolean) =>
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: "customize_controls",
|
name: "customize_controls",
|
||||||
|
@ -53,7 +54,9 @@ export class HuiAreaControlsCardFeatureEditor
|
||||||
multiple: true,
|
multiple: true,
|
||||||
options: AREA_CONTROLS.concat().map((control) => ({
|
options: AREA_CONTROLS.concat().map((control) => ({
|
||||||
value: control,
|
value: control,
|
||||||
label: control,
|
label: localize(
|
||||||
|
`ui.panel.lovelace.editor.features.types.area-controls.controls_options.${control}`
|
||||||
|
),
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -73,7 +76,7 @@ export class HuiAreaControlsCardFeatureEditor
|
||||||
customize_controls: this._config.controls !== undefined,
|
customize_controls: this._config.controls !== undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const schema = this._schema(data.customize_controls);
|
const schema = this._schema(this.hass.localize, data.customize_controls);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-form
|
<ha-form
|
||||||
|
|
|
@ -7842,8 +7842,13 @@
|
||||||
},
|
},
|
||||||
"area-controls": {
|
"area-controls": {
|
||||||
"label": "Area controls",
|
"label": "Area controls",
|
||||||
|
"customize_controls": "Customize controls",
|
||||||
"controls": "Controls",
|
"controls": "Controls",
|
||||||
"customize_controls": "Customize controls"
|
"controls_options": {
|
||||||
|
"light": "Light",
|
||||||
|
"fan": "Fan",
|
||||||
|
"cover": "Cover"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue