forked from DigiLive/mushroom-strategy
Optimize types
The type definitions and interfaces of Home Assistant and Mushroom where outdated. Also, the type definitions and interfaces of the strategy could use some refinement.
This commit is contained in:
1
dist/mushroom-strategy.js
vendored
1
dist/mushroom-strategy.js
vendored
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mushroom-strategy",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@@ -14,7 +14,7 @@
|
||||
"devDependencies": {
|
||||
"home-assistant-js-websocket": "^9",
|
||||
"superstruct": "^1",
|
||||
"ts-loader": "^9",
|
||||
"ts-loader": "^9.5.0",
|
||||
"ts-node": "^10",
|
||||
"typescript": "^5",
|
||||
"version-bump-prompt": "^6",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mushroom-strategy",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"description": "Automatically create a dashboard using Mushroom cards",
|
||||
"keywords": [
|
||||
"strategy",
|
||||
|
@@ -8,6 +8,14 @@ import {generic} from "./types/strategy/generic";
|
||||
import setupCustomLocalize from "./localize";
|
||||
import {applyEntityCategoryFilters} from "./utillties/filters";
|
||||
import StrategyArea = generic.StrategyArea;
|
||||
import ViewConfig = generic.StrategyViewConfig;
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
import supportedViews = generic.SupportedViews;
|
||||
import isSortable = generic.isSortable;
|
||||
import AllDomainsConfig = generic.AllDomainsConfig;
|
||||
import SingleDomainConfig = generic.SingleDomainConfig;
|
||||
import isSupportedView = generic.isSupportedView;
|
||||
import isSupportedDomain = generic.isSupportedDomain;
|
||||
|
||||
/**
|
||||
* Helper Class
|
||||
@@ -40,7 +48,7 @@ class Helper {
|
||||
static #areas: StrategyArea[] = [];
|
||||
|
||||
/**
|
||||
* An array of state entities from Home Assistant's Hass object.
|
||||
* An array of state entities from Home Assistant's Hass-object.
|
||||
*
|
||||
* @type {HassEntities}
|
||||
* @private
|
||||
@@ -137,11 +145,11 @@ class Helper {
|
||||
/**
|
||||
* Initialize this module.
|
||||
*
|
||||
* @param {generic.DashBoardInfo} info Strategy information object.
|
||||
* @param {generic.DashboardInfo} info Strategy information object.
|
||||
* @returns {Promise<void>}
|
||||
* @static
|
||||
*/
|
||||
static async initialize(info: generic.DashBoardInfo): Promise<void> {
|
||||
static async initialize(info: generic.DashboardInfo): Promise<void> {
|
||||
// Initialize properties.
|
||||
this.customLocalize = setupCustomLocalize(info.hass);
|
||||
|
||||
@@ -191,16 +199,27 @@ class Helper {
|
||||
// Sort custom and default views of the strategy options by order first and then by title.
|
||||
this.#strategyOptions.views = Object.fromEntries(
|
||||
Object.entries(this.#strategyOptions.views).sort(([, a], [, b]) => {
|
||||
return (a.order ?? Infinity) - (b.order ?? Infinity) || (a.title ?? "undefined").localeCompare(b.title ?? "undefined");
|
||||
const viewA = a as ViewConfig;
|
||||
const viewB = b as ViewConfig;
|
||||
|
||||
return (viewA.order ?? Infinity) - (viewB.order ?? Infinity)
|
||||
|| (viewA.title ?? "undefined").localeCompare(viewB.title ?? "undefined");
|
||||
}),
|
||||
);
|
||||
) as Record<supportedViews, ViewConfig>;
|
||||
|
||||
// Sort custom and default domains of the strategy options by order first and then by title.
|
||||
this.#strategyOptions.domains = Object.fromEntries(
|
||||
Object.entries(this.#strategyOptions.domains).sort(([, a], [, b]) => {
|
||||
return (a.order ?? Infinity) - (b.order ?? Infinity) || (a.title ?? "undefined").localeCompare(b.title ?? "undefined");
|
||||
if (isSortable(a) && isSortable(b)) {
|
||||
const orderA = ('order' in a) ? a.order ?? Infinity : Infinity;
|
||||
const orderB = ('order' in b) ? b.order ?? Infinity : Infinity;
|
||||
|
||||
return orderA - orderB || (a.title ?? "undefined").localeCompare(b.title ?? "undefined");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}),
|
||||
);
|
||||
) as { [K in SupportedDomains]: K extends "_" ? AllDomainsConfig : SingleDomainConfig; };
|
||||
|
||||
this.#initialized = true;
|
||||
}
|
||||
@@ -228,7 +247,8 @@ class Helper {
|
||||
* @return {string} The template string.
|
||||
* @static
|
||||
*/
|
||||
static getCountTemplate(domain: string, operator: string, value: string): string {
|
||||
static getCountTemplate(domain: SupportedDomains, operator: string, value: string): string {
|
||||
// noinspection JSMismatchedCollectionQueryUpdate
|
||||
/**
|
||||
* Array of entity state-entries, filtered by domain.
|
||||
*
|
||||
@@ -390,27 +410,31 @@ class Helper {
|
||||
/**
|
||||
* Get the ids of the views which aren't set to hidden in the strategy options.
|
||||
*
|
||||
* @return {string[]} An array of view ids.
|
||||
* @return {SupportedViews[]} An array of view ids.
|
||||
*/
|
||||
static getExposedViewIds(): string[] {
|
||||
static getExposedViewIds(): supportedViews[] {
|
||||
if (!this.isInitialized()) {
|
||||
console.warn("Helper class should be initialized before calling this method!");
|
||||
}
|
||||
|
||||
return this.#getObjectKeysByPropertyValue(this.#strategyOptions.views, "hidden", false);
|
||||
const ids = this.#getObjectKeysByPropertyValue(this.#strategyOptions.views, "hidden", false);
|
||||
|
||||
return ids.filter(isSupportedView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ids of the domain ids which aren't set to hidden in the strategy options.
|
||||
*
|
||||
* @return {string[]} An array of domain ids.
|
||||
* @return {SupportedDomains[]} An array of domain ids.
|
||||
*/
|
||||
static getExposedDomainIds(): string[] {
|
||||
static getExposedDomainIds(): SupportedDomains[] {
|
||||
if (!this.isInitialized()) {
|
||||
console.warn("Helper class should be initialized before calling this method!");
|
||||
}
|
||||
|
||||
return this.#getObjectKeysByPropertyValue(this.#strategyOptions.domains, "hidden", false);
|
||||
const ids = this.#getObjectKeysByPropertyValue(this.#strategyOptions.domains, "hidden", false);
|
||||
|
||||
return ids.filter(isSupportedDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {AbstractCard} from "./AbstractCard";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {EntityRegistryEntry} from "../types/homeassistant/data/entity_registry";
|
||||
import {PictureEntityCardConfig} from "../types/homeassistant/panels/lovelave/cards/types";
|
||||
import {PictureEntityCardConfig} from "../types/homeassistant/panels/lovelace/cards/types";
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {StackCardConfig} from "../types/homeassistant/lovelace/cards/types";
|
||||
import {LovelaceCardConfig} from "../types/homeassistant/data/lovelace";
|
||||
import {HassServiceTarget} from "home-assistant-js-websocket";
|
||||
import {StackCardConfig} from "../types/homeassistant/panels/lovelace/cards/types";
|
||||
|
||||
/**
|
||||
* Controller Card class.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {AbstractCard} from "./AbstractCard";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {AreaRegistryEntry} from "../types/homeassistant/data/area_registry";
|
||||
import {AreaCardConfig} from "../types/homeassistant/lovelace/cards/types";
|
||||
import {AreaCardConfig} from "../types/homeassistant/panels/lovelace/cards/types";
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
|
@@ -8,27 +8,72 @@ export const getConfigurationDefaults = (localize: Function): StrategyDefaults =
|
||||
return {
|
||||
areas: {
|
||||
undisclosed: {
|
||||
aliases: [],
|
||||
area_id: "undisclosed",
|
||||
created_at: 0,
|
||||
floor_id: null,
|
||||
name: "Undisclosed",
|
||||
picture: null,
|
||||
hidden: false,
|
||||
humidity_entity_id: null,
|
||||
icon: "mdi:floor-plan",
|
||||
labels: [],
|
||||
aliases: [],
|
||||
hidden: false,
|
||||
modified_at: 0,
|
||||
name: "Undisclosed",
|
||||
picture: null,
|
||||
temperature_entity_id: null,
|
||||
}
|
||||
},
|
||||
card_options: {},
|
||||
chips: {},
|
||||
debug: false,
|
||||
domains: {
|
||||
_: {
|
||||
hide_config_entities: true,
|
||||
hide_diagnostic_entities: true,
|
||||
},
|
||||
binary_sensor: {
|
||||
title: `${localize("sensor.binary")} ` + localize("sensor.sensors"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
camera: {
|
||||
title: localize("camera.cameras"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
climate: {
|
||||
title: localize("climate.climates"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
cover: {
|
||||
title: localize("cover.covers"),
|
||||
showControls: true,
|
||||
iconOn: "mdi:arrow-up",
|
||||
iconOff: "mdi:arrow-down",
|
||||
onService: "cover.open_cover",
|
||||
offService: "cover.close_cover",
|
||||
hidden: false,
|
||||
},
|
||||
default: {
|
||||
title: localize("generic.miscellaneous"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
fan: {
|
||||
title: localize("fan.fans"),
|
||||
showControls: true,
|
||||
iconOn: "mdi:fan",
|
||||
iconOff: "mdi:fan-off",
|
||||
onService: "fan.turn_on",
|
||||
offService: "fan.turn_off",
|
||||
hidden: false,
|
||||
},
|
||||
|
||||
input_select: {
|
||||
title: localize("input_select.input_selects"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
light: {
|
||||
title: localize("light.lights"),
|
||||
showControls: true,
|
||||
@@ -38,28 +83,35 @@ export const getConfigurationDefaults = (localize: Function): StrategyDefaults =
|
||||
offService: "light.turn_off",
|
||||
hidden: false,
|
||||
},
|
||||
lock: {
|
||||
title: localize("lock.locks"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
media_player: {
|
||||
title: localize("media_player.media_players"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
number: {
|
||||
title: localize("generic.numbers"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
scene: {
|
||||
title: localize("scene.scenes"),
|
||||
showControls: false,
|
||||
onService: "scene.turn_on",
|
||||
hidden: false,
|
||||
},
|
||||
fan: {
|
||||
title: localize("fan.fans"),
|
||||
showControls: true,
|
||||
iconOn: "mdi:fan",
|
||||
iconOff: "mdi:fan-off",
|
||||
onService: "fan.turn_on",
|
||||
offService: "fan.turn_off",
|
||||
select: {
|
||||
title: localize("select.selects"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
cover: {
|
||||
title: localize("cover.covers"),
|
||||
showControls: true,
|
||||
iconOn: "mdi:arrow-up",
|
||||
iconOff: "mdi:arrow-down",
|
||||
onService: "cover.open_cover",
|
||||
offService: "cover.close_cover",
|
||||
sensor: {
|
||||
title: localize("sensor.sensors"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
switch: {
|
||||
@@ -71,61 +123,34 @@ export const getConfigurationDefaults = (localize: Function): StrategyDefaults =
|
||||
offService: "switch.turn_off",
|
||||
hidden: false,
|
||||
},
|
||||
camera: {
|
||||
title: localize("camera.cameras"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
lock: {
|
||||
title: localize("lock.locks"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
climate: {
|
||||
title: localize("climate.climates"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
media_player: {
|
||||
title: localize("media_player.media_players"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
sensor: {
|
||||
title: localize("sensor.sensors"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
binary_sensor: {
|
||||
title: `${localize("sensor.binary")} ` + localize("sensor.sensors"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
number: {
|
||||
title: localize("generic.numbers"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
vacuum: {
|
||||
title: localize("vacuum.vacuums"),
|
||||
showControls: true,
|
||||
hidden: false,
|
||||
},
|
||||
select: {
|
||||
title: localize("select.selects"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
input_select: {
|
||||
title: localize("input_select.input_selects"),
|
||||
showControls: false,
|
||||
hidden: false,
|
||||
},
|
||||
},
|
||||
extra_cards: [],
|
||||
extra_views: [],
|
||||
home_view: {
|
||||
hidden: [],
|
||||
},
|
||||
views: {
|
||||
camera: {
|
||||
order: 7,
|
||||
hidden: false,
|
||||
},
|
||||
climate: {
|
||||
order: 6,
|
||||
hidden: false,
|
||||
},
|
||||
cover: {
|
||||
order: 4,
|
||||
hidden: false,
|
||||
},
|
||||
fan: {
|
||||
order: 3,
|
||||
hidden: false,
|
||||
},
|
||||
home: {
|
||||
order: 1,
|
||||
hidden: false,
|
||||
@@ -134,34 +159,19 @@ export const getConfigurationDefaults = (localize: Function): StrategyDefaults =
|
||||
order: 2,
|
||||
hidden: false,
|
||||
},
|
||||
fan: {
|
||||
order: 3,
|
||||
hidden: false,
|
||||
},
|
||||
cover: {
|
||||
order: 4,
|
||||
scene: {
|
||||
order: 9,
|
||||
hidden: false,
|
||||
},
|
||||
switch: {
|
||||
order: 5,
|
||||
hidden: false,
|
||||
},
|
||||
climate: {
|
||||
order: 6,
|
||||
hidden: false,
|
||||
},
|
||||
camera: {
|
||||
order: 7,
|
||||
hidden: false,
|
||||
},
|
||||
vacuum: {
|
||||
order: 8,
|
||||
hidden: false,
|
||||
},
|
||||
scene: {
|
||||
order: 9,
|
||||
hidden: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
quick_access_cards: []
|
||||
};
|
||||
};
|
||||
|
@@ -1,13 +1,18 @@
|
||||
import {Helper} from "./Helper";
|
||||
import {SensorCard} from "./cards/SensorCard";
|
||||
import {ControllerCard} from "./cards/ControllerCard";
|
||||
import {generic} from "./types/strategy/generic";
|
||||
import {LovelaceCardConfig, LovelaceConfig, LovelaceViewConfig} from "./types/homeassistant/data/lovelace";
|
||||
import {StackCardConfig} from "./types/homeassistant/lovelace/cards/types";
|
||||
import {EntityCardConfig} from "./types/lovelace-mushroom/cards/entity-card-config";
|
||||
import {HassServiceTarget} from "home-assistant-js-websocket";
|
||||
import {applyEntityCategoryFilters} from "./utillties/filters";
|
||||
import {LovelaceConfig} from "./types/homeassistant/data/lovelace/config/types";
|
||||
import {LovelaceViewConfig, LovelaceViewRawConfig} from "./types/homeassistant/data/lovelace/config/view";
|
||||
import {LovelaceCardConfig} from "./types/homeassistant/data/lovelace";
|
||||
import {StackCardConfig} from "./types/homeassistant/panels/lovelace/cards/types";
|
||||
import {generic} from "./types/strategy/generic";
|
||||
import {views} from "./types/strategy/views";
|
||||
import ViewConfig = views.ViewConfig;
|
||||
import StrategyArea = generic.StrategyArea;
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
/**
|
||||
* Mushroom Dashboard Strategy.<br>
|
||||
@@ -28,14 +33,14 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
*
|
||||
* Called when opening a dashboard.
|
||||
*
|
||||
* @param {generic.DashBoardInfo} info Dashboard strategy information object.
|
||||
* @param {generic.DashboardInfo} info Dashboard strategy information object.
|
||||
* @return {Promise<LovelaceConfig>}
|
||||
*/
|
||||
static async generateDashboard(info: generic.DashBoardInfo): Promise<LovelaceConfig> {
|
||||
static async generateDashboard(info: generic.DashboardInfo): Promise<LovelaceConfig> {
|
||||
await Helper.initialize(info);
|
||||
|
||||
// Create views.
|
||||
const views: LovelaceViewConfig[] = info.config?.views ?? [];
|
||||
const views: LovelaceViewRawConfig[] = [];
|
||||
|
||||
let viewModule;
|
||||
|
||||
@@ -44,7 +49,7 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
try {
|
||||
const viewType = Helper.sanitizeClassName(viewId + "View");
|
||||
viewModule = await import(`./views/${viewType}`);
|
||||
const view: LovelaceViewConfig = await new viewModule[viewType](Helper.strategyOptions.views[viewId]).getView();
|
||||
const view: ViewConfig = await new viewModule[viewType](Helper.strategyOptions.views[viewId]).getView();
|
||||
|
||||
if (view.cards?.length) {
|
||||
views.push(view);
|
||||
@@ -216,7 +221,7 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
// Create cards for any other domain.
|
||||
// Collect entities of the current area and unexposed domains.
|
||||
let miscellaneousEntities = Helper.getDeviceEntities(area).filter(
|
||||
entity => !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0])
|
||||
entity => !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0] as SupportedDomains)
|
||||
);
|
||||
|
||||
// Exclude hidden Config and Diagnostic entities.
|
||||
@@ -234,7 +239,6 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
|
||||
for (const entity of miscellaneousEntities) {
|
||||
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id];
|
||||
let deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id ?? "null"];
|
||||
|
||||
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
|
||||
}
|
||||
@@ -261,7 +265,7 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
|
||||
customElements.define("ll-strategy-mushroom-strategy", MushroomStrategy);
|
||||
|
||||
const version = "v2.2.0";
|
||||
const version = "v2.2.1";
|
||||
console.info(
|
||||
"%c Mushroom Strategy %c ".concat(version, " "),
|
||||
"color: white; background: coral; font-weight: 700;", "color: coral; background: white; font-weight: 700;"
|
||||
|
49
src/types/homeassistant/common/translations/localize.ts
Normal file
49
src/types/homeassistant/common/translations/localize.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import type {TranslationDict} from "../../types";
|
||||
|
||||
// Exclude some patterns from key type checking for now
|
||||
// These are intended to be removed as errors are fixed
|
||||
// Fixing component category will require tighter definition of types from backend and/or web socket
|
||||
export type LocalizeKeys =
|
||||
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
||||
| `panel.${string}`
|
||||
| `ui.card.alarm_control_panel.${string}`
|
||||
| `ui.card.weather.attributes.${string}`
|
||||
| `ui.card.weather.cardinal_direction.${string}`
|
||||
| `ui.card.lawn_mower.actions.${string}`
|
||||
| `ui.components.calendar.event.rrule.${string}`
|
||||
| `ui.components.selectors.file.${string}`
|
||||
| `ui.components.logbook.messages.detected_device_classes.${string}`
|
||||
| `ui.components.logbook.messages.cleared_device_classes.${string}`
|
||||
| `ui.dialogs.entity_registry.editor.${string}`
|
||||
| `ui.dialogs.more_info_control.lawn_mower.${string}`
|
||||
| `ui.dialogs.more_info_control.vacuum.${string}`
|
||||
| `ui.dialogs.quick-bar.commands.${string}`
|
||||
| `ui.dialogs.unhealthy.reason.${string}`
|
||||
| `ui.dialogs.unsupported.reason.${string}`
|
||||
| `ui.panel.config.${string}.${"caption" | "description"}`
|
||||
| `ui.panel.config.dashboard.${string}`
|
||||
| `ui.panel.config.zha.${string}`
|
||||
| `ui.panel.config.zwave_js.${string}`
|
||||
| `ui.panel.lovelace.card.${string}`
|
||||
| `ui.panel.lovelace.editor.${string}`
|
||||
| `ui.panel.page-authorize.form.${string}`
|
||||
| `component.${string}`;
|
||||
|
||||
// Tweaked from https://www.raygesualdo.com/posts/flattening-object-keys-with-typescript-types
|
||||
export type FlattenObjectKeys<
|
||||
T extends Record<string, any>,
|
||||
Key extends keyof T = keyof T,
|
||||
> = Key extends string
|
||||
? T[Key] extends Record<string, unknown>
|
||||
? `${Key}.${FlattenObjectKeys<T[Key]>}`
|
||||
: `${Key}`
|
||||
: never;
|
||||
|
||||
// Later, don't return string when HTML is passed, and don't allow undefined
|
||||
export type LocalizeFunc<Keys extends string = LocalizeKeys> = (
|
||||
key: Keys,
|
||||
values?: Record<
|
||||
string,
|
||||
string | number | {_$litType$: 1, strings: TemplateStringsArray, values: Array<unknown>} | null | undefined
|
||||
>
|
||||
) => string;
|
@@ -1,20 +1,26 @@
|
||||
import {RegistryEntry} from "./registry";
|
||||
|
||||
/**
|
||||
* Area Entity.
|
||||
* Entry in the Area Registry.
|
||||
*
|
||||
* @property {string[]} aliases Array of aliases of the area.
|
||||
* @property {string} area_id The id of the area.
|
||||
* @property {string|null} floor_id The id of the area's floor.
|
||||
* @property {string} name Name of the area.
|
||||
* @property {string|null} picture URL to a picture that should be used instead of showing the domain icon.
|
||||
* @property {string|null} humidity_entity_id The id of the area's humidity sensor.
|
||||
* @property {string|null} icon Icon to show.
|
||||
* @property {string[]} labels Labels allow grouping elements irrespective of their physical location or type.
|
||||
* @property {string[]} aliases Array of aliases of the area.
|
||||
* @property {string} name Name of the area.
|
||||
* @property {string|null} picture URL to a picture that should be used instead of showing the domain icon.
|
||||
* @property {string|null} temperature_entity_id The id of the area's temperature sensor.
|
||||
*/
|
||||
export interface AreaRegistryEntry {
|
||||
export interface AreaRegistryEntry extends RegistryEntry {
|
||||
aliases: string[];
|
||||
area_id: string;
|
||||
floor_id: string | null;
|
||||
name: string;
|
||||
picture: string | null;
|
||||
humidity_entity_id: string | null;
|
||||
icon: string | null;
|
||||
labels: string[];
|
||||
aliases: string[];
|
||||
name: string;
|
||||
picture: string | null;
|
||||
temperature_entity_id: string | null;
|
||||
}
|
||||
|
@@ -9,11 +9,3 @@ export const HVAC_MODES = [
|
||||
] as const;
|
||||
|
||||
export type HvacMode = (typeof HVAC_MODES)[number];
|
||||
|
||||
HVAC_MODES.reduce(
|
||||
(order, mode, index) => {
|
||||
order[mode] = index;
|
||||
return order;
|
||||
},
|
||||
{} as Record<HvacMode, number>
|
||||
);
|
||||
|
@@ -2,30 +2,51 @@
|
||||
* Device Entity.
|
||||
*
|
||||
* @property {string} id Unique ID of a device (generated by Home Assistant).
|
||||
* @property {string[]} config_entries
|
||||
* @property {Array} connections
|
||||
* @property {Array} identifiers
|
||||
* @property {string | null} manufacturer
|
||||
* @property {string | null} model
|
||||
* @property {string | null} name
|
||||
* @property {string | null} sw_version
|
||||
* @property {string | null} hw_version
|
||||
* @property {string | null} serial_number
|
||||
* @property {string | null} via_device_id
|
||||
* @property {string[]} config_entries Config entries that are linked to this device.
|
||||
* @property {Record<string, (string | null)[]>} config_entries_subentries
|
||||
* @property {[string, string][]} connections A set of tuples of (connection_type, connection identifier).
|
||||
* Connection types are defined in the device registry module.
|
||||
* Each item in the set uniquely defines a device entry, meaning another
|
||||
* device can't have the same connection.
|
||||
* @property {[string, string][]} identifiers Set of (DOMAIN, identifier) tuples.
|
||||
* Identifiers identify the device in the outside world.
|
||||
* An example is a serial number.
|
||||
* Each item in the set uniquely defines a device entry, meaning another
|
||||
* device can't have the same identifier.
|
||||
* @property {string | null} manufacturer The manufacturer of the device.
|
||||
* @property {string | null} model The model name of the device.
|
||||
* @property {string | null} model_id The model identifier of the device.
|
||||
* @property {string | null} name Name of this device
|
||||
* @property {string[]} labels
|
||||
* @property {string | null} sw_version The firmware version of the device.
|
||||
* @property {string | null} hw_version The hardware version of the device.
|
||||
* @property {string | null} serial_number The serial number of the device.
|
||||
* Unlike a serial number in the identifiers set, this does not need to be
|
||||
* unique.
|
||||
* @property {string | null} via_device_id Identifier of a device that routes messages between this device and Home Assistant.
|
||||
* Examples of such devices are hubs, or parent devices of a sub-device.
|
||||
* This is used to show device topology in Home Assistant.
|
||||
* @property {string} area_id The Area which the device is placed in.
|
||||
* @property {string | null} name_by_user
|
||||
* @property {string[] | null} entry_type
|
||||
* @property {string | null} name_by_user The user configured name of the device.
|
||||
* @property {string[] | null} entry_type The type of entry. Possible values are None and DeviceEntryType enum members
|
||||
* (only service).
|
||||
* @property {string | null} disabled_by Indicates by what this entity is disabled.
|
||||
* @property {string | null} configuration_url
|
||||
* @property {string | null} configuration_url A URL on which the device or service can be configured,
|
||||
* linking to paths inside the Home Assistant UI can be done by using
|
||||
* homeassistant://<path>.
|
||||
* @property {string | null} primary_config_entry
|
||||
*/
|
||||
export interface DeviceRegistryEntry {
|
||||
id: string;
|
||||
config_entries: string[];
|
||||
connections: Array<[string, string]>;
|
||||
identifiers: Array<[string, string]>;
|
||||
config_entries_subentries: Record<string, (string | null)[]>;
|
||||
connections: [string, string][];
|
||||
identifiers: [string, string][];
|
||||
manufacturer: string | null;
|
||||
model: string | null;
|
||||
model_id: string | null;
|
||||
name: string | null;
|
||||
labels: string[];
|
||||
sw_version: string | null;
|
||||
hw_version: string | null;
|
||||
serial_number: string | null;
|
||||
@@ -35,4 +56,5 @@ export interface DeviceRegistryEntry {
|
||||
entry_type: "service" | null;
|
||||
disabled_by: "user" | "integration" | "config_entry" | null;
|
||||
configuration_url: string | null;
|
||||
primary_config_entry: string | null;
|
||||
}
|
||||
|
@@ -5,13 +5,16 @@ type EntityCategory = "config" | "diagnostic";
|
||||
export interface EntityRegistryDisplayEntry {
|
||||
entity_id: string;
|
||||
name?: string;
|
||||
icon?: string;
|
||||
device_id?: string;
|
||||
area_id?: string;
|
||||
labels: string[];
|
||||
hidden?: boolean;
|
||||
entity_category?: EntityCategory;
|
||||
translation_key?: string;
|
||||
platform?: string;
|
||||
display_precision?: number;
|
||||
has_entity_name?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,8 +26,10 @@ export interface EntityRegistryDisplayEntry {
|
||||
* @property {string | null} icon
|
||||
* @property {string | null} platform
|
||||
* @property {string | null} config_entry_id
|
||||
* @property {string | null} config_subentry_id
|
||||
* @property {string | null} device_id The id of the device to which this entity is linked.
|
||||
* @property {string | null} area_id The id of the area to which this entity is linked.
|
||||
* @property {string[]} labels
|
||||
* @property {string | null} disabled_by Indicates by what this entity is disabled.
|
||||
* @property {Object} hidden_by Indicates by what this entity is hidden.
|
||||
* @property {EntityCategory | null} entity_category
|
||||
@@ -33,6 +38,7 @@ export interface EntityRegistryDisplayEntry {
|
||||
* @property {string} unique_id
|
||||
* @property {string} [translation_key]
|
||||
* @property {EntityRegistryOptions | null} options
|
||||
* @property {Record<string, string>} categories
|
||||
*/
|
||||
export interface EntityRegistryEntry {
|
||||
id: string;
|
||||
@@ -41,8 +47,10 @@ export interface EntityRegistryEntry {
|
||||
icon: string | null;
|
||||
platform: string;
|
||||
config_entry_id: string | null;
|
||||
config_subentry_id: string | null;
|
||||
device_id: string | null;
|
||||
area_id: string | null;
|
||||
labels: string[];
|
||||
disabled_by: "user" | "device" | "integration" | "config_entry" | null;
|
||||
hidden_by: Exclude<EntityRegistryEntry["disabled_by"], "config_entry">;
|
||||
entity_category: EntityCategory | null;
|
||||
@@ -51,6 +59,7 @@ export interface EntityRegistryEntry {
|
||||
unique_id: string;
|
||||
translation_key?: string;
|
||||
options: EntityRegistryOptions | null;
|
||||
categories: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface SensorEntityOptions {
|
||||
@@ -71,6 +80,10 @@ export interface LockEntityOptions {
|
||||
default_code?: string | null;
|
||||
}
|
||||
|
||||
export interface AlarmControlPanelEntityOptions {
|
||||
default_code?: string | null;
|
||||
}
|
||||
|
||||
export interface WeatherEntityOptions {
|
||||
precipitation_unit?: string | null;
|
||||
pressure_unit?: string | null;
|
||||
@@ -81,11 +94,13 @@ export interface WeatherEntityOptions {
|
||||
|
||||
export interface SwitchAsXEntityOptions {
|
||||
entity_id: string;
|
||||
invert: boolean;
|
||||
}
|
||||
|
||||
export interface EntityRegistryOptions {
|
||||
number?: NumberEntityOptions;
|
||||
sensor?: SensorEntityOptions;
|
||||
alarm_control_panel?: AlarmControlPanelEntityOptions;
|
||||
lock?: LockEntityOptions;
|
||||
weather?: WeatherEntityOptions;
|
||||
light?: LightEntityOptions;
|
||||
|
9
src/types/homeassistant/data/floor_registry.ts
Normal file
9
src/types/homeassistant/data/floor_registry.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import {RegistryEntry} from "./registry";
|
||||
|
||||
export interface FloorRegistryEntry extends RegistryEntry {
|
||||
floor_id: string;
|
||||
name: string;
|
||||
level: number | null;
|
||||
icon: string | null;
|
||||
aliases: string[];
|
||||
}
|
3
src/types/homeassistant/data/frontend.ts
Normal file
3
src/types/homeassistant/data/frontend.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface CoreFrontendUserData {
|
||||
showAdvanced?: boolean;
|
||||
}
|
@@ -1,54 +1,17 @@
|
||||
import {HassServiceTarget} from "home-assistant-js-websocket";
|
||||
|
||||
export type LovelaceStrategyConfig = {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export interface LovelaceConfig {
|
||||
title?: string;
|
||||
strategy?: LovelaceStrategyConfig;
|
||||
views: LovelaceViewConfig[];
|
||||
background?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* View Config.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/views/
|
||||
*/
|
||||
export interface LovelaceViewConfig {
|
||||
index?: number;
|
||||
title?: string;
|
||||
type?: string;
|
||||
strategy?: LovelaceStrategyConfig;
|
||||
badges?: Array<string | LovelaceBadgeConfig>;
|
||||
cards?: LovelaceCardConfig[];
|
||||
path?: string;
|
||||
icon?: string;
|
||||
theme?: string;
|
||||
panel?: boolean;
|
||||
background?: string;
|
||||
visible?: boolean | ShowViewConfig[];
|
||||
subview?: boolean;
|
||||
back_path?: string;
|
||||
}
|
||||
|
||||
export interface ShowViewConfig {
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceBadgeConfig {
|
||||
type?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
import {LovelaceGridOptions, LovelaceLayoutOptions} from "../panels/lovelace/types";
|
||||
import {Condition} from "../panels/common/validate-condition";
|
||||
|
||||
export interface LovelaceCardConfig {
|
||||
index?: number;
|
||||
view_index?: number;
|
||||
view_layout?: any;
|
||||
/** @deprecated Use `grid_options` instead */
|
||||
layout_options?: LovelaceLayoutOptions;
|
||||
grid_options?: LovelaceGridOptions;
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
visibility?: Condition[];
|
||||
}
|
||||
|
||||
export interface ToggleActionConfig extends BaseActionConfig {
|
||||
|
7
src/types/homeassistant/data/lovelace/config/badge.ts
Normal file
7
src/types/homeassistant/data/lovelace/config/badge.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import {Condition} from "../../../panels/common/validate-condition";
|
||||
|
||||
export interface LovelaceBadgeConfig {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
visibility?: Condition[];
|
||||
}
|
14
src/types/homeassistant/data/lovelace/config/card.ts
Normal file
14
src/types/homeassistant/data/lovelace/config/card.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Condition} from "../../../panels/common/validate-condition";
|
||||
import {LovelaceGridOptions, LovelaceLayoutOptions} from "../../../panels/lovelace/types";
|
||||
|
||||
export interface LovelaceCardConfig {
|
||||
index?: number;
|
||||
view_index?: number;
|
||||
view_layout?: any;
|
||||
/** @deprecated Use `grid_options` instead */
|
||||
layout_options?: LovelaceLayoutOptions;
|
||||
grid_options?: LovelaceGridOptions;
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
visibility?: Condition[];
|
||||
}
|
27
src/types/homeassistant/data/lovelace/config/section.ts
Normal file
27
src/types/homeassistant/data/lovelace/config/section.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {LovelaceStrategyConfig} from "./strategy";
|
||||
import {LovelaceCardConfig} from "../../lovelace";
|
||||
import {Condition} from "../../../panels/common/validate-condition";
|
||||
|
||||
export interface LovelaceBaseSectionConfig {
|
||||
visibility?: Condition[];
|
||||
column_span?: number;
|
||||
row_span?: number;
|
||||
/**
|
||||
* @deprecated Use heading card instead.
|
||||
*/
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceSectionConfig extends LovelaceBaseSectionConfig {
|
||||
type?: string;
|
||||
cards?: LovelaceCardConfig[];
|
||||
}
|
||||
|
||||
export interface LovelaceStrategySectionConfig
|
||||
extends LovelaceBaseSectionConfig {
|
||||
strategy: LovelaceStrategyConfig;
|
||||
}
|
||||
|
||||
export type LovelaceSectionRawConfig =
|
||||
| LovelaceSectionConfig
|
||||
| LovelaceStrategySectionConfig;
|
4
src/types/homeassistant/data/lovelace/config/strategy.ts
Normal file
4
src/types/homeassistant/data/lovelace/config/strategy.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface LovelaceStrategyConfig {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
}
|
10
src/types/homeassistant/data/lovelace/config/types.ts
Normal file
10
src/types/homeassistant/data/lovelace/config/types.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import {LovelaceViewRawConfig} from "./view";
|
||||
|
||||
export interface LovelaceDashboardBaseConfig {}
|
||||
|
||||
export interface LovelaceConfig extends LovelaceDashboardBaseConfig {
|
||||
background?: string;
|
||||
views: LovelaceViewRawConfig[];
|
||||
}
|
||||
|
||||
|
74
src/types/homeassistant/data/lovelace/config/view.ts
Normal file
74
src/types/homeassistant/data/lovelace/config/view.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import {LovelaceStrategyConfig} from "./strategy";
|
||||
import {LovelaceSectionRawConfig} from "./section";
|
||||
import {LovelaceCardConfig} from "./card";
|
||||
import {LovelaceBadgeConfig} from "./badge";
|
||||
|
||||
export interface ShowViewConfig {
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface LovelaceViewBackgroundConfig {
|
||||
image?: string;
|
||||
opacity?: number;
|
||||
size?: "auto" | "cover" | "contain";
|
||||
alignment?:
|
||||
| "top left"
|
||||
| "top center"
|
||||
| "top right"
|
||||
| "center left"
|
||||
| "center"
|
||||
| "center right"
|
||||
| "bottom left"
|
||||
| "bottom center"
|
||||
| "bottom right";
|
||||
repeat?: "repeat" | "no-repeat";
|
||||
attachment?: "scroll" | "fixed";
|
||||
}
|
||||
|
||||
export interface LovelaceViewHeaderConfig {
|
||||
card?: LovelaceCardConfig;
|
||||
layout?: "start" | "center" | "responsive";
|
||||
badges_position?: "bottom" | "top";
|
||||
}
|
||||
|
||||
export interface LovelaceBaseViewConfig {
|
||||
index?: number;
|
||||
title?: string;
|
||||
path?: string;
|
||||
icon?: string;
|
||||
theme?: string;
|
||||
panel?: boolean;
|
||||
background?: string | LovelaceViewBackgroundConfig;
|
||||
visible?: boolean | ShowViewConfig[];
|
||||
subview?: boolean;
|
||||
back_path?: string;
|
||||
// Only used for section view, it should move to a section view config type when the views will have a dedicated editor.
|
||||
max_columns?: number;
|
||||
dense_section_placement?: boolean;
|
||||
top_margin?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* View Config.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/views/
|
||||
*/
|
||||
export interface LovelaceViewConfig extends LovelaceBaseViewConfig {
|
||||
type?: string;
|
||||
badges?: (string | Partial<LovelaceBadgeConfig>)[]; // Badge can be just an entity_id or without type
|
||||
cards?: LovelaceCardConfig[];
|
||||
sections?: LovelaceSectionRawConfig[];
|
||||
header?: LovelaceViewHeaderConfig;
|
||||
}
|
||||
|
||||
export interface LovelaceStrategyViewConfig extends LovelaceBaseViewConfig {
|
||||
strategy: LovelaceStrategyConfig;
|
||||
}
|
||||
|
||||
export interface LovelaceStrategyViewConfig extends LovelaceBaseViewConfig {
|
||||
strategy: LovelaceStrategyConfig;
|
||||
}
|
||||
|
||||
export type LovelaceViewRawConfig =
|
||||
| LovelaceViewConfig
|
||||
| LovelaceStrategyViewConfig;
|
4
src/types/homeassistant/data/registry.ts
Normal file
4
src/types/homeassistant/data/registry.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface RegistryEntry {
|
||||
created_at: number;
|
||||
modified_at: number;
|
||||
}
|
87
src/types/homeassistant/data/translations.ts
Normal file
87
src/types/homeassistant/data/translations.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
|
||||
import {HomeAssistant} from "../types";
|
||||
|
||||
export enum NumberFormat {
|
||||
language = "language",
|
||||
system = "system",
|
||||
comma_decimal = "comma_decimal",
|
||||
decimal_comma = "decimal_comma",
|
||||
space_comma = "space_comma",
|
||||
none = "none",
|
||||
}
|
||||
|
||||
export enum TimeFormat {
|
||||
language = "language",
|
||||
system = "system",
|
||||
am_pm = "12",
|
||||
twenty_four = "24",
|
||||
}
|
||||
|
||||
export enum TimeZone {
|
||||
local = "local",
|
||||
server = "server",
|
||||
}
|
||||
|
||||
export enum DateFormat {
|
||||
language = "language",
|
||||
system = "system",
|
||||
DMY = "DMY",
|
||||
MDY = "MDY",
|
||||
YMD = "YMD",
|
||||
}
|
||||
|
||||
export enum FirstWeekday {
|
||||
language = "language",
|
||||
monday = "monday",
|
||||
tuesday = "tuesday",
|
||||
wednesday = "wednesday",
|
||||
thursday = "thursday",
|
||||
friday = "friday",
|
||||
saturday = "saturday",
|
||||
sunday = "sunday",
|
||||
}
|
||||
|
||||
export interface FrontendLocaleData {
|
||||
language: string;
|
||||
number_format: NumberFormat;
|
||||
time_format: TimeFormat;
|
||||
date_format: DateFormat;
|
||||
first_weekday: FirstWeekday;
|
||||
time_zone: TimeZone;
|
||||
}
|
||||
|
||||
export type TranslationCategory =
|
||||
| "title"
|
||||
| "state"
|
||||
| "entity"
|
||||
| "entity_component"
|
||||
| "exceptions"
|
||||
| "config"
|
||||
| "config_subentries"
|
||||
| "config_panel"
|
||||
| "options"
|
||||
| "device_automation"
|
||||
| "mfa_setup"
|
||||
| "system_health"
|
||||
| "application_credentials"
|
||||
| "issues"
|
||||
| "selector"
|
||||
| "services";
|
||||
|
||||
export const getHassTranslations = async (
|
||||
hass: HomeAssistant,
|
||||
language: string,
|
||||
category: TranslationCategory,
|
||||
integration?: string | string[],
|
||||
config_flow?: boolean
|
||||
): Promise<Record<string, unknown>> => {
|
||||
const result = await hass.callWS<{ resources: Record<string, unknown> }>({
|
||||
type: "frontend/get_translations",
|
||||
language,
|
||||
category,
|
||||
integration,
|
||||
config_flow,
|
||||
});
|
||||
return result.resources;
|
||||
};
|
26
src/types/homeassistant/data/ws-themes.ts
Normal file
26
src/types/homeassistant/data/ws-themes.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export interface ThemeVars {
|
||||
// Incomplete
|
||||
"primary-color": string;
|
||||
"text-primary-color": string;
|
||||
"accent-color": string;
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
export type Theme = ThemeVars & {
|
||||
modes?: {
|
||||
light?: ThemeVars;
|
||||
dark?: ThemeVars;
|
||||
};
|
||||
};
|
||||
|
||||
export interface Themes {
|
||||
default_theme: string;
|
||||
default_dark_theme: string | null;
|
||||
themes: Record<string, Theme>;
|
||||
// Currently effective dark mode. Will never be undefined. If user selected "auto"
|
||||
// in theme picker, this property will still contain either true or false based on
|
||||
// what has been determined via system preferences and support for the selected theme.
|
||||
darkMode: boolean;
|
||||
// Currently globally active theme name
|
||||
theme: string;
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
import {LovelaceCardConfig} from "../../data/lovelace";
|
||||
|
||||
/**
|
||||
* Home Assistant Stack Card Config.
|
||||
*
|
||||
* @property {string} type The stack type.
|
||||
* @property {Object[]} cards The content of the stack.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/horizontal-stack/
|
||||
* @see https://www.home-assistant.io/dashboards/vertical-stack/
|
||||
*/
|
||||
export interface StackCardConfig extends LovelaceCardConfig {
|
||||
cards: LovelaceCardConfig[];
|
||||
title?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Home Assistant Area Card Config.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/area/
|
||||
*/
|
||||
export interface AreaCardConfig extends LovelaceCardConfig {
|
||||
area: string;
|
||||
navigation_path?: string;
|
||||
show_camera?: boolean;
|
||||
}
|
45
src/types/homeassistant/panels/common/validate-condition.ts
Normal file
45
src/types/homeassistant/panels/common/validate-condition.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export type Condition =
|
||||
| NumericStateCondition
|
||||
| StateCondition
|
||||
| ScreenCondition
|
||||
| UserCondition
|
||||
| OrCondition
|
||||
| AndCondition;
|
||||
|
||||
interface BaseCondition {
|
||||
condition: string;
|
||||
}
|
||||
|
||||
export interface NumericStateCondition extends BaseCondition {
|
||||
condition: "numeric_state";
|
||||
entity?: string;
|
||||
below?: string | number;
|
||||
above?: string | number;
|
||||
}
|
||||
|
||||
export interface StateCondition extends BaseCondition {
|
||||
condition: "state";
|
||||
entity?: string;
|
||||
state?: string | string[];
|
||||
state_not?: string | string[];
|
||||
}
|
||||
|
||||
export interface ScreenCondition extends BaseCondition {
|
||||
condition: "screen";
|
||||
media_query?: string;
|
||||
}
|
||||
|
||||
export interface UserCondition extends BaseCondition {
|
||||
condition: "user";
|
||||
users?: string[];
|
||||
}
|
||||
|
||||
export interface OrCondition extends BaseCondition {
|
||||
condition: "or";
|
||||
conditions?: Condition[];
|
||||
}
|
||||
|
||||
export interface AndCondition extends BaseCondition {
|
||||
condition: "and";
|
||||
conditions?: Condition[];
|
||||
}
|
@@ -1,12 +1,26 @@
|
||||
import {ActionConfig, LovelaceCardConfig} from "../../../data/lovelace";
|
||||
|
||||
/**
|
||||
* Home Assistant Area Card Config.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/area/
|
||||
*/
|
||||
export interface AreaCardConfig extends LovelaceCardConfig {
|
||||
area: string;
|
||||
navigation_path?: string;
|
||||
show_camera?: boolean;
|
||||
camera_view?: "live" | "auto";
|
||||
aspect_ratio?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Home Assistant Picture Entity Config.
|
||||
*
|
||||
* @property {string} entity An entity_id used for the picture.
|
||||
* @property {string} [name] Overwrite entity name.
|
||||
* @property {string} [image] URL of an image.
|
||||
* @property {string} [camera_image] Camera entity_id to use. (not required if entity is already a camera-entity).
|
||||
* @property {string} [camera_image] Camera entity_id to use.
|
||||
* (not required if the entity is already a camera-entity).
|
||||
* @property {string} [camera_view=auto] “live” will show the live view if stream is enabled.
|
||||
* @property {Record<string, unknown>} [state_image] Map entity states to images (state: image URL).
|
||||
* @property {string[]} [state_filter] State-based CSS filters.
|
||||
@@ -39,3 +53,17 @@ export interface PictureEntityCardConfig extends LovelaceCardConfig {
|
||||
show_state?: boolean;
|
||||
theme?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Home Assistant Stack Card Config.
|
||||
*
|
||||
* @property {string} type The stack type.
|
||||
* @property {Object[]} cards The content of the stack.
|
||||
*
|
||||
* @see https://www.home-assistant.io/dashboards/horizontal-stack/
|
||||
* @see https://www.home-assistant.io/dashboards/vertical-stack/
|
||||
*/
|
||||
export interface StackCardConfig extends LovelaceCardConfig {
|
||||
cards: LovelaceCardConfig[];
|
||||
title?: string;
|
||||
}
|
17
src/types/homeassistant/panels/lovelace/types.ts
Normal file
17
src/types/homeassistant/panels/lovelace/types.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export interface LovelaceLayoutOptions {
|
||||
grid_columns?: number | "full";
|
||||
grid_rows?: number | "auto";
|
||||
grid_max_columns?: number;
|
||||
grid_min_columns?: number;
|
||||
grid_min_rows?: number;
|
||||
grid_max_rows?: number;
|
||||
}
|
||||
|
||||
export interface LovelaceGridOptions {
|
||||
columns?: number | "full";
|
||||
rows?: number | "auto";
|
||||
max_columns?: number;
|
||||
min_columns?: number;
|
||||
min_rows?: number;
|
||||
max_rows?: number;
|
||||
}
|
@@ -1,7 +1,21 @@
|
||||
import {Auth, Connection, HassConfig, HassEntities, HassServices, MessageBase,} from "home-assistant-js-websocket";
|
||||
import {
|
||||
Auth,
|
||||
Connection,
|
||||
HassConfig,
|
||||
HassEntities,
|
||||
HassEntity,
|
||||
HassServices,
|
||||
HassServiceTarget,
|
||||
MessageBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import {AreaRegistryEntry} from "./data/area_registry";
|
||||
import {DeviceRegistryEntry} from "./data/device_registry";
|
||||
import {EntityRegistryDisplayEntry} from "./data/entity_registry";
|
||||
import {FloorRegistryEntry} from "./data/floor_registry";
|
||||
import {Themes} from "./data/ws-themes";
|
||||
import {FrontendLocaleData, getHassTranslations} from "./data/translations";
|
||||
import {LocalizeFunc} from "./common/translations/localize";
|
||||
import {CoreFrontendUserData} from "./data/frontend";
|
||||
|
||||
export interface Credential {
|
||||
auth_provider_type: string;
|
||||
@@ -32,10 +46,7 @@ export interface PanelInfo<T = Record<string, any> | null> {
|
||||
config_panel_domain?: string;
|
||||
}
|
||||
|
||||
export interface Panels {
|
||||
[name: string]: PanelInfo;
|
||||
}
|
||||
|
||||
export type Panels = Record<string, PanelInfo>;
|
||||
|
||||
export interface Translation {
|
||||
nativeName: string;
|
||||
@@ -45,27 +56,40 @@ export interface Translation {
|
||||
|
||||
export interface TranslationMetadata {
|
||||
fragments: string[];
|
||||
translations: {
|
||||
[lang: string]: Translation;
|
||||
};
|
||||
translations: Record<string, Translation>;
|
||||
}
|
||||
|
||||
export interface Resources {
|
||||
[language: string]: Record<string, string>;
|
||||
export type TranslationDict = {[key: string]: string};
|
||||
|
||||
export type Resources = Record<string, Record<string, string>>;
|
||||
|
||||
// Currently selected theme and its settings. These are the values stored in local storage.
|
||||
// Note: These values are not meant to be used at runtime to check whether dark mode is active
|
||||
// or which theme name to use, as this interface represents the config data for the theme picker.
|
||||
// The actually active dark mode and theme name can be read from hass.themes.
|
||||
export interface ThemeSettings {
|
||||
theme: string;
|
||||
// Radio box selection for theme picker. Do not use in Lovelace rendering as
|
||||
// it can be undefined == auto.
|
||||
// Property hass.themes.darkMode carries effective current mode.
|
||||
dark?: boolean;
|
||||
primaryColor?: string;
|
||||
accentColor?: string;
|
||||
}
|
||||
|
||||
export interface HomeAssistant {
|
||||
auth: Auth & { external?: any };
|
||||
auth: Auth & { external?: {[key: string]: any;} };
|
||||
connection: Connection;
|
||||
connected: boolean;
|
||||
states: HassEntities;
|
||||
entities: { [id: string]: EntityRegistryDisplayEntry };
|
||||
devices: { [id: string]: DeviceRegistryEntry };
|
||||
areas: { [id: string]: AreaRegistryEntry };
|
||||
entities: Record<string, EntityRegistryDisplayEntry>;
|
||||
devices: Record<string, DeviceRegistryEntry>;
|
||||
areas: Record<string, AreaRegistryEntry>;
|
||||
floors: Record<string, FloorRegistryEntry>;
|
||||
services: HassServices;
|
||||
config: HassConfig;
|
||||
themes: { [k: string]: any };
|
||||
selectedTheme: { [k: string]: any } | null;
|
||||
themes: Themes;
|
||||
selectedTheme: ThemeSettings | null;
|
||||
panels: Panels;
|
||||
panelUrl: string;
|
||||
// i18n
|
||||
@@ -77,9 +101,9 @@ export interface HomeAssistant {
|
||||
language: string;
|
||||
// local stored language, keep that name for backward compatibility
|
||||
selectedLanguage: string | null;
|
||||
locale: { [k: string]: any };
|
||||
locale: FrontendLocaleData;
|
||||
resources: Resources;
|
||||
localize: Function;
|
||||
localize: LocalizeFunc;
|
||||
translationMetadata: TranslationMetadata;
|
||||
suspendWhenHidden: boolean;
|
||||
enableShortcuts: boolean;
|
||||
@@ -89,7 +113,61 @@ export interface HomeAssistant {
|
||||
defaultPanel: string;
|
||||
moreInfoEntityId: string | null;
|
||||
user?: CurrentUser;
|
||||
userData?: { [k: string]: any } | null;
|
||||
|
||||
userData?: CoreFrontendUserData | null;
|
||||
hassUrl(path?: any): string;
|
||||
callService(
|
||||
domain: ServiceCallRequest["domain"],
|
||||
service: ServiceCallRequest["service"],
|
||||
serviceData?: ServiceCallRequest["serviceData"],
|
||||
target?: ServiceCallRequest["target"],
|
||||
notifyOnError?: boolean,
|
||||
returnResponse?: boolean
|
||||
): Promise<ServiceCallResponse>;
|
||||
callApi<T>(
|
||||
method: "GET" | "POST" | "PUT" | "DELETE",
|
||||
path: string,
|
||||
parameters?: Record<string, any>,
|
||||
headers?: Record<string, string>
|
||||
): Promise<T>;
|
||||
callApiRaw( // introduced in 2024.11
|
||||
method: "GET" | "POST" | "PUT" | "DELETE",
|
||||
path: string,
|
||||
parameters?: Record<string, any>,
|
||||
headers?: Record<string, string>,
|
||||
signal?: AbortSignal
|
||||
): Promise<Response>;
|
||||
fetchWithAuth(path: string, init?: Record<string, any>): Promise<Response>;
|
||||
sendWS(msg: MessageBase): void;
|
||||
callWS<T>(msg: MessageBase): Promise<T>;
|
||||
loadBackendTranslation(
|
||||
category: Parameters<typeof getHassTranslations>[2],
|
||||
integrations?: Parameters<typeof getHassTranslations>[3],
|
||||
configFlow?: Parameters<typeof getHassTranslations>[4]
|
||||
): Promise<LocalizeFunc>;
|
||||
loadFragmentTranslation(fragment: string): Promise<LocalizeFunc | undefined>;
|
||||
formatEntityState(stateObj: HassEntity, state?: string): string;
|
||||
formatEntityAttributeValue(
|
||||
stateObj: HassEntity,
|
||||
attribute: string,
|
||||
value?: any
|
||||
): string;
|
||||
formatEntityAttributeName(stateObj: HassEntity, attribute: string): string;
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
id: string;
|
||||
parent_id?: string;
|
||||
user_id?: string | null;
|
||||
}
|
||||
|
||||
export interface ServiceCallRequest {
|
||||
domain: string;
|
||||
service: string;
|
||||
serviceData?: Record<string, any>;
|
||||
target?: HassServiceTarget;
|
||||
}
|
||||
|
||||
export interface ServiceCallResponse {
|
||||
context: Context;
|
||||
response?: any;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import {LovelaceChipConfig} from "../utils/lovelace/chip/types";
|
||||
* Chips Card Configuration
|
||||
*
|
||||
* @param {LovelaceChipConfig[]} chips Chips Array
|
||||
* @param {string} [alignment=start] Chips alignment (end, center, justify), when empty default behavior is start.
|
||||
* @param {string} [alignment=start] Chips alignment (start,end, center, justify), when empty default behavior is start.
|
||||
*
|
||||
* @see https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/chips.md
|
||||
*/
|
||||
|
@@ -9,6 +9,7 @@ import {AppearanceSharedConfig} from "../shared/config/appearance-config";
|
||||
* @property {boolean} [icon_animation=false] Animate the icon when fan is on.
|
||||
* @property {boolean} [show_percentage_control=false] Show a slider to control speed.
|
||||
* @property {boolean} [show_oscillate_control=false] Show a button to control oscillation.
|
||||
* @property {boolean} [show_direction_control=false] Show a button to control the direction.
|
||||
* @property {boolean} [icon_animation=false] Animate the icon when fan is on.
|
||||
*
|
||||
* @see https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/fan.md
|
||||
@@ -20,5 +21,6 @@ export type FanCardConfig = LovelaceCardConfig &
|
||||
icon_animation?: boolean;
|
||||
show_percentage_control?: boolean;
|
||||
show_oscillate_control?: boolean;
|
||||
show_direction_control?: boolean;
|
||||
collapsible_controls?: boolean;
|
||||
};
|
||||
|
@@ -5,11 +5,10 @@ import {AppearanceSharedConfig} from "../lovelace-mushroom/shared/config/appeara
|
||||
import {ActionsSharedConfig} from "../lovelace-mushroom/shared/config/actions-config";
|
||||
import {TemplateCardConfig} from "../lovelace-mushroom/cards/template-card-config";
|
||||
import {EntityCardConfig} from "../lovelace-mushroom/cards/entity-card-config";
|
||||
import {PictureEntityCardConfig} from "../homeassistant/panels/lovelave/cards/types";
|
||||
import {AreaCardConfig, PictureEntityCardConfig} from "../homeassistant/panels/lovelace/cards/types";
|
||||
import {ClimateCardConfig} from "../lovelace-mushroom/cards/climate-card-config";
|
||||
import {CoverCardConfig} from "../lovelace-mushroom/cards/cover-card-config";
|
||||
import {FanCardConfig} from "../lovelace-mushroom/cards/fan-card-config";
|
||||
import {AreaCardConfig} from "../homeassistant/lovelace/cards/types";
|
||||
import {LightCardConfig} from "../lovelace-mushroom/cards/light-card-config";
|
||||
import {LockCardConfig} from "../lovelace-mushroom/cards/lock-card-config";
|
||||
import {MediaPlayerCardConfig} from "../lovelace-mushroom/cards/media-player-card-config";
|
||||
|
@@ -1,19 +1,98 @@
|
||||
import {
|
||||
CallServiceActionConfig,
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
LovelaceViewConfig
|
||||
} from "../homeassistant/data/lovelace";
|
||||
import {CallServiceActionConfig, LovelaceCardConfig,} from "../homeassistant/data/lovelace";
|
||||
import {HomeAssistant} from "../homeassistant/types";
|
||||
import {AreaRegistryEntry} from "../homeassistant/data/area_registry";
|
||||
import {cards} from "./cards";
|
||||
import {EntityRegistryEntry} from "../homeassistant/data/entity_registry";
|
||||
import {LovelaceChipConfig} from "../lovelace-mushroom/utils/lovelace/chip/types";
|
||||
import {HassServiceTarget} from "home-assistant-js-websocket";
|
||||
import {LovelaceViewConfig, LovelaceViewRawConfig} from "../homeassistant/data/lovelace/config/view";
|
||||
import {LovelaceConfig} from "../homeassistant/data/lovelace/config/types";
|
||||
|
||||
/**
|
||||
* List of supported domains.
|
||||
*
|
||||
* This constant array defines the domains that are supported by the strategy.
|
||||
* Each domain represents a specific type of entity within the Home Assistant ecosystem.
|
||||
*
|
||||
* _ refers to all domains.
|
||||
* default refers to the miscellanea domain.
|
||||
*
|
||||
* @readonly
|
||||
* @constant
|
||||
*/
|
||||
const SUPPORTED_DOMAINS = [
|
||||
"_",
|
||||
"binary_sensor",
|
||||
"camera",
|
||||
"climate",
|
||||
"cover",
|
||||
"default",
|
||||
"fan",
|
||||
"input_select",
|
||||
"light",
|
||||
"lock",
|
||||
"media_player",
|
||||
"number",
|
||||
"scene",
|
||||
"select",
|
||||
"sensor",
|
||||
"switch",
|
||||
"vacuum",
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* List of supported views.
|
||||
*
|
||||
* This constant array defines the views that are supported by the strategy.
|
||||
*
|
||||
* @readonly
|
||||
* @constant
|
||||
*/
|
||||
const SUPPORTED_VIEWS = [
|
||||
"camera",
|
||||
"climate",
|
||||
"cover",
|
||||
"fan",
|
||||
"home",
|
||||
"light",
|
||||
"scene",
|
||||
"switch",
|
||||
"vacuum",
|
||||
] as const;
|
||||
|
||||
const SUPPORTED_CHIPS = [
|
||||
"light",
|
||||
"fan",
|
||||
"cover",
|
||||
"switch",
|
||||
"climate",
|
||||
"weather",
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* List of home view sections.
|
||||
*
|
||||
* This constant array defines the sections that are present in the home view.
|
||||
*
|
||||
* @readonly
|
||||
* @constant
|
||||
*/
|
||||
const HOME_VIEW_SECTIONS = [
|
||||
"areas",
|
||||
"areasTitle",
|
||||
"chips",
|
||||
"greeting",
|
||||
"persons",
|
||||
] as const;
|
||||
|
||||
export namespace generic {
|
||||
export type SupportedDomains = typeof SUPPORTED_DOMAINS[number];
|
||||
export type SupportedViews = typeof SUPPORTED_VIEWS[number];
|
||||
export type SupportedChips = typeof SUPPORTED_CHIPS[number];
|
||||
export type HomeViewSections = typeof HOME_VIEW_SECTIONS[number];
|
||||
|
||||
/**
|
||||
* An entry out of a Home Assistant Register.
|
||||
* An entry of a Home Assistant Register.
|
||||
*/
|
||||
export type RegistryEntry =
|
||||
| AreaRegistryEntry
|
||||
@@ -21,164 +100,179 @@ export namespace generic {
|
||||
| EntityRegistryEntry
|
||||
|
||||
/**
|
||||
* View Entity.
|
||||
* View Configuration of the strategy.
|
||||
*
|
||||
* @property {number} [order] Ordering position of the entity in the list of available views.
|
||||
* @property {boolean} [hidden] True if the entity should be hidden from the dashboard.
|
||||
* @interface StrategyViewConfig
|
||||
* @extends LovelaceViewConfig
|
||||
*
|
||||
* @property {boolean} [hidden] If True, the view is hidden from the dashboard.
|
||||
* @property {number} [order] Ordering position of the views at the top of the dashboard.
|
||||
*/
|
||||
export interface ViewConfig extends LovelaceViewConfig {
|
||||
hidden?: boolean;
|
||||
export interface StrategyViewConfig extends LovelaceViewConfig {
|
||||
hidden: boolean;
|
||||
order: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* All Domains Configuration.
|
||||
*
|
||||
* @interface AllDomainsConfig
|
||||
*
|
||||
* @property {boolean} [hide_config_entities] If True, all configuration entities are hidden from the dashboard.
|
||||
* @property {boolean} [hide_diagnostic_entities] If True, all diagnostic entities are hidden from the dashboard.
|
||||
*/
|
||||
export interface AllDomainsConfig {
|
||||
hide_config_entities: boolean;
|
||||
hide_diagnostic_entities: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Single Domain Configuration.
|
||||
*
|
||||
* @interface SingleDomainConfig
|
||||
* @extends Partial<cards.ControllerCardConfig>
|
||||
*
|
||||
* @property {boolean} [hidden] If True, all entities of the domain are hidden from the dashboard.
|
||||
* @property {number} [order] Ordering position of the domains in a views.
|
||||
*/
|
||||
export interface SingleDomainConfig extends Partial<cards.ControllerCardConfig> {
|
||||
hidden: boolean;
|
||||
order?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Domain Configuration.
|
||||
*
|
||||
* @property {number} [order] Ordering position of the entity in the list of available views.
|
||||
* @property {boolean} [hidden] True if the entity should be hidden from the dashboard.
|
||||
* @property {boolean} [hide_config_entities] True if the entity's categorie is "config" and should be hidden from the
|
||||
* dashboard.
|
||||
* @property {boolean} [hide_diagnostic_entities] True if the entity's categorie is "diagnostic" and should be hidden
|
||||
* from the dashboard.
|
||||
*/
|
||||
export interface DomainConfig extends Partial<cards.ControllerCardConfig> {
|
||||
hidden?: boolean;
|
||||
order?: number;
|
||||
hide_config_entities?: boolean
|
||||
hide_diagnostic_entities?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard Information Object.
|
||||
* Dashboard Info Object.
|
||||
*
|
||||
* Home Assistant passes this object to the Dashboard Generator method.
|
||||
*
|
||||
* @interface DashboardInfo
|
||||
*
|
||||
* @property {LovelaceConfig} config Dashboard configuration.
|
||||
* @property {HomeAssistant} hass The Home Assistant object.
|
||||
*
|
||||
* @see https://developers.home-assistant.io/docs/frontend/custom-ui/custom-strategy/#dashboard-strategies
|
||||
*/
|
||||
export interface DashBoardInfo {
|
||||
config?: LovelaceConfig & {
|
||||
export interface DashboardInfo {
|
||||
config: LovelaceViewRawConfig & {
|
||||
strategy: {
|
||||
options?: StrategyConfig
|
||||
options?: StrategyConfig & { area: StrategyArea }
|
||||
}
|
||||
};
|
||||
hass: HomeAssistant;
|
||||
}
|
||||
|
||||
/**
|
||||
* View Information Object.
|
||||
* View Info Object.
|
||||
*
|
||||
* Home Assistant passes this object to the View Generator method.
|
||||
*
|
||||
* @property {LovelaceViewConfig} view View configuration.
|
||||
* @interface ViewInfo
|
||||
*
|
||||
* @property {LovelaceConfig} config Dashboard configuration.
|
||||
* @property {HomeAssistant} hass The Home Assistant object.
|
||||
* @property {LovelaceViewConfig} view View configuration.
|
||||
*
|
||||
* @see https://developers.home-assistant.io/docs/frontend/custom-ui/custom-strategy/#view-strategies
|
||||
*/
|
||||
export interface ViewInfo {
|
||||
view: LovelaceViewConfig & {
|
||||
strategy?: {
|
||||
config: LovelaceConfig;
|
||||
hass: HomeAssistant;
|
||||
view: LovelaceViewRawConfig & {
|
||||
strategy: {
|
||||
options?: StrategyConfig & { area: StrategyArea }
|
||||
}
|
||||
};
|
||||
config: LovelaceConfig
|
||||
hass: HomeAssistant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strategy Configuration.
|
||||
*
|
||||
* @property {Object.<AreaRegistryEntry>} areas List of areas.
|
||||
* @property {Object.<CustomCardConfig>} [card_options] Card options for entities.
|
||||
* @property {chips} [chips] List of chips to show in the Home view.
|
||||
* @property {boolean} [debug] Set to true for more verbose debugging info.
|
||||
* @property {Object.<DomainConfig>} domains List of domains.
|
||||
* @property {object[]} [extra_cards] List of cards to show below room cards.
|
||||
* @property {object[]} [extra_views] List of views to add to the dashboard.
|
||||
* @property {object[]} [quick_access_cards] List of cards to show between welcome card and rooms cards.
|
||||
* @property {Object.<ViewConfig>} views List of views.
|
||||
* @interface StrategyConfig
|
||||
*
|
||||
* @property {Object.<string, StrategyArea>} areas List of areas.
|
||||
* @property {Object.<string, CustomCardConfig>} card_options Card options for entities.
|
||||
* @property {Partial<ChipConfiguration>} chips The configuration of chips in the Home view.
|
||||
* @property {boolean} debug If True, the strategy outputs more verbose debug information in the console.
|
||||
* @property {Object.<string, AllDomainsConfig | SingleDomainConfig>} domains List of domains.
|
||||
* @property {LovelaceCardConfig[]} extra_cards List of cards to show below room cards.
|
||||
* @property {StrategyViewConfig[]} extra_views List of custom-defined views to add to the dashboard.
|
||||
* @property {{ hidden: HomeViewSections[] | [] }} home_view List of views to add to the dashboard.
|
||||
* @property {Object.<hidden, StrategyViewConfig>} views The configurations of views.
|
||||
* @property {LovelaceCardConfig[]} quick_access_cards List of custom-defined cards to show between the welcome card
|
||||
* and rooms cards.
|
||||
*/
|
||||
export interface StrategyConfig {
|
||||
areas: { [k: string]: StrategyArea };
|
||||
card_options?: { [k: string]: CustomCardConfig };
|
||||
chips?: Chips;
|
||||
areas: { [S: string]: StrategyArea };
|
||||
card_options: { [S: string]: CustomCardConfig };
|
||||
chips: Partial<ChipConfiguration>;
|
||||
debug: boolean;
|
||||
domains: { [k: string]: DomainConfig };
|
||||
extra_cards?: LovelaceCardConfig[];
|
||||
extra_views?: ViewConfig[];
|
||||
domains: { [K in SupportedDomains]: K extends "_" ? AllDomainsConfig : SingleDomainConfig; };
|
||||
extra_cards: LovelaceCardConfig[];
|
||||
extra_views: StrategyViewConfig[];
|
||||
home_view: {
|
||||
hidden: HiddenSectionType[]
|
||||
hidden: HomeViewSections[] | [];
|
||||
}
|
||||
quick_access_cards?: LovelaceCardConfig[];
|
||||
views: { [k: string]: ViewConfig };
|
||||
views: Record<SupportedViews, StrategyViewConfig>;
|
||||
quick_access_cards: LovelaceCardConfig[];
|
||||
}
|
||||
|
||||
const hiddenSectionList = ["chips", "persons", "greeting", "areas", "areasTitle"] as const;
|
||||
export type HiddenSectionType = typeof hiddenSectionList[number];
|
||||
|
||||
/**
|
||||
* Represents the default configuration for a strategy.
|
||||
*
|
||||
* @interface StrategyDefaults
|
||||
*/
|
||||
export interface StrategyDefaults extends StrategyConfig {
|
||||
areas: {
|
||||
undisclosed: StrategyArea & {
|
||||
area_id: "undisclosed",
|
||||
},
|
||||
[k: string]: StrategyArea,
|
||||
},
|
||||
domains: {
|
||||
default: DomainConfig,
|
||||
[k: string]: DomainConfig,
|
||||
}
|
||||
areas: { "undisclosed": StrategyArea } & { [S: string]: StrategyArea };
|
||||
}
|
||||
|
||||
/**
|
||||
* Strategy Area.
|
||||
*
|
||||
* @property {number} [order] Ordering position of the area in the list of available areas.
|
||||
* @interface StrategyArea
|
||||
*
|
||||
* @property {boolean} [hidden] True if the entity should be hidden from the dashboard.
|
||||
* @property {object[]} [extra_cards] An array of card configurations.
|
||||
* The configured cards are added to the dashboard.
|
||||
* @property {string} [type=default] The type of area card.
|
||||
* @property {number} [order] Ordering position of the area in the list of available areas.
|
||||
* @property {string} [type] The type of area card.
|
||||
*/
|
||||
export interface StrategyArea extends AreaRegistryEntry {
|
||||
order?: number;
|
||||
hidden?: boolean;
|
||||
extra_cards?: LovelaceCardConfig[];
|
||||
hidden?: boolean;
|
||||
order?: number;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of chips to show in the Home view.
|
||||
*
|
||||
* @property {boolean} light_count Chip to display the number of lights on.
|
||||
* @property {boolean} fan_count Chip to display the number of fans on.
|
||||
* @property {boolean} cover_count Chip to display the number of unclosed covers.
|
||||
* @property {boolean} switch_count Chip to display the number of switches on.
|
||||
* @interface ChipConfiguration
|
||||
*
|
||||
* @property {boolean} climate_count Chip to display the number of climates which are not off.
|
||||
* @property {boolean} cover_count Chip to display the number of unclosed covers.
|
||||
* @property {boolean} fan_count Chip to display the number of fans on.
|
||||
* @property {boolean} light_count Chip to display the number of lights on.
|
||||
* @property {boolean} switch_count Chip to display the number of switches on.
|
||||
* @property {string} weather_entity Entity ID for the weather chip to use, accepts `weather.` only.
|
||||
* @property {object[]} extra_chips List of extra chips.
|
||||
*/
|
||||
export interface Chips {
|
||||
extra_chips: LovelaceChipConfig[];
|
||||
|
||||
light_count: boolean;
|
||||
fan_count: boolean;
|
||||
cover_count: boolean;
|
||||
switch_count: boolean;
|
||||
export interface ChipConfiguration {
|
||||
climate_count: boolean;
|
||||
cover_count: boolean;
|
||||
extra_chips: LovelaceChipConfig[];
|
||||
fan_count: boolean;
|
||||
light_count: boolean;
|
||||
switch_count: boolean;
|
||||
weather_entity: string;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Card Configuration for an entity.
|
||||
*
|
||||
* @property {boolean} hidden True if the entity should be hidden from the dashboard.
|
||||
* @interface CustomCardConfig
|
||||
* @extends LovelaceCardConfig
|
||||
*
|
||||
* @property {boolean} hidden If True, the card is hidden from the dashboard.
|
||||
*/
|
||||
export interface CustomCardConfig extends LovelaceCardConfig {
|
||||
hidden?: boolean;
|
||||
@@ -187,9 +281,12 @@ export namespace generic {
|
||||
/**
|
||||
* Area Filter Context.
|
||||
*
|
||||
* @property {AreaRegistryEntry} area Area Entity.
|
||||
* @property {string[]} areaDeviceIds The id of devices which are linked to the area entity.
|
||||
* @property {string} [domain] Domain of the entity. Example: `light`.
|
||||
* @interface AreaFilterContext
|
||||
*
|
||||
* @property {AreaRegistryEntry} area Area Entry.
|
||||
* @property {string[]} areaDeviceIds The id of devices which are linked to the area.
|
||||
* @property {string} [domain] Domain of an entity.
|
||||
* Example: `light`.
|
||||
*/
|
||||
export interface AreaFilterContext {
|
||||
area: AreaRegistryEntry;
|
||||
@@ -201,7 +298,7 @@ export namespace generic {
|
||||
* Checks if the given object is an instance of CallServiceActionConfig.
|
||||
*
|
||||
* @param {any} obj - The object to be checked.
|
||||
* @return {boolean} - Returns true if the object is an instance of CallServiceActionConfig, otherwise false.
|
||||
* @returns {boolean} - Returns true if the object is an instance of CallServiceActionConfig, otherwise false.
|
||||
*/
|
||||
export function isCallServiceActionConfig(obj: any): obj is CallServiceActionConfig {
|
||||
return obj && obj.action === "call-service" && ["action", "service"].every(key => key in obj);
|
||||
@@ -211,9 +308,60 @@ export namespace generic {
|
||||
* Checks if the given object is an instance of HassServiceTarget.
|
||||
*
|
||||
* @param {any} obj - The object to check.
|
||||
* @return {boolean} - True if the object is an instance of HassServiceTarget, false otherwise.
|
||||
* @returns {boolean} - True if the object is an instance of HassServiceTarget, false otherwise.
|
||||
*/
|
||||
export function isCallServiceActionTarget(obj: any): obj is HassServiceTarget {
|
||||
return obj && ["entity_id", "device_id", "area_id"].some(key => key in obj);
|
||||
}
|
||||
|
||||
interface SortableBase {
|
||||
order: number;
|
||||
}
|
||||
|
||||
type SortableWithTitle = SortableBase & { title: string; name?: never };
|
||||
type SortableWithName = SortableBase & { name: string; title?: never };
|
||||
|
||||
|
||||
/**
|
||||
* The union type of SortableWithTitle and SortableWithName.
|
||||
*
|
||||
* @remarks
|
||||
* This type is used to sort objects by title or by name.
|
||||
* The `order` property is used to sort the objects.
|
||||
* The `title` and `name` properties are used to display the object in the UI.
|
||||
*/
|
||||
export type Sortable = SortableWithTitle | SortableWithName;
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given object is of a sortable type.
|
||||
*
|
||||
* Sortable types are objects that have a `title` or a `name` property and an `order` property.
|
||||
*
|
||||
* @param {any} obj - The object to check.
|
||||
* @returns {boolean} - True if the object is an instance of Sortable, false otherwise.
|
||||
*/
|
||||
export function isSortable(obj: any): obj is Sortable {
|
||||
return obj && 'order' in obj && ('title' in obj || 'name' in obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given view id is a supported view.
|
||||
*
|
||||
* @param {string} id - The view id to check.
|
||||
* @returns {boolean} - Returns true if the view id is a supported view, otherwise false.
|
||||
*/
|
||||
export function isSupportedView(id: string): id is SupportedViews {
|
||||
return SUPPORTED_VIEWS.includes(id as SupportedViews);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given domain id is a supported domain.
|
||||
*
|
||||
* @param {string} id - The domain id to check.
|
||||
* @returns {boolean} - Returns true if the domain id is a supported domain, otherwise false.
|
||||
*/
|
||||
export function isSupportedDomain(id: string): id is SupportedDomains {
|
||||
return SUPPORTED_DOMAINS.includes(id as SupportedDomains);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import {cards} from "./cards";
|
||||
import {LovelaceViewConfig} from "../homeassistant/data/lovelace";
|
||||
import {LovelaceViewConfig} from "../homeassistant/data/lovelace/config/view";
|
||||
|
||||
export namespace views {
|
||||
/**
|
||||
|
@@ -1,5 +1,7 @@
|
||||
import {EntityRegistryEntry} from "../types/homeassistant/data/entity_registry";
|
||||
import {Helper} from "../Helper";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
/**
|
||||
* Filter an array of entities by property/value pair
|
||||
@@ -20,7 +22,7 @@ export function filterEntitiesByPropertyValue(
|
||||
return entities.filter(entity => exclude ? entity[property] !== value : entity[property] === value);
|
||||
}
|
||||
|
||||
export function applyEntityCategoryFilters(entities: EntityRegistryEntry[], domain: string) {
|
||||
export function applyEntityCategoryFilters(entities: EntityRegistryEntry[], domain: SupportedDomains) {
|
||||
if (!Helper.isInitialized()) {
|
||||
throw new Error("The Helper module must be initialized before using this one.");
|
||||
}
|
||||
@@ -49,4 +51,14 @@ export function applyEntityCategoryFilters(entities: EntityRegistryEntry[], doma
|
||||
return entities;
|
||||
}
|
||||
|
||||
/*export function filterHiddenEntities(entities: EntityRegistryEntry[]) {
|
||||
entities = entities.filter(
|
||||
function (entity) {
|
||||
return entity.hidden_by === null // entity is not hidden by HASS settings.
|
||||
&& entity.disabled_by === null // entity is not disabled by HASS settings.
|
||||
&& Helper.strategyOptions.card_options.[entity.entity_id] // entity is not hidden by strategy options.
|
||||
}
|
||||
);
|
||||
}*/
|
||||
|
||||
|
||||
|
@@ -1,12 +1,15 @@
|
||||
import {Helper} from "../Helper";
|
||||
import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {StackCardConfig} from "../types/homeassistant/lovelace/cards/types";
|
||||
import {LovelaceCardConfig, LovelaceViewConfig} from "../types/homeassistant/data/lovelace";
|
||||
import {LovelaceCardConfig} from "../types/homeassistant/data/lovelace";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {TitleCardConfig} from "../types/lovelace-mushroom/cards/title-card-config";
|
||||
import {HassServiceTarget} from "home-assistant-js-websocket";
|
||||
import {applyEntityCategoryFilters} from "../utillties/filters";
|
||||
import {LovelaceViewConfig} from "../types/homeassistant/data/lovelace/config/view";
|
||||
import {StackCardConfig} from "../types/homeassistant/panels/lovelace/cards/types";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import abstractCardConfig = cards.AbstractCardConfig;
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
/**
|
||||
* Abstract View Class.
|
||||
@@ -40,20 +43,21 @@ abstract class AbstractView {
|
||||
/**
|
||||
* The domain of which we operate the devices.
|
||||
*
|
||||
* @type {SupportedDomains | "home"}
|
||||
* @private
|
||||
* @readonly
|
||||
*/
|
||||
readonly #domain: string;
|
||||
readonly #domain: SupportedDomains | "home";
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param {string} domain The domain which the view is representing.
|
||||
* @param {SupportedDomains} domain The domain which the view is representing.
|
||||
*
|
||||
* @throws {Error} If trying to instantiate this class.
|
||||
* @throws {Error} If the Helper module isn't initialized.
|
||||
*/
|
||||
protected constructor(domain: string) {
|
||||
protected constructor(domain: SupportedDomains | "home") {
|
||||
if (!Helper.isInitialized()) {
|
||||
throw new Error("The Helper module must be initialized before using this one.");
|
||||
}
|
||||
@@ -67,6 +71,13 @@ abstract class AbstractView {
|
||||
* @return {Promise<(StackCardConfig | TitleCardConfig)[]>} An array of card objects.
|
||||
*/
|
||||
async createViewCards(): Promise<(StackCardConfig | TitleCardConfig)[]> {
|
||||
if (this.#domain === "home") {
|
||||
// The home domain should override this method because it hasn't entities on its own.
|
||||
// The method override creates its own cards to show at the home view.
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
const viewCards: LovelaceCardConfig[] = [];
|
||||
|
||||
// Create cards for each area.
|
||||
|
@@ -3,6 +3,8 @@ import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {Helper} from "../Helper";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class CameraView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "camera";
|
||||
static #domain: SupportedDomains = "camera";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class ClimateView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "climate";
|
||||
static #domain: SupportedDomains = "climate";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class CoverView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "cover";
|
||||
static #domain: SupportedDomains = "cover";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class FanView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "fan";
|
||||
static #domain: SupportedDomains = "fan";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,11 +3,13 @@ import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {LovelaceChipConfig} from "../types/lovelace-mushroom/utils/lovelace/chip/types";
|
||||
import {ChipsCardConfig} from "../types/lovelace-mushroom/cards/chips-card";
|
||||
import {AreaCardConfig, StackCardConfig} from "../types/homeassistant/lovelace/cards/types";
|
||||
import {TemplateCardConfig} from "../types/lovelace-mushroom/cards/template-card-config";
|
||||
import {ActionConfig} from "../types/homeassistant/data/lovelace";
|
||||
import {TitleCardConfig} from "../types/lovelace-mushroom/cards/title-card-config";
|
||||
import {PersonCardConfig} from "../types/lovelace-mushroom/cards/person-card-config";
|
||||
import {AreaCardConfig, StackCardConfig} from "../types/homeassistant/panels/lovelace/cards/types";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import supportedChips = generic.SupportedChips;
|
||||
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
@@ -76,27 +78,26 @@ class HomeView extends AbstractView {
|
||||
} as StackCardConfig);
|
||||
}
|
||||
|
||||
if (!Helper.strategyOptions.home_view.hidden.includes("greeting")) {
|
||||
const greeting =
|
||||
homeViewCards.push({
|
||||
type: "custom:mushroom-template-card",
|
||||
primary:
|
||||
`{% set time = now().hour %} {% if (time >= 18) %} ${Helper.customLocalize("generic.good_evening")},{{user}}!
|
||||
{% elif (time >= 12) %} ${Helper.customLocalize("generic.good_afternoon")}, {{user}}!
|
||||
{% elif (time >= 5) %} ${Helper.customLocalize("generic.good_morning")}, {{user}}!
|
||||
{% else %} ${Helper.customLocalize("generic.hello")}, {{user}}! {% endif %}`,
|
||||
icon: "mdi:hand-wave",
|
||||
icon_color: "orange",
|
||||
tap_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
double_tap_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
hold_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
} as TemplateCardConfig);
|
||||
if (!(Helper.strategyOptions.home_view.hidden as string[]).includes("greeting")) {
|
||||
homeViewCards.push({
|
||||
type: "custom:mushroom-template-card",
|
||||
primary:
|
||||
`{% set time = now().hour %} {% if (time >= 18) %} ${Helper.customLocalize("generic.good_evening")},{{user}}!
|
||||
{% elif (time >= 12) %} ${Helper.customLocalize("generic.good_afternoon")}, {{user}}!
|
||||
{% elif (time >= 5) %} ${Helper.customLocalize("generic.good_morning")}, {{user}}!
|
||||
{% else %} ${Helper.customLocalize("generic.hello")}, {{user}}! {% endif %}`,
|
||||
icon: "mdi:hand-wave",
|
||||
icon_color: "orange",
|
||||
tap_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
double_tap_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
hold_action: {
|
||||
action: "none",
|
||||
} as ActionConfig,
|
||||
} as TemplateCardConfig);
|
||||
}
|
||||
|
||||
// Add quick access cards.
|
||||
@@ -125,8 +126,8 @@ class HomeView extends AbstractView {
|
||||
* @return {Promise<LovelaceChipConfig[]>} Promise a chip array.
|
||||
*/
|
||||
async #createChips(): Promise<LovelaceChipConfig[]> {
|
||||
if (Helper.strategyOptions.home_view.hidden.includes("chips")) {
|
||||
// Chips section is hidden.
|
||||
if ((Helper.strategyOptions.home_view.hidden as string[]).includes("chips")) {
|
||||
// The Chip section is hidden.
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -135,14 +136,14 @@ class HomeView extends AbstractView {
|
||||
const chipOptions = Helper.strategyOptions.chips;
|
||||
|
||||
// TODO: Get domains from config.
|
||||
const exposedChips = ["light", "fan", "cover", "switch", "climate"];
|
||||
const exposedChips: supportedChips[] = ["light", "fan", "cover", "switch", "climate"];
|
||||
// Create a list of area-ids, used for switching all devices via chips
|
||||
const areaIds = Helper.areas.map(area => area.area_id ?? "");
|
||||
|
||||
let chipModule;
|
||||
|
||||
// Weather chip.
|
||||
const weatherEntityId = chipOptions?.weather_entity ?? Helper.entities.find(
|
||||
const weatherEntityId = chipOptions.weather_entity ?? Helper.entities.find(
|
||||
(entity) => entity.entity_id.startsWith("weather.") && entity.disabled_by === null && entity.hidden_by === null,
|
||||
)?.entity_id;
|
||||
|
||||
@@ -159,7 +160,7 @@ class HomeView extends AbstractView {
|
||||
|
||||
// Numeric chips.
|
||||
for (let chipType of exposedChips) {
|
||||
if (chipOptions?.[`${chipType}_count` as string] ?? true) {
|
||||
if (chipType !== "weather" && (chipOptions?.[(`${chipType}_count`)] ?? true)) {
|
||||
const className = Helper.sanitizeClassName(chipType + "Chip");
|
||||
try {
|
||||
chipModule = await import((`../chips/${className}`));
|
||||
@@ -187,8 +188,8 @@ class HomeView extends AbstractView {
|
||||
* @return {PersonCardConfig[]} A Person Card array.
|
||||
*/
|
||||
#createPersonCards(): PersonCardConfig[] {
|
||||
if (Helper.strategyOptions.home_view.hidden.includes("persons")) {
|
||||
// Person section is hidden.
|
||||
if ((Helper.strategyOptions.home_view.hidden as string[]).includes("persons")) {
|
||||
// The Person section is hidden.
|
||||
|
||||
return [];
|
||||
}
|
||||
@@ -216,7 +217,7 @@ class HomeView extends AbstractView {
|
||||
* @return {Promise<(TitleCardConfig | StackCardConfig)[]>} Promise an Area Card Section.
|
||||
*/
|
||||
async #createAreaSection(): Promise<(TitleCardConfig | StackCardConfig)[]> {
|
||||
if (Helper.strategyOptions.home_view.hidden.includes("areas")) {
|
||||
if ((Helper.strategyOptions.home_view.hidden as string[]).includes("areas")) {
|
||||
// Areas section is hidden.
|
||||
|
||||
return [];
|
||||
@@ -226,7 +227,7 @@ class HomeView extends AbstractView {
|
||||
|
||||
let areaCards: (TemplateCardConfig | AreaCardConfig)[] = [];
|
||||
|
||||
if (!Helper.strategyOptions.home_view.hidden.includes("areasTitle")) {
|
||||
if (!(Helper.strategyOptions.home_view.hidden as string[]).includes("areasTitle")) {
|
||||
groupedCards.push({
|
||||
type: "custom:mushroom-title-card",
|
||||
title: Helper.customLocalize("generic.areas"),
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class LightView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "light";
|
||||
static #domain: SupportedDomains = "light";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import {Helper} from "../Helper";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -15,11 +17,11 @@ class SceneView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "scene";
|
||||
static #domain: SupportedDomains = "scene";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class SwitchView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "switch";
|
||||
static #domain: SupportedDomains = "switch";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
@@ -3,6 +3,8 @@ import {ControllerCard} from "../cards/ControllerCard";
|
||||
import {AbstractView} from "./AbstractView";
|
||||
import {views} from "../types/strategy/views";
|
||||
import {cards} from "../types/strategy/cards";
|
||||
import {generic} from "../types/strategy/generic";
|
||||
import SupportedDomains = generic.SupportedDomains;
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols Class is dynamically imported.
|
||||
/**
|
||||
@@ -17,11 +19,11 @@ class VacuumView extends AbstractView {
|
||||
/**
|
||||
* Domain of the view's entities.
|
||||
*
|
||||
* @type {string}
|
||||
* @type {SupportedDomains}
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
static #domain: string = "vacuum";
|
||||
static #domain: SupportedDomains = "vacuum";
|
||||
|
||||
/**
|
||||
* Default configuration of the view.
|
||||
|
Reference in New Issue
Block a user