mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 10:26:35 +00:00
Add types to hass object (#1776)
This commit is contained in:
parent
b8cee5cc9c
commit
8e49241e7c
78
src/types.ts
78
src/types.ts
@ -1,13 +1,87 @@
|
|||||||
import { HassEntities, HassConfig } from "home-assistant-js-websocket";
|
import {
|
||||||
|
HassEntities,
|
||||||
|
HassConfig,
|
||||||
|
Auth,
|
||||||
|
Connection,
|
||||||
|
MessageBase,
|
||||||
|
} from "home-assistant-js-websocket";
|
||||||
|
|
||||||
|
export interface Credential {
|
||||||
|
auth_provider_type: string;
|
||||||
|
auth_provider_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MFAModule {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
id: string;
|
||||||
|
is_owner: boolean;
|
||||||
|
name: string;
|
||||||
|
credentials: Credential[];
|
||||||
|
mfa_modules: MFAModule[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Theme {
|
||||||
|
// Incomplete
|
||||||
|
"primary-color": string;
|
||||||
|
"text-primary-color": string;
|
||||||
|
"accent-color": string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Panel {
|
||||||
|
component_name: string;
|
||||||
|
config?: { [key: string]: any };
|
||||||
|
icon: string;
|
||||||
|
title: string;
|
||||||
|
url_path: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Translation {
|
||||||
|
nativeName: string;
|
||||||
|
fingerprints: { [fragment: string]: string };
|
||||||
|
}
|
||||||
|
|
||||||
export interface HomeAssistant {
|
export interface HomeAssistant {
|
||||||
|
auth: Auth;
|
||||||
|
conn: Connection;
|
||||||
|
connected: boolean;
|
||||||
states: HassEntities;
|
states: HassEntities;
|
||||||
config: HassConfig;
|
config: HassConfig;
|
||||||
|
themes: {
|
||||||
|
default_theme: string;
|
||||||
|
themes: { [key: string]: Theme };
|
||||||
|
};
|
||||||
|
panels: { [key: string]: Panel };
|
||||||
|
panelUrl: string;
|
||||||
language: string;
|
language: string;
|
||||||
resources: { [key: string]: any };
|
resources: { [key: string]: any };
|
||||||
|
translationMetadata: {
|
||||||
|
fragments: string[];
|
||||||
|
translations: {
|
||||||
|
[lang: string]: Translation;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
dockedSidebar: boolean;
|
||||||
|
moreInfoEntityId: string;
|
||||||
|
user: User;
|
||||||
callService: (
|
callService: (
|
||||||
domain: string,
|
domain: string,
|
||||||
service: string,
|
service: string,
|
||||||
serviceData: { [key: string]: any }
|
serviceData?: { [key: string]: any }
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
|
callApi: <T>(
|
||||||
|
method: "GET" | "POST" | "PUT" | "DELETE",
|
||||||
|
path: string,
|
||||||
|
parameters?: { [key: string]: any }
|
||||||
|
) => Promise<T>;
|
||||||
|
fetchWithAuth: (
|
||||||
|
path: string,
|
||||||
|
init?: { [key: string]: any }
|
||||||
|
) => Promise<Response>;
|
||||||
|
sendWS: (msg: MessageBase) => Promise<void>;
|
||||||
|
callWS: <T>(msg: MessageBase) => Promise<T>;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user