mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Merge pull request #13357 from steverep/fix-some-card-keys
This commit is contained in:
commit
e241b20378
@ -59,9 +59,9 @@ export const getCloudTtsSupportedGenders = (
|
|||||||
if (curLang === language) {
|
if (curLang === language) {
|
||||||
genders.push([
|
genders.push([
|
||||||
gender,
|
gender,
|
||||||
localize(`ui.panel.media-browser.tts.gender_${gender}`) ||
|
gender === "male" || gender === "female"
|
||||||
localize(`ui.panel.config.cloud.account.tts.${gender}`) ||
|
? localize(`ui.panel.config.cloud.account.tts.${gender}`)
|
||||||
gender,
|
: gender,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import type {
|
|||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
import { supportsFeature } from "../common/entity/supports-feature";
|
import { supportsFeature } from "../common/entity/supports-feature";
|
||||||
import { MediaPlayerItemId } from "../components/media-player/ha-media-player-browse";
|
import { MediaPlayerItemId } from "../components/media-player/ha-media-player-browse";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant, TranslationDict } from "../types";
|
||||||
import { UNAVAILABLE_STATES } from "./entity";
|
import { UNAVAILABLE_STATES } from "./entity";
|
||||||
import { isTTSMediaSource } from "./tts";
|
import { isTTSMediaSource } from "./tts";
|
||||||
|
|
||||||
@ -170,14 +170,14 @@ export interface MediaPlayerThumbnail {
|
|||||||
export interface ControlButton {
|
export interface ControlButton {
|
||||||
icon: string;
|
icon: string;
|
||||||
// Used as key for action as well as tooltip and aria-label translation key
|
// Used as key for action as well as tooltip and aria-label translation key
|
||||||
action: string;
|
action: keyof TranslationDict["ui"]["card"]["media_player"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MediaPlayerItem {
|
export interface MediaPlayerItem {
|
||||||
title: string;
|
title: string;
|
||||||
media_content_type: string;
|
media_content_type: string;
|
||||||
media_content_id: string;
|
media_content_id: string;
|
||||||
media_class: string;
|
media_class: keyof TranslationDict["ui"]["components"]["media-browser"]["class"];
|
||||||
children_media_class?: string;
|
children_media_class?: string;
|
||||||
can_play: boolean;
|
can_play: boolean;
|
||||||
can_expand: boolean;
|
can_expand: boolean;
|
||||||
|
@ -246,7 +246,7 @@ export class HuiEnergyUsageGraphCard
|
|||||||
: "",
|
: "",
|
||||||
totalReturned
|
totalReturned
|
||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
"ui.panel.lovelace.cards.energyenergy_usage_graph.total_returned",
|
"ui.panel.lovelace.cards.energy.energy_usage_graph.total_returned",
|
||||||
{ num: formatNumber(totalReturned, locale) }
|
{ num: formatNumber(totalReturned, locale) }
|
||||||
)
|
)
|
||||||
: "",
|
: "",
|
||||||
|
@ -85,7 +85,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
states: ["arm_away", "arm_home"],
|
states: ["arm_away", "arm_home"] as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
this._config = { ...defaults, ...config };
|
this._config = { ...defaults, ...config };
|
||||||
@ -166,7 +166,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
|||||||
<div id="armActions" class="actions">
|
<div id="armActions" class="actions">
|
||||||
${(stateObj.state === "disarmed"
|
${(stateObj.state === "disarmed"
|
||||||
? this._config.states!
|
? this._config.states!
|
||||||
: ["disarm"]
|
: (["disarm"] as const)
|
||||||
).map(
|
).map(
|
||||||
(stateAction) => html`
|
(stateAction) => html`
|
||||||
<mwc-button
|
<mwc-button
|
||||||
@ -221,7 +221,9 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _actionDisplay(entityState: string): string {
|
private _actionDisplay(
|
||||||
|
entityState: NonNullable<AlarmPanelCardConfig["states"]>[number]
|
||||||
|
): string {
|
||||||
return this.hass!.localize(`ui.card.alarm_control_panel.${entityState}`);
|
return this.hass!.localize(`ui.card.alarm_control_panel.${entityState}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { StatisticType } from "../../../data/history";
|
import { StatisticType } from "../../../data/history";
|
||||||
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
||||||
import { FullCalendarView } from "../../../types";
|
import { FullCalendarView, TranslationDict } from "../../../types";
|
||||||
import { Condition } from "../common/validate-condition";
|
import { Condition } from "../common/validate-condition";
|
||||||
import { HuiImage } from "../components/hui-image";
|
import { HuiImage } from "../components/hui-image";
|
||||||
import { LovelaceElementConfig } from "../elements/types";
|
import { LovelaceElementConfig } from "../elements/types";
|
||||||
@ -14,7 +14,7 @@ import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
|||||||
export interface AlarmPanelCardConfig extends LovelaceCardConfig {
|
export interface AlarmPanelCardConfig extends LovelaceCardConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
states?: string[];
|
states?: readonly (keyof TranslationDict["ui"]["card"]["alarm_control_panel"])[];
|
||||||
theme?: string;
|
theme?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ export interface WeatherForecastCardConfig extends LovelaceCardConfig {
|
|||||||
name?: string;
|
name?: string;
|
||||||
show_current?: boolean;
|
show_current?: boolean;
|
||||||
show_forecast?: boolean;
|
show_forecast?: boolean;
|
||||||
secondary_info_attribute?: string;
|
secondary_info_attribute?: keyof TranslationDict["ui"]["card"]["weather"]["attributes"];
|
||||||
theme?: string;
|
theme?: string;
|
||||||
tap_action?: ActionConfig;
|
tap_action?: ActionConfig;
|
||||||
hold_action?: ActionConfig;
|
hold_action?: ActionConfig;
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
cleanupMediaTitle,
|
cleanupMediaTitle,
|
||||||
computeMediaControls,
|
computeMediaControls,
|
||||||
computeMediaDescription,
|
computeMediaDescription,
|
||||||
|
ControlButton,
|
||||||
formatMediaTime,
|
formatMediaTime,
|
||||||
getCurrentProgress,
|
getCurrentProgress,
|
||||||
handleMediaControlClick,
|
handleMediaControlClick,
|
||||||
@ -179,7 +180,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
return this._renderChoosePlayer(stateObj);
|
return this._renderChoosePlayer(stateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
const controls = !this.narrow
|
const controls: ControlButton[] | undefined = !this.narrow
|
||||||
? computeMediaControls(stateObj, true)
|
? computeMediaControls(stateObj, true)
|
||||||
: (stateObj.state === "playing" &&
|
: (stateObj.state === "playing" &&
|
||||||
(supportsFeature(stateObj, SUPPORT_PAUSE) ||
|
(supportsFeature(stateObj, SUPPORT_PAUSE) ||
|
||||||
@ -207,7 +208,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
: "media_stop",
|
: "media_stop",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [{}];
|
: undefined;
|
||||||
const mediaDescription = computeMediaDescription(stateObj);
|
const mediaDescription = computeMediaDescription(stateObj);
|
||||||
const mediaDuration = formatMediaTime(stateObj.attributes.media_duration);
|
const mediaDuration = formatMediaTime(stateObj.attributes.media_duration);
|
||||||
const mediaTitleClean = cleanupMediaTitle(
|
const mediaTitleClean = cleanupMediaTitle(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user