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