mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
More foundations
This commit is contained in:
parent
fb634a2092
commit
a6abc88007
@ -9,6 +9,7 @@ export const entitiesContext =
|
||||
export const devicesContext =
|
||||
createContext<HomeAssistant["devices"]>("devices");
|
||||
export const areasContext = createContext<HomeAssistant["areas"]>("areas");
|
||||
export const labelsContext = createContext<HomeAssistant["labels"]>("labels");
|
||||
export const localizeContext =
|
||||
createContext<HomeAssistant["localize"]>("localize");
|
||||
export const localeContext = createContext<HomeAssistant["locale"]>("locale");
|
||||
|
@ -27,6 +27,7 @@ export interface DeviceRegistryEntry {
|
||||
entry_type: "service" | null;
|
||||
disabled_by: "user" | "integration" | "config_entry" | null;
|
||||
configuration_url: string | null;
|
||||
labels: string[];
|
||||
}
|
||||
|
||||
export interface DeviceEntityDisplayLookup {
|
||||
|
@ -20,6 +20,7 @@ export interface EntityRegistryDisplayEntry {
|
||||
translation_key?: string;
|
||||
platform?: string;
|
||||
display_precision?: number;
|
||||
labels?: string[];
|
||||
}
|
||||
|
||||
interface EntityRegistryDisplayEntryResponse {
|
||||
@ -33,6 +34,7 @@ interface EntityRegistryDisplayEntryResponse {
|
||||
tk?: string;
|
||||
hb?: boolean;
|
||||
dp?: number;
|
||||
lb?: string[];
|
||||
}[];
|
||||
entity_categories: Record<number, entityCategory>;
|
||||
}
|
||||
@ -54,6 +56,7 @@ export interface EntityRegistryEntry {
|
||||
unique_id: string;
|
||||
translation_key?: string;
|
||||
options: EntityRegistryOptions | null;
|
||||
labels: string[];
|
||||
}
|
||||
|
||||
export interface ExtEntityRegistryEntry extends EntityRegistryEntry {
|
||||
|
@ -14,6 +14,7 @@ import { subscribeAreaRegistry } from "../data/area_registry";
|
||||
import { broadcastConnectionStatus } from "../data/connection-status";
|
||||
import { subscribeDeviceRegistry } from "../data/device_registry";
|
||||
import { subscribeEntityRegistryDisplay } from "../data/entity_registry";
|
||||
import { subscribeLabelRegistry } from "../data/label_registry";
|
||||
import { subscribeFrontendUserData } from "../data/frontend";
|
||||
import { forwardHaptic } from "../data/haptics";
|
||||
import { DEFAULT_PANEL } from "../data/panel";
|
||||
@ -49,6 +50,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
entities: null as any,
|
||||
devices: null as any,
|
||||
areas: null as any,
|
||||
labels: null as any,
|
||||
config: null as any,
|
||||
themes: null as any,
|
||||
selectedTheme: null,
|
||||
@ -229,6 +231,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
name: entity.en,
|
||||
hidden: entity.hb,
|
||||
display_precision: entity.dp,
|
||||
labels: entity.lb,
|
||||
};
|
||||
}
|
||||
this._updateHass({ entities });
|
||||
@ -247,6 +250,13 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
|
||||
}
|
||||
this._updateHass({ areas });
|
||||
});
|
||||
subscribeLabelRegistry(conn, (labelReg) => {
|
||||
const labels: HomeAssistant["labels"] = {};
|
||||
for (const label of labelReg) {
|
||||
labels[label.label_id] = label;
|
||||
}
|
||||
this._updateHass({ labels });
|
||||
});
|
||||
subscribeConfig(conn, (config) => {
|
||||
if (this.hass?.config?.time_zone !== config.time_zone) {
|
||||
import("../resources/intl-polyfill").then(() => {
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
configContext,
|
||||
devicesContext,
|
||||
entitiesContext,
|
||||
labelsContext,
|
||||
localeContext,
|
||||
localizeContext,
|
||||
panelsContext,
|
||||
@ -42,6 +43,10 @@ export const contextMixin = <T extends Constructor<HassBaseEl>>(
|
||||
context: areasContext,
|
||||
initialValue: this.hass ? this.hass.areas : this._pendingHass.areas,
|
||||
}),
|
||||
labels: new ContextProvider(this, {
|
||||
context: labelsContext,
|
||||
initialValue: this.hass ? this.hass.labels : this._pendingHass.labels,
|
||||
}),
|
||||
localize: new ContextProvider(this, {
|
||||
context: localizeContext,
|
||||
initialValue: this.hass
|
||||
|
@ -12,6 +12,7 @@ import { LocalizeFunc } from "./common/translations/localize";
|
||||
import { AreaRegistryEntry } from "./data/area_registry";
|
||||
import { DeviceRegistryEntry } from "./data/device_registry";
|
||||
import { EntityRegistryDisplayEntry } from "./data/entity_registry";
|
||||
import { LabelRegistryEntry } from "./data/label_registry";
|
||||
import { CoreFrontendUserData } from "./data/frontend";
|
||||
import { FrontendLocaleData, getHassTranslations } from "./data/translation";
|
||||
import { Themes } from "./data/ws-themes";
|
||||
@ -208,6 +209,7 @@ export interface HomeAssistant {
|
||||
entities: { [id: string]: EntityRegistryDisplayEntry };
|
||||
devices: { [id: string]: DeviceRegistryEntry };
|
||||
areas: { [id: string]: AreaRegistryEntry };
|
||||
labels: { [id: string]: LabelRegistryEntry };
|
||||
services: HassServices;
|
||||
config: HassConfig;
|
||||
themes: Themes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user