mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 22:07:20 +00:00
Fix some key type errors in cards
This commit is contained in:
parent
12239d7fe3
commit
d23d774ec1
@ -34,7 +34,7 @@ import type {
|
||||
} from "home-assistant-js-websocket";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
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 { isTTSMediaSource } from "./tts";
|
||||
|
||||
@ -170,7 +170,7 @@ export interface MediaPlayerThumbnail {
|
||||
export interface ControlButton {
|
||||
icon: string;
|
||||
// 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 {
|
||||
|
@ -246,7 +246,7 @@ export class HuiEnergyUsageGraphCard
|
||||
: "",
|
||||
totalReturned
|
||||
? 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) }
|
||||
)
|
||||
: "",
|
||||
|
@ -85,7 +85,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
states: ["arm_away", "arm_home"],
|
||||
states: ["arm_away", "arm_home"] as const,
|
||||
};
|
||||
|
||||
this._config = { ...defaults, ...config };
|
||||
@ -166,7 +166,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
<div id="armActions" class="actions">
|
||||
${(stateObj.state === "disarmed"
|
||||
? this._config.states!
|
||||
: ["disarm"]
|
||||
: (["disarm"] as const)
|
||||
).map(
|
||||
(stateAction) => html`
|
||||
<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}`);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { StatisticType } from "../../../data/history";
|
||||
import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import { FullCalendarView } from "../../../types";
|
||||
import { FullCalendarView, TranslationDict } from "../../../types";
|
||||
import { Condition } from "../common/validate-condition";
|
||||
import { HuiImage } from "../components/hui-image";
|
||||
import { LovelaceElementConfig } from "../elements/types";
|
||||
@ -14,7 +14,7 @@ import { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||
export interface AlarmPanelCardConfig extends LovelaceCardConfig {
|
||||
entity: string;
|
||||
name?: string;
|
||||
states?: string[];
|
||||
states?: readonly (keyof TranslationDict["ui"]["card"]["alarm_control_panel"])[];
|
||||
theme?: string;
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ export interface WeatherForecastCardConfig extends LovelaceCardConfig {
|
||||
name?: string;
|
||||
show_current?: boolean;
|
||||
show_forecast?: boolean;
|
||||
secondary_info_attribute?: string;
|
||||
secondary_info_attribute?: keyof TranslationDict["ui"]["card"]["weather"]["attributes"];
|
||||
theme?: string;
|
||||
tap_action?: ActionConfig;
|
||||
hold_action?: ActionConfig;
|
||||
|
Loading…
x
Reference in New Issue
Block a user