mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-25 10:47:19 +00:00
Compare commits
66 Commits
logs-front
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccc48d158a | ||
|
|
b11e787f09 | ||
|
|
cdb6562de8 | ||
|
|
d8e8c9aa02 | ||
|
|
be392be1e6 | ||
|
|
10dc432445 | ||
|
|
19187f887d | ||
|
|
dc76a42aaa | ||
|
|
1f2b8047a6 | ||
|
|
e8c9ed0528 | ||
|
|
c7ae78c02f | ||
|
|
dc8f1211e6 | ||
|
|
5c25a63ea5 | ||
|
|
c1787ab994 | ||
|
|
6fea535fdc | ||
|
|
e8cee84380 | ||
|
|
b4613edeb7 | ||
|
|
a8b6e5aa3d | ||
|
|
e842193cd6 | ||
|
|
bb0813333d | ||
|
|
ab4c6f80f4 | ||
|
|
89796e425a | ||
|
|
9c42c8bbc4 | ||
|
|
616237caee | ||
|
|
2d36a0d37f | ||
|
|
1ec432a20f | ||
|
|
afd91b2261 | ||
|
|
cdfb7f914f | ||
|
|
33b0897522 | ||
|
|
5f0cf1b522 | ||
|
|
afb2ad95a4 | ||
|
|
27beab3133 | ||
|
|
435c82489b | ||
|
|
3ba6bf272e | ||
|
|
eec99b2fa3 | ||
|
|
d23e45e410 | ||
|
|
3c82d12609 | ||
|
|
15d67997e7 | ||
|
|
a6dfcb3100 | ||
|
|
26c2369228 | ||
|
|
2eed446492 | ||
|
|
7ebdeab6b2 | ||
|
|
0c35278f51 | ||
|
|
561122f03d | ||
|
|
95311be034 | ||
|
|
1eda44a102 | ||
|
|
d76781eb91 | ||
|
|
82d44e051f | ||
|
|
fdc9f5a3b7 | ||
|
|
ee6c82aba9 | ||
|
|
11d3f5c2ba | ||
|
|
feb68ce373 | ||
|
|
7f9a9de157 | ||
|
|
8e1b6a3d3b | ||
|
|
6e6e5a53e2 | ||
|
|
0408734ec5 | ||
|
|
317519fc08 | ||
|
|
843d79eab4 | ||
|
|
165a757f06 | ||
|
|
ea8b730142 | ||
|
|
e88c97d625 | ||
|
|
7560988b76 | ||
|
|
eecd8077b6 | ||
|
|
cbab5c3f7b | ||
|
|
a5d27c8bb8 | ||
|
|
a6a340b5db |
@@ -18,16 +18,16 @@ module.exports.sourceMapURL = () => {
|
|||||||
module.exports.ignorePackages = () => [];
|
module.exports.ignorePackages = () => [];
|
||||||
|
|
||||||
// Files from NPM packages that we should replace with empty file
|
// Files from NPM packages that we should replace with empty file
|
||||||
module.exports.emptyPackages = ({ isHassioBuild }) =>
|
module.exports.emptyPackages = ({ isHassioBuild, isLandingPageBuild }) =>
|
||||||
[
|
[
|
||||||
require.resolve("@vaadin/vaadin-material-styles/typography.js"),
|
require.resolve("@vaadin/vaadin-material-styles/typography.js"),
|
||||||
require.resolve("@vaadin/vaadin-material-styles/font-icons.js"),
|
require.resolve("@vaadin/vaadin-material-styles/font-icons.js"),
|
||||||
// Icons in supervisor conflict with icons in HA so we don't load.
|
// Icons in supervisor conflict with icons in HA so we don't load.
|
||||||
isHassioBuild &&
|
(isHassioBuild || isLandingPageBuild) &&
|
||||||
require.resolve(
|
require.resolve(
|
||||||
path.resolve(paths.root_dir, "src/components/ha-icon.ts")
|
path.resolve(paths.root_dir, "src/components/ha-icon.ts")
|
||||||
),
|
),
|
||||||
isHassioBuild &&
|
(isHassioBuild || isLandingPageBuild) &&
|
||||||
require.resolve(
|
require.resolve(
|
||||||
path.resolve(paths.root_dir, "src/components/ha-icon-picker.ts")
|
path.resolve(paths.root_dir, "src/components/ha-icon-picker.ts")
|
||||||
),
|
),
|
||||||
@@ -337,6 +337,7 @@ module.exports.config = {
|
|||||||
publicPath: publicPath(latestBuild),
|
publicPath: publicPath(latestBuild),
|
||||||
isProdBuild,
|
isProdBuild,
|
||||||
latestBuild,
|
latestBuild,
|
||||||
|
isLandingPageBuild: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const createRspackConfig = ({
|
|||||||
isStatsBuild,
|
isStatsBuild,
|
||||||
isTestBuild,
|
isTestBuild,
|
||||||
isHassioBuild,
|
isHassioBuild,
|
||||||
|
isLandingPageBuild,
|
||||||
dontHash,
|
dontHash,
|
||||||
}) => {
|
}) => {
|
||||||
if (!dontHash) {
|
if (!dontHash) {
|
||||||
@@ -168,7 +169,9 @@ const createRspackConfig = ({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new rspack.NormalModuleReplacementPlugin(
|
new rspack.NormalModuleReplacementPlugin(
|
||||||
new RegExp(bundle.emptyPackages({ isHassioBuild }).join("|")),
|
new RegExp(
|
||||||
|
bundle.emptyPackages({ isHassioBuild, isLandingPageBuild }).join("|")
|
||||||
|
),
|
||||||
path.resolve(paths.root_dir, "src/util/empty.js")
|
path.resolve(paths.root_dir, "src/util/empty.js")
|
||||||
),
|
),
|
||||||
!isProdBuild && new LogStartCompilePlugin(),
|
!isProdBuild && new LogStartCompilePlugin(),
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import {
|
|||||||
} from "../../../../src/common/auth/token_storage";
|
} from "../../../../src/common/auth/token_storage";
|
||||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||||
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
||||||
|
import "../../../../src/components/ha-button";
|
||||||
import "../../../../src/components/ha-icon";
|
import "../../../../src/components/ha-icon";
|
||||||
import "../../../../src/components/ha-list";
|
import "../../../../src/components/ha-list";
|
||||||
import "../../../../src/components/ha-button";
|
|
||||||
import "../../../../src/components/ha-list-item";
|
import "../../../../src/components/ha-list-item";
|
||||||
import "../../../../src/components/ha-svg-icon";
|
import "../../../../src/components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
@@ -28,7 +28,6 @@ import {
|
|||||||
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
|
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
|
||||||
import type { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
|
||||||
import "../../../../src/layouts/hass-loading-screen";
|
import "../../../../src/layouts/hass-loading-screen";
|
||||||
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
|
|
||||||
import "./hc-layout";
|
import "./hc-layout";
|
||||||
|
|
||||||
@customElement("hc-cast")
|
@customElement("hc-cast")
|
||||||
@@ -96,7 +95,9 @@ class HcCast extends LitElement {
|
|||||||
<ha-list @action=${this._handlePickView} activatable>
|
<ha-list @action=${this._handlePickView} activatable>
|
||||||
${(
|
${(
|
||||||
this.lovelaceViews ?? [
|
this.lovelaceViews ?? [
|
||||||
generateDefaultViewConfig({}, {}, {}, {}, () => ""),
|
{
|
||||||
|
title: "Home",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
).map(
|
).map(
|
||||||
(view, idx) => html`
|
(view, idx) => html`
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const SENSOR_DEVICE_CLASSES = [
|
|||||||
"pm1",
|
"pm1",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
|
"pm4",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"power",
|
"power",
|
||||||
"precipitation",
|
"precipitation",
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import "@material/mwc-linear-progress";
|
import "@material/mwc-linear-progress";
|
||||||
import { type PropertyValues, css, html, nothing } from "lit";
|
import { mdiOpenInNew } from "@mdi/js";
|
||||||
|
import { css, html, nothing, type PropertyValues } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { extractSearchParam } from "../../src/common/url/search-params";
|
||||||
import "../../src/components/ha-alert";
|
import "../../src/components/ha-alert";
|
||||||
|
import "../../src/components/ha-button";
|
||||||
import "../../src/components/ha-fade-in";
|
import "../../src/components/ha-fade-in";
|
||||||
import "../../src/components/ha-spinner";
|
import "../../src/components/ha-spinner";
|
||||||
import { haStyle } from "../../src/resources/styles";
|
import "../../src/components/ha-svg-icon";
|
||||||
import "../../src/onboarding/onboarding-welcome-links";
|
|
||||||
import "./components/landing-page-network";
|
|
||||||
import "./components/landing-page-logs";
|
|
||||||
import { extractSearchParam } from "../../src/common/url/search-params";
|
|
||||||
import { onBoardingStyles } from "../../src/onboarding/styles";
|
|
||||||
import { makeDialogManager } from "../../src/dialogs/make-dialog-manager";
|
import { makeDialogManager } from "../../src/dialogs/make-dialog-manager";
|
||||||
import { LandingPageBaseElement } from "./landing-page-base-element";
|
import "../../src/onboarding/onboarding-welcome-links";
|
||||||
|
import { onBoardingStyles } from "../../src/onboarding/styles";
|
||||||
|
import { haStyle } from "../../src/resources/styles";
|
||||||
|
import "./components/landing-page-logs";
|
||||||
|
import "./components/landing-page-network";
|
||||||
import {
|
import {
|
||||||
getSupervisorNetworkInfo,
|
getSupervisorNetworkInfo,
|
||||||
pingSupervisor,
|
pingSupervisor,
|
||||||
type NetworkInfo,
|
type NetworkInfo,
|
||||||
} from "./data/supervisor";
|
} from "./data/supervisor";
|
||||||
|
import { LandingPageBaseElement } from "./landing-page-base-element";
|
||||||
|
|
||||||
export const ASSUME_CORE_START_SECONDS = 60;
|
export const ASSUME_CORE_START_SECONDS = 60;
|
||||||
const SCHEDULE_CORE_CHECK_SECONDS = 1;
|
const SCHEDULE_CORE_CHECK_SECONDS = 1;
|
||||||
@@ -94,16 +97,21 @@ class HaLandingPage extends LandingPageBaseElement {
|
|||||||
<ha-language-picker
|
<ha-language-picker
|
||||||
.value=${this.language}
|
.value=${this.language}
|
||||||
.label=${""}
|
.label=${""}
|
||||||
|
button-style
|
||||||
native-name
|
native-name
|
||||||
@value-changed=${this._languageChanged}
|
@value-changed=${this._languageChanged}
|
||||||
inline-arrow
|
inline-arrow
|
||||||
></ha-language-picker>
|
></ha-language-picker>
|
||||||
<a
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
variant="neutral"
|
||||||
href="https://www.home-assistant.io/getting-started/onboarding/"
|
href="https://www.home-assistant.io/getting-started/onboarding/"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer noopener"
|
rel="noreferrer noopener"
|
||||||
>${this.localize("ui.panel.page-onboarding.help")}</a
|
|
||||||
>
|
>
|
||||||
|
${this.localize("ui.panel.page-onboarding.help")}
|
||||||
|
<ha-svg-icon slot="end" .path=${mdiOpenInNew}></ha-svg-icon>
|
||||||
|
</ha-button>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -218,26 +226,8 @@ class HaLandingPage extends LandingPageBaseElement {
|
|||||||
ha-alert p {
|
ha-alert p {
|
||||||
text-align: unset;
|
text-align: unset;
|
||||||
}
|
}
|
||||||
ha-language-picker {
|
.footer ha-svg-icon {
|
||||||
display: block;
|
--mdc-icon-size: var(--ha-space-5);
|
||||||
width: 200px;
|
|
||||||
border-radius: var(--ha-border-radius-sm);
|
|
||||||
overflow: hidden;
|
|
||||||
--ha-select-height: 40px;
|
|
||||||
--mdc-select-fill-color: none;
|
|
||||||
--mdc-select-label-ink-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-select-ink-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-select-idle-line-color: transparent;
|
|
||||||
--mdc-select-hover-line-color: transparent;
|
|
||||||
--mdc-select-dropdown-icon-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-shape-small: 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--primary-text-color);
|
|
||||||
margin-right: 16px;
|
|
||||||
margin-inline-end: 16px;
|
|
||||||
margin-inline-start: initial;
|
|
||||||
}
|
}
|
||||||
ha-fade-in {
|
ha-fade-in {
|
||||||
min-height: calc(100vh - 64px - 88px);
|
min-height: calc(100vh - 64px - 88px);
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
"home-assistant-js-websocket": "9.5.0",
|
"home-assistant-js-websocket": "9.5.0",
|
||||||
"idb-keyval": "6.2.2",
|
"idb-keyval": "6.2.2",
|
||||||
"intl-messageformat": "10.7.18",
|
"intl-messageformat": "10.7.18",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.1",
|
||||||
"leaflet": "1.9.4",
|
"leaflet": "1.9.4",
|
||||||
"leaflet-draw": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch",
|
"leaflet-draw": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch",
|
||||||
"leaflet.markercluster": "1.5.3",
|
"leaflet.markercluster": "1.5.3",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20251029.0"
|
version = "20251105.1"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
license-files = ["LICENSE*"]
|
license-files = ["LICENSE*"]
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ export class HaAuthFlow extends LitElement {
|
|||||||
willUpdate(changedProps: PropertyValues) {
|
willUpdate(changedProps: PropertyValues) {
|
||||||
super.willUpdate(changedProps);
|
super.willUpdate(changedProps);
|
||||||
|
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated && this.clientId === genClientId()) {
|
||||||
|
// Preselect store token when logging in to own instance
|
||||||
this._storeToken = this.initStoreToken;
|
this._storeToken = this.initStoreToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable lit/prefer-static-styles */
|
/* eslint-disable lit/prefer-static-styles */
|
||||||
|
import { mdiOpenInNew } from "@mdi/js";
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { html, LitElement, nothing } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
@@ -6,6 +7,8 @@ import punycode from "punycode";
|
|||||||
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
|
||||||
import { extractSearchParamsObject } from "../common/url/search-params";
|
import { extractSearchParamsObject } from "../common/url/search-params";
|
||||||
import "../components/ha-alert";
|
import "../components/ha-alert";
|
||||||
|
import "../components/ha-button";
|
||||||
|
import "../components/ha-svg-icon";
|
||||||
import type { AuthProvider, AuthUrlSearchParams } from "../data/auth";
|
import type { AuthProvider, AuthUrlSearchParams } from "../data/auth";
|
||||||
import { fetchAuthProviders } from "../data/auth";
|
import { fetchAuthProviders } from "../data/auth";
|
||||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||||
@@ -133,25 +136,8 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
ha-language-picker {
|
.footer ha-svg-icon {
|
||||||
width: 200px;
|
--mdc-icon-size: var(--ha-space-5);
|
||||||
border-radius: var(--ha-border-radius-sm);
|
|
||||||
overflow: hidden;
|
|
||||||
--ha-select-height: 40px;
|
|
||||||
--mdc-select-fill-color: none;
|
|
||||||
--mdc-select-label-ink-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-select-ink-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-select-idle-line-color: transparent;
|
|
||||||
--mdc-select-hover-line-color: transparent;
|
|
||||||
--mdc-select-dropdown-icon-color: var(--primary-text-color, #212121);
|
|
||||||
--mdc-shape-small: 0;
|
|
||||||
}
|
|
||||||
.footer a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--primary-text-color);
|
|
||||||
margin-right: 16px;
|
|
||||||
margin-inline-end: 16px;
|
|
||||||
margin-inline-start: initial;
|
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: var(--ha-font-size-3xl);
|
font-size: var(--ha-font-size-3xl);
|
||||||
@@ -205,16 +191,21 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
<ha-language-picker
|
<ha-language-picker
|
||||||
.value=${this.language}
|
.value=${this.language}
|
||||||
.label=${""}
|
.label=${""}
|
||||||
|
button-style
|
||||||
native-name
|
native-name
|
||||||
@value-changed=${this._languageChanged}
|
@value-changed=${this._languageChanged}
|
||||||
inline-arrow
|
inline-arrow
|
||||||
></ha-language-picker>
|
></ha-language-picker>
|
||||||
<a
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
variant="neutral"
|
||||||
href="https://www.home-assistant.io/docs/authentication/"
|
href="https://www.home-assistant.io/docs/authentication/"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer noopener"
|
rel="noreferrer noopener"
|
||||||
>${this.localize("ui.panel.page-authorize.help")}</a
|
|
||||||
>
|
>
|
||||||
|
${this.localize("ui.panel.page-authorize.help")}
|
||||||
|
<ha-svg-icon slot="end" .path=${mdiOpenInNew}></ha-svg-icon>
|
||||||
|
</ha-button>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ type EntityCategory = "none" | "config" | "diagnostic";
|
|||||||
export interface EntityFilter {
|
export interface EntityFilter {
|
||||||
domain?: string | string[];
|
domain?: string | string[];
|
||||||
device_class?: string | string[];
|
device_class?: string | string[];
|
||||||
device?: string | string[];
|
device?: string | null | (string | null)[];
|
||||||
area?: string | string[];
|
area?: string | null | (string | null)[];
|
||||||
floor?: string | string[];
|
floor?: string | null | (string | null)[];
|
||||||
label?: string | string[];
|
label?: string | string[];
|
||||||
entity_category?: EntityCategory | EntityCategory[];
|
entity_category?: EntityCategory | EntityCategory[];
|
||||||
hidden_platform?: string | string[];
|
hidden_platform?: string | string[];
|
||||||
@@ -19,6 +19,18 @@ export interface EntityFilter {
|
|||||||
|
|
||||||
export type EntityFilterFunc = (entityId: string) => boolean;
|
export type EntityFilterFunc = (entityId: string) => boolean;
|
||||||
|
|
||||||
|
const normalizeFilterArray = <T>(
|
||||||
|
value: T | null | T[] | (T | null)[] | undefined
|
||||||
|
): Set<T | null> | undefined => {
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (value === null) {
|
||||||
|
return new Set([null]);
|
||||||
|
}
|
||||||
|
return new Set(ensureArray(value));
|
||||||
|
};
|
||||||
|
|
||||||
export const generateEntityFilter = (
|
export const generateEntityFilter = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
filter: EntityFilter
|
filter: EntityFilter
|
||||||
@@ -29,11 +41,9 @@ export const generateEntityFilter = (
|
|||||||
const deviceClasses = filter.device_class
|
const deviceClasses = filter.device_class
|
||||||
? new Set(ensureArray(filter.device_class))
|
? new Set(ensureArray(filter.device_class))
|
||||||
: undefined;
|
: undefined;
|
||||||
const floors = filter.floor ? new Set(ensureArray(filter.floor)) : undefined;
|
const floors = normalizeFilterArray(filter.floor);
|
||||||
const areas = filter.area ? new Set(ensureArray(filter.area)) : undefined;
|
const areas = normalizeFilterArray(filter.area);
|
||||||
const devices = filter.device
|
const devices = normalizeFilterArray(filter.device);
|
||||||
? new Set(ensureArray(filter.device))
|
|
||||||
: undefined;
|
|
||||||
const entityCategories = filter.entity_category
|
const entityCategories = filter.entity_category
|
||||||
? new Set(ensureArray(filter.entity_category))
|
? new Set(ensureArray(filter.entity_category))
|
||||||
: undefined;
|
: undefined;
|
||||||
@@ -73,23 +83,20 @@ export const generateEntityFilter = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (floors) {
|
if (floors) {
|
||||||
if (!floor || !floors.has(floor.floor_id)) {
|
const floorId = floor?.floor_id ?? null;
|
||||||
|
if (!floors.has(floorId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (areas) {
|
if (areas) {
|
||||||
if (!area) {
|
const areaId = area?.area_id ?? null;
|
||||||
return false;
|
if (!areas.has(areaId)) {
|
||||||
}
|
|
||||||
if (!areas.has(area.area_id)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (devices) {
|
if (devices) {
|
||||||
if (!device) {
|
const deviceId = device?.id ?? null;
|
||||||
return false;
|
if (!devices.has(deviceId)) {
|
||||||
}
|
|
||||||
if (!devices.has(device.id)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
|||||||
"pm1",
|
"pm1",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
|
"pm4",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"power",
|
"power",
|
||||||
"pressure",
|
"pressure",
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ export function downSampleLineData<
|
|||||||
data: T[] | undefined,
|
data: T[] | undefined,
|
||||||
maxDetails: number,
|
maxDetails: number,
|
||||||
minX?: number,
|
minX?: number,
|
||||||
maxX?: number
|
maxX?: number,
|
||||||
|
useMean = false
|
||||||
): T[] {
|
): T[] {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return [];
|
return [];
|
||||||
@@ -17,15 +18,13 @@ export function downSampleLineData<
|
|||||||
const min = minX ?? getPointData(data[0]!)[0];
|
const min = minX ?? getPointData(data[0]!)[0];
|
||||||
const max = maxX ?? getPointData(data[data.length - 1]!)[0];
|
const max = maxX ?? getPointData(data[data.length - 1]!)[0];
|
||||||
const step = Math.ceil((max - min) / Math.floor(maxDetails));
|
const step = Math.ceil((max - min) / Math.floor(maxDetails));
|
||||||
const frames = new Map<
|
|
||||||
number,
|
|
||||||
{
|
|
||||||
min: { point: (typeof data)[number]; x: number; y: number };
|
|
||||||
max: { point: (typeof data)[number]; x: number; y: number };
|
|
||||||
}
|
|
||||||
>();
|
|
||||||
|
|
||||||
// Group points into frames
|
// Group points into frames
|
||||||
|
const frames = new Map<
|
||||||
|
number,
|
||||||
|
{ point: (typeof data)[number]; x: number; y: number }[]
|
||||||
|
>();
|
||||||
|
|
||||||
for (const point of data) {
|
for (const point of data) {
|
||||||
const pointData = getPointData(point);
|
const pointData = getPointData(point);
|
||||||
if (!Array.isArray(pointData)) continue;
|
if (!Array.isArray(pointData)) continue;
|
||||||
@@ -36,28 +35,53 @@ export function downSampleLineData<
|
|||||||
const frameIndex = Math.floor((x - min) / step);
|
const frameIndex = Math.floor((x - min) / step);
|
||||||
const frame = frames.get(frameIndex);
|
const frame = frames.get(frameIndex);
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
frames.set(frameIndex, { min: { point, x, y }, max: { point, x, y } });
|
frames.set(frameIndex, [{ point, x, y }]);
|
||||||
} else {
|
} else {
|
||||||
if (frame.min.y > y) {
|
frame.push({ point, x, y });
|
||||||
frame.min = { point, x, y };
|
|
||||||
}
|
|
||||||
if (frame.max.y < y) {
|
|
||||||
frame.max = { point, x, y };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert frames back to points
|
// Convert frames back to points
|
||||||
const result: T[] = [];
|
const result: T[] = [];
|
||||||
for (const [_i, frame] of frames) {
|
|
||||||
// Use min/max points to preserve visual accuracy
|
if (useMean) {
|
||||||
// The order of the data must be preserved so max may be before min
|
// Use mean values for each frame
|
||||||
if (frame.min.x > frame.max.x) {
|
for (const [_i, framePoints] of frames) {
|
||||||
result.push(frame.max.point);
|
const sumY = framePoints.reduce((acc, p) => acc + p.y, 0);
|
||||||
|
const meanY = sumY / framePoints.length;
|
||||||
|
const sumX = framePoints.reduce((acc, p) => acc + p.x, 0);
|
||||||
|
const meanX = sumX / framePoints.length;
|
||||||
|
|
||||||
|
const firstPoint = framePoints[0].point;
|
||||||
|
const pointData = getPointData(firstPoint);
|
||||||
|
const meanPoint = (
|
||||||
|
Array.isArray(pointData) ? [meanX, meanY] : { value: [meanX, meanY] }
|
||||||
|
) as T;
|
||||||
|
result.push(meanPoint);
|
||||||
}
|
}
|
||||||
result.push(frame.min.point);
|
} else {
|
||||||
if (frame.min.x < frame.max.x) {
|
// Use min/max values for each frame
|
||||||
result.push(frame.max.point);
|
for (const [_i, framePoints] of frames) {
|
||||||
|
let minPoint = framePoints[0];
|
||||||
|
let maxPoint = framePoints[0];
|
||||||
|
|
||||||
|
for (const p of framePoints) {
|
||||||
|
if (p.y < minPoint.y) {
|
||||||
|
minPoint = p;
|
||||||
|
}
|
||||||
|
if (p.y > maxPoint.y) {
|
||||||
|
maxPoint = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The order of the data must be preserved so max may be before min
|
||||||
|
if (minPoint.x > maxPoint.x) {
|
||||||
|
result.push(maxPoint.point);
|
||||||
|
}
|
||||||
|
result.push(minPoint.point);
|
||||||
|
if (minPoint.x < maxPoint.x) {
|
||||||
|
result.push(maxPoint.point);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
|
|||||||
const LEGEND_OVERFLOW_LIMIT = 10;
|
const LEGEND_OVERFLOW_LIMIT = 10;
|
||||||
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
|
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
|
||||||
const DOUBLE_TAP_TIME = 300;
|
const DOUBLE_TAP_TIME = 300;
|
||||||
const RESIZE_ANIMATION_DURATION = 250;
|
|
||||||
|
|
||||||
export type CustomLegendOption = ECOption["legend"] & {
|
export type CustomLegendOption = ECOption["legend"] & {
|
||||||
type: "custom";
|
type: "custom";
|
||||||
@@ -91,6 +90,8 @@ export class HaChartBase extends LitElement {
|
|||||||
|
|
||||||
private _shouldResizeChart = false;
|
private _shouldResizeChart = false;
|
||||||
|
|
||||||
|
private _resizeAnimationDuration?: number;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
private _resizeController = new ResizeController(this, {
|
private _resizeController = new ResizeController(this, {
|
||||||
callback: () => {
|
callback: () => {
|
||||||
@@ -214,6 +215,7 @@ export class HaChartBase extends LitElement {
|
|||||||
) {
|
) {
|
||||||
// custom legend changes may require a resize to layout properly
|
// custom legend changes may require a resize to layout properly
|
||||||
this._shouldResizeChart = true;
|
this._shouldResizeChart = true;
|
||||||
|
this._resizeAnimationDuration = 250;
|
||||||
}
|
}
|
||||||
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
|
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
|
||||||
chartOptions.dataZoom = this._getDataZoomConfig();
|
chartOptions.dataZoom = this._getDataZoomConfig();
|
||||||
@@ -625,6 +627,10 @@ export class HaChartBase extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createTheme(style: CSSStyleDeclaration) {
|
private _createTheme(style: CSSStyleDeclaration) {
|
||||||
|
const textBorderColor =
|
||||||
|
style.getPropertyValue("--ha-card-background") ||
|
||||||
|
style.getPropertyValue("--card-background-color");
|
||||||
|
const textBorderWidth = 2;
|
||||||
return {
|
return {
|
||||||
color: getAllGraphColors(style),
|
color: getAllGraphColors(style),
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
@@ -648,15 +654,22 @@ export class HaChartBase extends LitElement {
|
|||||||
graph: {
|
graph: {
|
||||||
label: {
|
label: {
|
||||||
color: style.getPropertyValue("--primary-text-color"),
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
textBorderColor: style.getPropertyValue("--primary-background-color"),
|
textBorderColor,
|
||||||
textBorderWidth: 2,
|
textBorderWidth,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pie: {
|
||||||
|
label: {
|
||||||
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
|
textBorderColor,
|
||||||
|
textBorderWidth,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sankey: {
|
sankey: {
|
||||||
label: {
|
label: {
|
||||||
color: style.getPropertyValue("--primary-text-color"),
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
textBorderColor: style.getPropertyValue("--primary-background-color"),
|
textBorderColor,
|
||||||
textBorderWidth: 2,
|
textBorderWidth,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
categoryAxis: {
|
categoryAxis: {
|
||||||
@@ -970,11 +983,14 @@ export class HaChartBase extends LitElement {
|
|||||||
private _handleChartRenderFinished = () => {
|
private _handleChartRenderFinished = () => {
|
||||||
if (this._shouldResizeChart) {
|
if (this._shouldResizeChart) {
|
||||||
this.chart?.resize({
|
this.chart?.resize({
|
||||||
animation: this._reducedMotion
|
animation:
|
||||||
? undefined
|
this._reducedMotion ||
|
||||||
: { duration: RESIZE_ANIMATION_DURATION },
|
typeof this._resizeAnimationDuration !== "number"
|
||||||
|
? undefined
|
||||||
|
: { duration: this._resizeAnimationDuration },
|
||||||
});
|
});
|
||||||
this._shouldResizeChart = false;
|
this._shouldResizeChart = false;
|
||||||
|
this._resizeAnimationDuration = undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
private _previousYAxisLabelValue = 0;
|
private _previousYAxisLabelValue = 0;
|
||||||
|
|
||||||
|
private _yAxisMaximumFractionDigits = 0;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
@@ -757,8 +759,12 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
this._yAxisMaximumFractionDigits = Math.max(
|
||||||
|
this._yAxisMaximumFractionDigits,
|
||||||
|
maximumFractionDigits
|
||||||
|
);
|
||||||
const label = formatNumber(value, this.hass.locale, {
|
const label = formatNumber(value, this.hass.locale, {
|
||||||
maximumFractionDigits,
|
maximumFractionDigits: this._yAxisMaximumFractionDigits,
|
||||||
});
|
});
|
||||||
const width = measureTextWidth(label, 12) + 5;
|
const width = measureTextWidth(label, 12) + 5;
|
||||||
if (width > this._yWidth) {
|
if (width > this._yWidth) {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class HaEntitiesPicker extends LitElement {
|
|||||||
.createDomains=${this.createDomains}
|
.createDomains=${this.createDomains}
|
||||||
.required=${this.required && !currentEntities.length}
|
.required=${this.required && !currentEntities.length}
|
||||||
@value-changed=${this._addEntity}
|
@value-changed=${this._addEntity}
|
||||||
add-button
|
.addButton=${currentEntities.length > 0}
|
||||||
></ha-entity-picker>
|
></ha-entity-picker>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ export class HaAreaPicker extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public required = false;
|
@property({ type: Boolean }) public required = false;
|
||||||
|
|
||||||
|
@property({ attribute: "add-button-label" }) public addButtonLabel?: string;
|
||||||
|
|
||||||
@query("ha-generic-picker") private _picker?: HaGenericPicker;
|
@query("ha-generic-picker") private _picker?: HaGenericPicker;
|
||||||
|
|
||||||
public async open() {
|
public async open() {
|
||||||
@@ -375,6 +377,7 @@ export class HaAreaPicker extends LitElement {
|
|||||||
.getItems=${this._getItems}
|
.getItems=${this._getItems}
|
||||||
.getAdditionalItems=${this._getAdditionalItems}
|
.getAdditionalItems=${this._getAdditionalItems}
|
||||||
.valueRenderer=${valueRenderer}
|
.valueRenderer=${valueRenderer}
|
||||||
|
.addButtonLabel=${this.addButtonLabel}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
>
|
>
|
||||||
</ha-generic-picker>
|
</ha-generic-picker>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export class HaButton extends Button {
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|
||||||
transition: background-color 0.15s ease-in-out;
|
transition: background-color 0.15s ease-in-out;
|
||||||
|
text-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([size="small"]) .button {
|
:host([size="small"]) .button {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
.value=${getValue(this.data, item)}
|
.value=${getValue(this.data, item)}
|
||||||
.label=${this._computeLabel(item, this.data)}
|
.label=${this._computeLabel(item, this.data)}
|
||||||
.disabled=${item.disabled || this.disabled || false}
|
.disabled=${item.disabled || this.disabled || false}
|
||||||
.placeholder=${item.required ? "" : item.default}
|
.placeholder=${item.required ? undefined : item.default}
|
||||||
.helper=${this._computeHelper(item)}
|
.helper=${this._computeHelper(item)}
|
||||||
.localizeValue=${this.localizeValue}
|
.localizeValue=${this.localizeValue}
|
||||||
.required=${item.required || false}
|
.required=${item.required || false}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import type { HomeAssistant } from "../types";
|
|||||||
import "./ha-bottom-sheet";
|
import "./ha-bottom-sheet";
|
||||||
import "./ha-button";
|
import "./ha-button";
|
||||||
import "./ha-combo-box-item";
|
import "./ha-combo-box-item";
|
||||||
import "./ha-icon-button";
|
|
||||||
import "./ha-input-helper-text";
|
import "./ha-input-helper-text";
|
||||||
import "./ha-picker-combo-box";
|
import "./ha-picker-combo-box";
|
||||||
import type {
|
import type {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { mdiMenuDown } from "@mdi/js";
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { formatLanguageCode } from "../common/language/format_language";
|
import { formatLanguageCode } from "../common/language/format_language";
|
||||||
@@ -8,10 +9,10 @@ import { caseInsensitiveStringCompare } from "../common/string/compare";
|
|||||||
import type { FrontendLocaleData } from "../data/translation";
|
import type { FrontendLocaleData } from "../data/translation";
|
||||||
import { translationMetadata } from "../resources/translations-metadata";
|
import { translationMetadata } from "../resources/translations-metadata";
|
||||||
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
||||||
|
import "./ha-button";
|
||||||
import "./ha-generic-picker";
|
import "./ha-generic-picker";
|
||||||
import "./ha-list-item";
|
import type { HaGenericPicker } from "./ha-generic-picker";
|
||||||
import type { PickerComboBoxItem } from "./ha-picker-combo-box";
|
import type { PickerComboBoxItem } from "./ha-picker-combo-box";
|
||||||
import "./ha-select";
|
|
||||||
|
|
||||||
export const getLanguageOptions = (
|
export const getLanguageOptions = (
|
||||||
languages: string[],
|
languages: string[],
|
||||||
@@ -75,6 +76,9 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
@property({ attribute: "native-name", type: Boolean })
|
@property({ attribute: "native-name", type: Boolean })
|
||||||
public nativeName = false;
|
public nativeName = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: "button-style" })
|
||||||
|
public buttonStyle = false;
|
||||||
|
|
||||||
@property({ attribute: "no-sort", type: Boolean }) public noSort = false;
|
@property({ attribute: "no-sort", type: Boolean }) public noSort = false;
|
||||||
|
|
||||||
@property({ attribute: "inline-arrow", type: Boolean })
|
@property({ attribute: "inline-arrow", type: Boolean })
|
||||||
@@ -82,6 +86,8 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
|
|
||||||
@state() _defaultLanguages: string[] = [];
|
@state() _defaultLanguages: string[] = [];
|
||||||
|
|
||||||
|
@query("ha-generic-picker", true) public genericPicker!: HaGenericPicker;
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
this._computeDefaultLanguageOptions();
|
this._computeDefaultLanguageOptions();
|
||||||
@@ -101,12 +107,13 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
this.hass?.locale
|
this.hass?.locale
|
||||||
);
|
);
|
||||||
|
|
||||||
private _valueRenderer = (value) => {
|
private _getLanguageName = (lang?: string) =>
|
||||||
const language = this._getItems().find(
|
this._getItems().find((language) => language.id === lang)?.primary;
|
||||||
(lang) => lang.id === value
|
|
||||||
)?.primary;
|
private _valueRenderer = (value) =>
|
||||||
return html`<span slot="headline">${language ?? value}</span> `;
|
html`<span slot="headline"
|
||||||
};
|
>${this._getLanguageName(value) ?? value}</span
|
||||||
|
> `;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
const value =
|
const value =
|
||||||
@@ -130,10 +137,28 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
.getItems=${this._getItems}
|
.getItems=${this._getItems}
|
||||||
@value-changed=${this._changed}
|
@value-changed=${this._changed}
|
||||||
hide-clear-icon
|
hide-clear-icon
|
||||||
></ha-generic-picker>
|
>
|
||||||
|
${this.buttonStyle
|
||||||
|
? html`<ha-button
|
||||||
|
slot="field"
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
@click=${this._openPicker}
|
||||||
|
appearance="plain"
|
||||||
|
variant="neutral"
|
||||||
|
>
|
||||||
|
${this._getLanguageName(value)}
|
||||||
|
<ha-svg-icon slot="end" .path=${mdiMenuDown}></ha-svg-icon>
|
||||||
|
</ha-button>`
|
||||||
|
: nothing}
|
||||||
|
</ha-generic-picker>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _openPicker(ev: Event) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
this.genericPicker.open();
|
||||||
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
ha-generic-picker {
|
ha-generic-picker {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { ListItemEl } from "@material/web/list/internal/listitem/list-item";
|
import { ListItemEl } from "@material/web/list/internal/listitem/list-item";
|
||||||
import { styles } from "@material/web/list/internal/listitem/list-item-styles";
|
import { styles } from "@material/web/list/internal/listitem/list-item-styles";
|
||||||
import { css } from "lit";
|
import { css, html, nothing, type TemplateResult } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
import "./ha-ripple";
|
||||||
|
|
||||||
export const haMdListStyles = [
|
export const haMdListStyles = [
|
||||||
styles,
|
styles,
|
||||||
@@ -25,6 +26,18 @@ export const haMdListStyles = [
|
|||||||
@customElement("ha-md-list-item")
|
@customElement("ha-md-list-item")
|
||||||
export class HaMdListItem extends ListItemEl {
|
export class HaMdListItem extends ListItemEl {
|
||||||
static override styles = haMdListStyles;
|
static override styles = haMdListStyles;
|
||||||
|
|
||||||
|
protected renderRipple(): TemplateResult | typeof nothing {
|
||||||
|
if (this.type === "text") {
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`<ha-ripple
|
||||||
|
part="ripple"
|
||||||
|
for="item"
|
||||||
|
?disabled=${this.disabled && this.type !== "link"}
|
||||||
|
></ha-ripple>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -87,166 +87,208 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (this.addOnTop) {
|
if (this.addOnTop) {
|
||||||
return html` ${this._renderChips()} ${this._renderItems()} `;
|
return html` ${this._renderPicker()} ${this._renderItems()} `;
|
||||||
}
|
}
|
||||||
return html` ${this._renderItems()} ${this._renderChips()} `;
|
return html` ${this._renderItems()} ${this._renderPicker()} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderValueChips() {
|
private _renderValueChips() {
|
||||||
return html`<div class="mdc-chip-set items">
|
const entityIds = this.value?.entity_id
|
||||||
${this.value?.floor_id
|
? ensureArray(this.value.entity_id)
|
||||||
? ensureArray(this.value.floor_id).map(
|
: [];
|
||||||
(floor_id) => html`
|
const deviceIds = this.value?.device_id
|
||||||
<ha-target-picker-value-chip
|
? ensureArray(this.value.device_id)
|
||||||
.hass=${this.hass}
|
: [];
|
||||||
type="floor"
|
const areaIds = this.value?.area_id ? ensureArray(this.value.area_id) : [];
|
||||||
.itemId=${floor_id}
|
const floorIds = this.value?.floor_id
|
||||||
@remove-target-item=${this._handleRemove}
|
? ensureArray(this.value.floor_id)
|
||||||
@expand-target-item=${this._handleExpand}
|
: [];
|
||||||
></ha-target-picker-value-chip>
|
const labelIds = this.value?.label_id
|
||||||
`
|
? ensureArray(this.value.label_id)
|
||||||
)
|
: [];
|
||||||
: nothing}
|
|
||||||
${this.value?.area_id
|
|
||||||
? ensureArray(this.value.area_id).map(
|
|
||||||
(area_id) => html`
|
|
||||||
<ha-target-picker-value-chip
|
|
||||||
.hass=${this.hass}
|
|
||||||
type="area"
|
|
||||||
.itemId=${area_id}
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
@expand-target-item=${this._handleExpand}
|
|
||||||
></ha-target-picker-value-chip>
|
|
||||||
`
|
|
||||||
)
|
|
||||||
: nothing}
|
|
||||||
${this.value?.device_id
|
|
||||||
? ensureArray(this.value.device_id).map(
|
|
||||||
(device_id) => html`
|
|
||||||
<ha-target-picker-value-chip
|
|
||||||
.hass=${this.hass}
|
|
||||||
type="device"
|
|
||||||
.itemId=${device_id}
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
@expand-target-item=${this._handleExpand}
|
|
||||||
></ha-target-picker-value-chip>
|
|
||||||
`
|
|
||||||
)
|
|
||||||
: nothing}
|
|
||||||
${this.value?.entity_id
|
|
||||||
? ensureArray(this.value.entity_id).map(
|
|
||||||
(entity_id) => html`
|
|
||||||
<ha-target-picker-value-chip
|
|
||||||
.hass=${this.hass}
|
|
||||||
type="entity"
|
|
||||||
.itemId=${entity_id}
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
@expand-target-item=${this._handleExpand}
|
|
||||||
></ha-target-picker-value-chip>
|
|
||||||
`
|
|
||||||
)
|
|
||||||
: nothing}
|
|
||||||
${this.value?.label_id
|
|
||||||
? ensureArray(this.value.label_id).map(
|
|
||||||
(label_id) => html`
|
|
||||||
<ha-target-picker-value-chip
|
|
||||||
.hass=${this.hass}
|
|
||||||
type="label"
|
|
||||||
.itemId=${label_id}
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
@expand-target-item=${this._handleExpand}
|
|
||||||
></ha-target-picker-value-chip>
|
|
||||||
`
|
|
||||||
)
|
|
||||||
: nothing}
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _renderValueGroups() {
|
|
||||||
return html`<div class="item-groups">
|
|
||||||
${this.value?.entity_id
|
|
||||||
? html`
|
|
||||||
<ha-target-picker-item-group
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
type="entity"
|
|
||||||
.hass=${this.hass}
|
|
||||||
.items=${{ entity: ensureArray(this.value?.entity_id) }}
|
|
||||||
.deviceFilter=${this.deviceFilter}
|
|
||||||
.entityFilter=${this.entityFilter}
|
|
||||||
.includeDomains=${this.includeDomains}
|
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
|
||||||
>
|
|
||||||
</ha-target-picker-item-group>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
${this.value?.device_id
|
|
||||||
? html`
|
|
||||||
<ha-target-picker-item-group
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
type="device"
|
|
||||||
.hass=${this.hass}
|
|
||||||
.items=${{ device: ensureArray(this.value?.device_id) }}
|
|
||||||
.deviceFilter=${this.deviceFilter}
|
|
||||||
.entityFilter=${this.entityFilter}
|
|
||||||
.includeDomains=${this.includeDomains}
|
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
|
||||||
>
|
|
||||||
</ha-target-picker-item-group>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
${this.value?.floor_id || this.value?.area_id
|
|
||||||
? html`
|
|
||||||
<ha-target-picker-item-group
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
type="area"
|
|
||||||
.hass=${this.hass}
|
|
||||||
.items=${{
|
|
||||||
floor: ensureArray(this.value?.floor_id),
|
|
||||||
area: ensureArray(this.value?.area_id),
|
|
||||||
}}
|
|
||||||
.deviceFilter=${this.deviceFilter}
|
|
||||||
.entityFilter=${this.entityFilter}
|
|
||||||
.includeDomains=${this.includeDomains}
|
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
|
||||||
>
|
|
||||||
</ha-target-picker-item-group>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
${this.value?.label_id
|
|
||||||
? html`
|
|
||||||
<ha-target-picker-item-group
|
|
||||||
@remove-target-item=${this._handleRemove}
|
|
||||||
type="label"
|
|
||||||
.hass=${this.hass}
|
|
||||||
.items=${{ label: ensureArray(this.value?.label_id) }}
|
|
||||||
.deviceFilter=${this.deviceFilter}
|
|
||||||
.entityFilter=${this.entityFilter}
|
|
||||||
.includeDomains=${this.includeDomains}
|
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
|
||||||
>
|
|
||||||
</ha-target-picker-item-group>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _renderItems() {
|
|
||||||
if (
|
if (
|
||||||
!this.value?.floor_id &&
|
!entityIds.length &&
|
||||||
!this.value?.area_id &&
|
!deviceIds.length &&
|
||||||
!this.value?.device_id &&
|
!areaIds.length &&
|
||||||
!this.value?.entity_id &&
|
!floorIds.length &&
|
||||||
!this.value?.label_id
|
!labelIds.length
|
||||||
) {
|
) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div class="mdc-chip-set items">
|
||||||
|
${floorIds.length
|
||||||
|
? floorIds.map(
|
||||||
|
(floor_id) => html`
|
||||||
|
<ha-target-picker-value-chip
|
||||||
|
.hass=${this.hass}
|
||||||
|
type="floor"
|
||||||
|
.itemId=${floor_id}
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
@expand-target-item=${this._handleExpand}
|
||||||
|
></ha-target-picker-value-chip>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
${areaIds.length
|
||||||
|
? areaIds.map(
|
||||||
|
(area_id) => html`
|
||||||
|
<ha-target-picker-value-chip
|
||||||
|
.hass=${this.hass}
|
||||||
|
type="area"
|
||||||
|
.itemId=${area_id}
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
@expand-target-item=${this._handleExpand}
|
||||||
|
></ha-target-picker-value-chip>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
${deviceIds.length
|
||||||
|
? deviceIds.map(
|
||||||
|
(device_id) => html`
|
||||||
|
<ha-target-picker-value-chip
|
||||||
|
.hass=${this.hass}
|
||||||
|
type="device"
|
||||||
|
.itemId=${device_id}
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
@expand-target-item=${this._handleExpand}
|
||||||
|
></ha-target-picker-value-chip>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
${entityIds.length
|
||||||
|
? entityIds.map(
|
||||||
|
(entity_id) => html`
|
||||||
|
<ha-target-picker-value-chip
|
||||||
|
.hass=${this.hass}
|
||||||
|
type="entity"
|
||||||
|
.itemId=${entity_id}
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
@expand-target-item=${this._handleExpand}
|
||||||
|
></ha-target-picker-value-chip>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
${labelIds.length
|
||||||
|
? labelIds.map(
|
||||||
|
(label_id) => html`
|
||||||
|
<ha-target-picker-value-chip
|
||||||
|
.hass=${this.hass}
|
||||||
|
type="label"
|
||||||
|
.itemId=${label_id}
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
@expand-target-item=${this._handleExpand}
|
||||||
|
></ha-target-picker-value-chip>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _renderValueGroups() {
|
||||||
|
const entityIds = this.value?.entity_id
|
||||||
|
? ensureArray(this.value.entity_id)
|
||||||
|
: [];
|
||||||
|
const deviceIds = this.value?.device_id
|
||||||
|
? ensureArray(this.value.device_id)
|
||||||
|
: [];
|
||||||
|
const areaIds = this.value?.area_id ? ensureArray(this.value.area_id) : [];
|
||||||
|
const floorIds = this.value?.floor_id
|
||||||
|
? ensureArray(this.value.floor_id)
|
||||||
|
: [];
|
||||||
|
const labelIds = this.value?.label_id
|
||||||
|
? ensureArray(this.value?.label_id)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (
|
||||||
|
!entityIds.length &&
|
||||||
|
!deviceIds.length &&
|
||||||
|
!areaIds.length &&
|
||||||
|
!floorIds.length &&
|
||||||
|
!labelIds.length
|
||||||
|
) {
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div class="item-groups">
|
||||||
|
${entityIds.length
|
||||||
|
? html`
|
||||||
|
<ha-target-picker-item-group
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
type="entity"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.items=${{ entity: entityIds }}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
|
.includeDomains=${this.includeDomains}
|
||||||
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
|
>
|
||||||
|
</ha-target-picker-item-group>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
${deviceIds.length
|
||||||
|
? html`
|
||||||
|
<ha-target-picker-item-group
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
type="device"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.items=${{ device: deviceIds }}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
|
.includeDomains=${this.includeDomains}
|
||||||
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
|
>
|
||||||
|
</ha-target-picker-item-group>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
${floorIds.length || areaIds.length
|
||||||
|
? html`
|
||||||
|
<ha-target-picker-item-group
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
type="area"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.items=${{
|
||||||
|
floor: floorIds,
|
||||||
|
area: areaIds,
|
||||||
|
}}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
|
.includeDomains=${this.includeDomains}
|
||||||
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
|
>
|
||||||
|
</ha-target-picker-item-group>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
${labelIds.length
|
||||||
|
? html`
|
||||||
|
<ha-target-picker-item-group
|
||||||
|
@remove-target-item=${this._handleRemove}
|
||||||
|
type="label"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.items=${{ label: labelIds }}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
|
.includeDomains=${this.includeDomains}
|
||||||
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
|
>
|
||||||
|
</ha-target-picker-item-group>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _renderItems() {
|
||||||
return html`
|
return html`
|
||||||
${this.compact ? this._renderValueChips() : this._renderValueGroups()}
|
${this.compact ? this._renderValueChips() : this._renderValueGroups()}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderChips() {
|
private _renderPicker() {
|
||||||
return html`
|
return html`
|
||||||
<div class="add-target-wrapper">
|
<div class="add-target-wrapper">
|
||||||
<ha-button
|
<ha-button
|
||||||
@@ -347,7 +389,8 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._pickerFilter = filter;
|
this._pickerFilter = filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _hidePicker() {
|
private _hidePicker(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
this._open = false;
|
this._open = false;
|
||||||
this._pickerWrapperOpen = false;
|
this._pickerWrapperOpen = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export class HaTooltip extends Tooltip {
|
|||||||
@property({ attribute: "show-delay", type: Number }) showDelay = 150;
|
@property({ attribute: "show-delay", type: Number }) showDelay = 150;
|
||||||
|
|
||||||
/** The amount of time to wait before hiding the tooltip when the user mouses out.. */
|
/** The amount of time to wait before hiding the tooltip when the user mouses out.. */
|
||||||
@property({ attribute: "hide-delay", type: Number }) hideDelay = 400;
|
@property({ attribute: "hide-delay", type: Number }) hideDelay = 150;
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
mdiLabel,
|
mdiLabel,
|
||||||
mdiTextureBox,
|
mdiTextureBox,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { css, html, LitElement, nothing, type PropertyValues } from "lit";
|
import { css, html, LitElement, nothing, type PropertyValues } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@@ -19,9 +20,12 @@ import { computeDomain } from "../../common/entity/compute_domain";
|
|||||||
import { computeEntityName } from "../../common/entity/compute_entity_name";
|
import { computeEntityName } from "../../common/entity/compute_entity_name";
|
||||||
import { getEntityContext } from "../../common/entity/context/get_entity_context";
|
import { getEntityContext } from "../../common/entity/context/get_entity_context";
|
||||||
import { computeRTL } from "../../common/util/compute_rtl";
|
import { computeRTL } from "../../common/util/compute_rtl";
|
||||||
|
import type { AreaRegistryEntry } from "../../data/area_registry";
|
||||||
import { getConfigEntry } from "../../data/config_entries";
|
import { getConfigEntry } from "../../data/config_entries";
|
||||||
import { labelsContext } from "../../data/context";
|
import { labelsContext } from "../../data/context";
|
||||||
|
import type { DeviceRegistryEntry } from "../../data/device_registry";
|
||||||
import type { HaEntityPickerEntityFilterFunc } from "../../data/entity";
|
import type { HaEntityPickerEntityFilterFunc } from "../../data/entity";
|
||||||
|
import type { FloorRegistryEntry } from "../../data/floor_registry";
|
||||||
import { domainToName } from "../../data/integration";
|
import { domainToName } from "../../data/integration";
|
||||||
import type { LabelRegistryEntry } from "../../data/label_registry";
|
import type { LabelRegistryEntry } from "../../data/label_registry";
|
||||||
import {
|
import {
|
||||||
@@ -111,10 +115,10 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
const { name, context, iconPath, fallbackIconPath, stateObject } =
|
const { name, context, iconPath, fallbackIconPath, stateObject, notFound } =
|
||||||
this._itemData(this.type, this.itemId);
|
this._itemData(this.type, this.itemId);
|
||||||
|
|
||||||
const showEntities = this.type !== "entity";
|
const showEntities = this.type !== "entity" && !notFound;
|
||||||
|
|
||||||
const entries = this.parentEntries || this._entries;
|
const entries = this.parentEntries || this._entries;
|
||||||
|
|
||||||
@@ -128,7 +132,7 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-md-list-item type="text">
|
<ha-md-list-item type="text" class=${notFound ? "error" : ""}>
|
||||||
<div class="icon" slot="start">
|
<div class="icon" slot="start">
|
||||||
${this.subEntry
|
${this.subEntry
|
||||||
? html`
|
? html`
|
||||||
@@ -148,11 +152,15 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
/>`
|
/>`
|
||||||
: fallbackIconPath
|
: fallbackIconPath
|
||||||
? html`<ha-svg-icon .path=${fallbackIconPath}></ha-svg-icon>`
|
? html`<ha-svg-icon .path=${fallbackIconPath}></ha-svg-icon>`
|
||||||
: stateObject
|
: this.type === "entity"
|
||||||
? html`
|
? html`
|
||||||
<ha-state-icon
|
<ha-state-icon
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.stateObj=${stateObject}
|
.stateObj=${stateObject ||
|
||||||
|
({
|
||||||
|
entity_id: this.itemId,
|
||||||
|
attributes: {},
|
||||||
|
} as HassEntity)}
|
||||||
>
|
>
|
||||||
</ha-state-icon>
|
</ha-state-icon>
|
||||||
`
|
`
|
||||||
@@ -160,8 +168,14 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="headline">${name}</div>
|
<div slot="headline">${name}</div>
|
||||||
${context && !this.hideContext
|
${notFound || (context && !this.hideContext)
|
||||||
? html`<span slot="supporting-text">${context}</span>`
|
? html`<span slot="supporting-text"
|
||||||
|
>${notFound
|
||||||
|
? this.hass.localize(
|
||||||
|
`ui.components.target-picker.${this.type}_not_found`
|
||||||
|
)
|
||||||
|
: context}</span
|
||||||
|
>`
|
||||||
: nothing}
|
: nothing}
|
||||||
${this._domainName && this.subEntry
|
${this._domainName && this.subEntry
|
||||||
? html`<span slot="supporting-text" class="domain"
|
? html`<span slot="supporting-text" class="domain"
|
||||||
@@ -474,26 +488,28 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
|
|
||||||
private _itemData = memoizeOne((type: TargetType, item: string) => {
|
private _itemData = memoizeOne((type: TargetType, item: string) => {
|
||||||
if (type === "floor") {
|
if (type === "floor") {
|
||||||
const floor = this.hass.floors?.[item];
|
const floor: FloorRegistryEntry | undefined = this.hass.floors?.[item];
|
||||||
return {
|
return {
|
||||||
name: floor?.name || item,
|
name: floor?.name || item,
|
||||||
iconPath: floor?.icon,
|
iconPath: floor?.icon,
|
||||||
fallbackIconPath: floor ? floorDefaultIconPath(floor) : mdiHome,
|
fallbackIconPath: floor ? floorDefaultIconPath(floor) : mdiHome,
|
||||||
|
notFound: !floor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type === "area") {
|
if (type === "area") {
|
||||||
const area = this.hass.areas?.[item];
|
const area: AreaRegistryEntry | undefined = this.hass.areas?.[item];
|
||||||
return {
|
return {
|
||||||
name: area?.name || item,
|
name: area?.name || item,
|
||||||
context: area.floor_id && this.hass.floors?.[area.floor_id]?.name,
|
context: area?.floor_id && this.hass.floors?.[area.floor_id]?.name,
|
||||||
iconPath: area?.icon,
|
iconPath: area?.icon,
|
||||||
fallbackIconPath: mdiTextureBox,
|
fallbackIconPath: mdiTextureBox,
|
||||||
|
notFound: !area,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type === "device") {
|
if (type === "device") {
|
||||||
const device = this.hass.devices?.[item];
|
const device: DeviceRegistryEntry | undefined = this.hass.devices?.[item];
|
||||||
|
|
||||||
if (device.primary_config_entry) {
|
if (device?.primary_config_entry) {
|
||||||
this._getDeviceDomain(device.primary_config_entry);
|
this._getDeviceDomain(device.primary_config_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,24 +517,25 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
name: device ? computeDeviceNameDisplay(device, this.hass) : item,
|
name: device ? computeDeviceNameDisplay(device, this.hass) : item,
|
||||||
context: device?.area_id && this.hass.areas?.[device.area_id]?.name,
|
context: device?.area_id && this.hass.areas?.[device.area_id]?.name,
|
||||||
fallbackIconPath: mdiDevices,
|
fallbackIconPath: mdiDevices,
|
||||||
|
notFound: !device,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type === "entity") {
|
if (type === "entity") {
|
||||||
this._setDomainName(computeDomain(item));
|
this._setDomainName(computeDomain(item));
|
||||||
|
|
||||||
const stateObject = this.hass.states[item];
|
const stateObject: HassEntity | undefined = this.hass.states[item];
|
||||||
const entityName = computeEntityName(
|
const entityName = stateObject
|
||||||
stateObject,
|
? computeEntityName(stateObject, this.hass.entities, this.hass.devices)
|
||||||
this.hass.entities,
|
: item;
|
||||||
this.hass.devices
|
const { area, device } = stateObject
|
||||||
);
|
? getEntityContext(
|
||||||
const { area, device } = getEntityContext(
|
stateObject,
|
||||||
stateObject,
|
this.hass.entities,
|
||||||
this.hass.entities,
|
this.hass.devices,
|
||||||
this.hass.devices,
|
this.hass.areas,
|
||||||
this.hass.areas,
|
this.hass.floors
|
||||||
this.hass.floors
|
)
|
||||||
);
|
: { area: undefined, device: undefined };
|
||||||
const deviceName = device ? computeDeviceName(device) : undefined;
|
const deviceName = device ? computeDeviceName(device) : undefined;
|
||||||
const areaName = area ? computeAreaName(area) : undefined;
|
const areaName = area ? computeAreaName(area) : undefined;
|
||||||
const context = [areaName, entityName ? deviceName : undefined]
|
const context = [areaName, entityName ? deviceName : undefined]
|
||||||
@@ -528,15 +545,19 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
name: entityName || deviceName || item,
|
name: entityName || deviceName || item,
|
||||||
context,
|
context,
|
||||||
stateObject,
|
stateObject,
|
||||||
|
notFound: !stateObject && item !== "all" && item !== "none",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// type label
|
// type label
|
||||||
const label = this._labelRegistry.find((lab) => lab.label_id === item);
|
const label: LabelRegistryEntry | undefined = this._labelRegistry.find(
|
||||||
|
(lab) => lab.label_id === item
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
name: label?.name || item,
|
name: label?.name || item,
|
||||||
iconPath: label?.icon,
|
iconPath: label?.icon,
|
||||||
fallbackIconPath: mdiLabel,
|
fallbackIconPath: mdiLabel,
|
||||||
|
notFound: !label,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -597,17 +618,27 @@ export class HaTargetPickerItemRow extends LitElement {
|
|||||||
border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg));
|
border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
background: var(--ha-color-fill-warning-quiet-resting);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error [slot="supporting-text"] {
|
||||||
|
color: var(--ha-color-on-warning-normal);
|
||||||
|
}
|
||||||
|
|
||||||
state-badge {
|
state-badge {
|
||||||
color: var(--ha-color-on-neutral-quiet);
|
color: var(--ha-color-on-neutral-quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
|
width: 24px;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
ha-icon-button {
|
ha-icon-button {
|
||||||
--mdc-icon-button-size: 32px;
|
--mdc-icon-button-size: 32px;
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ export class HaTargetPickerSelector extends LitElement {
|
|||||||
) as EntityComboBoxItem[];
|
) as EntityComboBoxItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filterType) {
|
if (!filterType && entities.length) {
|
||||||
// show group title
|
// show group title
|
||||||
items.push(
|
items.push(
|
||||||
this.hass.localize("ui.components.target-picker.type.entities")
|
this.hass.localize("ui.components.target-picker.type.entities")
|
||||||
@@ -733,7 +733,7 @@ export class HaTargetPickerSelector extends LitElement {
|
|||||||
devices = this._filterGroup("device", devices);
|
devices = this._filterGroup("device", devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filterType) {
|
if (!filterType && devices.length) {
|
||||||
// show group title
|
// show group title
|
||||||
items.push(
|
items.push(
|
||||||
this.hass.localize("ui.components.target-picker.type.devices")
|
this.hass.localize("ui.components.target-picker.type.devices")
|
||||||
@@ -769,7 +769,7 @@ export class HaTargetPickerSelector extends LitElement {
|
|||||||
) as FloorComboBoxItem[];
|
) as FloorComboBoxItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filterType) {
|
if (!filterType && areasAndFloors.length) {
|
||||||
// show group title
|
// show group title
|
||||||
items.push(
|
items.push(
|
||||||
this.hass.localize("ui.components.target-picker.type.areas")
|
this.hass.localize("ui.components.target-picker.type.areas")
|
||||||
@@ -811,7 +811,7 @@ export class HaTargetPickerSelector extends LitElement {
|
|||||||
labels = this._filterGroup("label", labels);
|
labels = this._filterGroup("label", labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filterType) {
|
if (!filterType && labels.length) {
|
||||||
// show group title
|
// show group title
|
||||||
items.push(
|
items.push(
|
||||||
this.hass.localize("ui.components.target-picker.type.labels")
|
this.hass.localize("ui.components.target-picker.type.labels")
|
||||||
|
|||||||
@@ -16,14 +16,10 @@ import memoizeOne from "memoize-one";
|
|||||||
import { computeCssColor } from "../../common/color/compute-color";
|
import { computeCssColor } from "../../common/color/compute-color";
|
||||||
import { hex2rgb } from "../../common/color/convert-color";
|
import { hex2rgb } from "../../common/color/convert-color";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { slugify } from "../../common/string/slugify";
|
import { computeDeviceNameDisplay } from "../../common/entity/compute_device_name";
|
||||||
import {
|
|
||||||
computeDeviceName,
|
|
||||||
computeDeviceNameDisplay,
|
|
||||||
} from "../../common/entity/compute_device_name";
|
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import { computeEntityName } from "../../common/entity/compute_entity_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
import { getEntityContext } from "../../common/entity/context/get_entity_context";
|
import { slugify } from "../../common/string/slugify";
|
||||||
import { getConfigEntry } from "../../data/config_entries";
|
import { getConfigEntry } from "../../data/config_entries";
|
||||||
import { labelsContext } from "../../data/context";
|
import { labelsContext } from "../../data/context";
|
||||||
import { domainToName } from "../../data/integration";
|
import { domainToName } from "../../data/integration";
|
||||||
@@ -172,23 +168,10 @@ export class HaTargetPickerValueChip extends LitElement {
|
|||||||
if (type === "entity") {
|
if (type === "entity") {
|
||||||
this._setDomainName(computeDomain(itemId));
|
this._setDomainName(computeDomain(itemId));
|
||||||
|
|
||||||
const stateObject = this.hass.states[itemId];
|
const stateObj = this.hass.states[itemId];
|
||||||
const entityName = computeEntityName(
|
|
||||||
stateObject,
|
|
||||||
this.hass.entities,
|
|
||||||
this.hass.devices
|
|
||||||
);
|
|
||||||
const { device } = getEntityContext(
|
|
||||||
stateObject,
|
|
||||||
this.hass.entities,
|
|
||||||
this.hass.devices,
|
|
||||||
this.hass.areas,
|
|
||||||
this.hass.floors
|
|
||||||
);
|
|
||||||
const deviceName = device ? computeDeviceName(device) : undefined;
|
|
||||||
return {
|
return {
|
||||||
name: entityName || deviceName || itemId,
|
name: computeStateName(stateObj) || itemId,
|
||||||
stateObject,
|
stateObject: stateObj,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||||
|
import { atLeastVersion } from "../common/config/version";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
|
||||||
export interface LogProvider {
|
export interface LogProvider {
|
||||||
@@ -8,4 +10,8 @@ export interface LogProvider {
|
|||||||
export const fetchErrorLog = (hass: HomeAssistant) =>
|
export const fetchErrorLog = (hass: HomeAssistant) =>
|
||||||
hass.callApi<string>("GET", "error_log");
|
hass.callApi<string>("GET", "error_log");
|
||||||
|
|
||||||
export const getErrorLogDownloadUrl = "/api/error_log";
|
export const getErrorLogDownloadUrl = (hass: HomeAssistant) =>
|
||||||
|
isComponentLoaded(hass, "hassio") &&
|
||||||
|
atLeastVersion(hass.config.version, 2025, 10)
|
||||||
|
? "/api/hassio/core/logs/latest"
|
||||||
|
: "/api/error_log";
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
mdiChatSleep,
|
mdiChatSleep,
|
||||||
mdiClipboardList,
|
mdiClipboardList,
|
||||||
mdiClock,
|
mdiClock,
|
||||||
|
mdiCodeBraces,
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiCommentAlert,
|
mdiCommentAlert,
|
||||||
mdiCounter,
|
mdiCounter,
|
||||||
@@ -113,6 +114,7 @@ export const FALLBACK_DOMAIN_ICONS = {
|
|||||||
text: mdiFormTextbox,
|
text: mdiFormTextbox,
|
||||||
time: mdiClock,
|
time: mdiClock,
|
||||||
timer: mdiTimerOutline,
|
timer: mdiTimerOutline,
|
||||||
|
template: mdiCodeBraces,
|
||||||
todo: mdiClipboardList,
|
todo: mdiClipboardList,
|
||||||
tts: mdiSpeakerMessage,
|
tts: mdiSpeakerMessage,
|
||||||
vacuum: mdiRobotVacuum,
|
vacuum: mdiRobotVacuum,
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
|||||||
pm25: {
|
pm25: {
|
||||||
default: "mdi:molecule",
|
default: "mdi:molecule",
|
||||||
},
|
},
|
||||||
|
pm4: {
|
||||||
|
default: "mdi:molecule",
|
||||||
|
},
|
||||||
power: {
|
power: {
|
||||||
default: "mdi:flash",
|
default: "mdi:flash",
|
||||||
},
|
},
|
||||||
@@ -674,6 +677,9 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
|||||||
pm25: {
|
pm25: {
|
||||||
default: "mdi:molecule",
|
default: "mdi:molecule",
|
||||||
},
|
},
|
||||||
|
pm4: {
|
||||||
|
default: "mdi:molecule",
|
||||||
|
},
|
||||||
power: {
|
power: {
|
||||||
default: "mdi:flash",
|
default: "mdi:flash",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const COMPONENTS = {
|
|||||||
"media-browser": () =>
|
"media-browser": () =>
|
||||||
import("../panels/media-browser/ha-panel-media-browser"),
|
import("../panels/media-browser/ha-panel-media-browser"),
|
||||||
light: () => import("../panels/light/ha-panel-light"),
|
light: () => import("../panels/light/ha-panel-light"),
|
||||||
safety: () => import("../panels/safety/ha-panel-safety"),
|
security: () => import("../panels/security/ha-panel-security"),
|
||||||
climate: () => import("../panels/climate/ha-panel-climate"),
|
climate: () => import("../panels/climate/ha-panel-climate"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { LitElement, css, html } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { goBack } from "../../common/navigate";
|
import { goBack } from "../../common/navigate";
|
||||||
|
import { debounce } from "../../common/util/debounce";
|
||||||
|
import { deepEqual } from "../../common/util/deep-equal";
|
||||||
import "../../components/ha-icon-button-arrow-prev";
|
import "../../components/ha-icon-button-arrow-prev";
|
||||||
import "../../components/ha-menu-button";
|
import "../../components/ha-menu-button";
|
||||||
import type { LovelaceConfig } from "../../data/lovelace/config/types";
|
import type { LovelaceStrategyViewConfig } from "../../data/lovelace/config/view";
|
||||||
import { haStyle } from "../../resources/styles";
|
import { haStyle } from "../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import { generateLovelaceViewStrategy } from "../lovelace/strategies/get-strategy";
|
||||||
import type { Lovelace } from "../lovelace/types";
|
import type { Lovelace } from "../lovelace/types";
|
||||||
import "../lovelace/views/hui-view";
|
import "../lovelace/views/hui-view";
|
||||||
import "../lovelace/views/hui-view-container";
|
import "../lovelace/views/hui-view-container";
|
||||||
|
|
||||||
const CLIMATE_LOVELACE_CONFIG: LovelaceConfig = {
|
const CLIMATE_LOVELACE_VIEW_CONFIG: LovelaceStrategyViewConfig = {
|
||||||
views: [
|
strategy: {
|
||||||
{
|
type: "climate",
|
||||||
strategy: {
|
},
|
||||||
type: "climate",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("ha-panel-climate")
|
@customElement("ha-panel-climate")
|
||||||
@@ -33,65 +32,119 @@ class PanelClimate extends LitElement {
|
|||||||
|
|
||||||
@state() private _searchParms = new URLSearchParams(window.location.search);
|
@state() private _searchParms = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
public firstUpdated(_changedProperties: PropertyValues): void {
|
|
||||||
super.firstUpdated(_changedProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public willUpdate(changedProps: PropertyValues) {
|
public willUpdate(changedProps: PropertyValues) {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this.hass.loadFragmentTranslation("lovelace");
|
||||||
|
this._setLovelace();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changedProps.has("hass")) {
|
if (!changedProps.has("hass")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldHass = changedProps.get("hass") as this["hass"];
|
const oldHass = changedProps.get("hass") as this["hass"];
|
||||||
if (oldHass?.locale !== this.hass.locale) {
|
if (oldHass && oldHass.localize !== this.hass.localize) {
|
||||||
this._setLovelace();
|
this._setLovelace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldHass && this.hass) {
|
||||||
|
// If the entity registry changed, ask the user if they want to refresh the config
|
||||||
|
if (
|
||||||
|
oldHass.entities !== this.hass.entities ||
|
||||||
|
oldHass.devices !== this.hass.devices ||
|
||||||
|
oldHass.areas !== this.hass.areas ||
|
||||||
|
oldHass.floors !== this.hass.floors
|
||||||
|
) {
|
||||||
|
if (this.hass.config.state === "RUNNING") {
|
||||||
|
this._debounceRegistriesChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If ha started, refresh the config
|
||||||
|
if (
|
||||||
|
this.hass.config.state === "RUNNING" &&
|
||||||
|
oldHass.config.state !== "RUNNING"
|
||||||
|
) {
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _debounceRegistriesChanged = debounce(
|
||||||
|
() => this._registriesChanged(),
|
||||||
|
200
|
||||||
|
);
|
||||||
|
|
||||||
|
private _registriesChanged = async () => {
|
||||||
|
this._setLovelace();
|
||||||
|
};
|
||||||
|
|
||||||
private _back(ev) {
|
private _back(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
goBack();
|
goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
${this._searchParms.has("historyBack")
|
${
|
||||||
? html`
|
this._searchParms.has("historyBack")
|
||||||
<ha-icon-button-arrow-prev
|
? html`
|
||||||
@click=${this._back}
|
<ha-icon-button-arrow-prev
|
||||||
slot="navigationIcon"
|
@click=${this._back}
|
||||||
></ha-icon-button-arrow-prev>
|
slot="navigationIcon"
|
||||||
`
|
></ha-icon-button-arrow-prev>
|
||||||
: html`
|
`
|
||||||
<ha-menu-button
|
: html`
|
||||||
slot="navigationIcon"
|
<ha-menu-button
|
||||||
.hass=${this.hass}
|
slot="navigationIcon"
|
||||||
.narrow=${this.narrow}
|
.hass=${this.hass}
|
||||||
></ha-menu-button>
|
.narrow=${this.narrow}
|
||||||
`}
|
></ha-menu-button>
|
||||||
|
`
|
||||||
|
}
|
||||||
<div class="main-title">${this.hass.localize("panel.climate")}</div>
|
<div class="main-title">${this.hass.localize("panel.climate")}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
${
|
||||||
<hui-view-container .hass=${this.hass}>
|
this._lovelace
|
||||||
<hui-view
|
? html`
|
||||||
.hass=${this.hass}
|
<hui-view-container .hass=${this.hass}>
|
||||||
.narrow=${this.narrow}
|
<hui-view
|
||||||
.lovelace=${this._lovelace}
|
.hass=${this.hass}
|
||||||
.index=${this._viewIndex}
|
.narrow=${this.narrow}
|
||||||
></hui-view>
|
.lovelace=${this._lovelace}
|
||||||
|
.index=${this._viewIndex}
|
||||||
|
></hui-view
|
||||||
|
></hui-view-container>
|
||||||
|
`
|
||||||
|
: nothing
|
||||||
|
}
|
||||||
</hui-view-container>
|
</hui-view-container>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setLovelace() {
|
private async _setLovelace() {
|
||||||
|
const viewConfig = await generateLovelaceViewStrategy(
|
||||||
|
CLIMATE_LOVELACE_VIEW_CONFIG,
|
||||||
|
this.hass
|
||||||
|
);
|
||||||
|
|
||||||
|
const config = { views: [viewConfig] };
|
||||||
|
const rawConfig = { views: [CLIMATE_LOVELACE_VIEW_CONFIG] };
|
||||||
|
|
||||||
|
if (deepEqual(config, this._lovelace?.config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._lovelace = {
|
this._lovelace = {
|
||||||
config: CLIMATE_LOVELACE_CONFIG,
|
config: config,
|
||||||
rawConfig: CLIMATE_LOVELACE_CONFIG,
|
rawConfig: rawConfig,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
urlPath: "climate",
|
urlPath: "climate",
|
||||||
mode: "generated",
|
mode: "generated",
|
||||||
|
|||||||
@@ -115,6 +115,24 @@ const processAreasForClimate = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const processUnassignedEntities = (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entities: string[]
|
||||||
|
): LovelaceCardConfig[] => {
|
||||||
|
const unassignedFilter = generateEntityFilter(hass, {
|
||||||
|
area: null,
|
||||||
|
});
|
||||||
|
const unassignedEntities = entities.filter(unassignedFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
const computeTileCard = computeAreaTileCardConfig(hass, "", true);
|
||||||
|
|
||||||
|
for (const entityId of unassignedEntities) {
|
||||||
|
areaCards.push(computeTileCard(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return areaCards;
|
||||||
|
};
|
||||||
|
|
||||||
@customElement("climate-view-strategy")
|
@customElement("climate-view-strategy")
|
||||||
export class ClimateViewStrategy extends ReactiveElement {
|
export class ClimateViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
@@ -190,10 +208,33 @@ export class ClimateViewStrategy extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process unassigned entities
|
||||||
|
const unassignedCards = processUnassignedEntities(hass, entities);
|
||||||
|
|
||||||
|
if (unassignedCards.length > 0) {
|
||||||
|
const section: LovelaceSectionRawConfig = {
|
||||||
|
type: "grid",
|
||||||
|
column_span: 2,
|
||||||
|
cards: [
|
||||||
|
{
|
||||||
|
type: "heading",
|
||||||
|
heading:
|
||||||
|
sections.length > 0
|
||||||
|
? hass.localize(
|
||||||
|
"ui.panel.lovelace.strategy.climate.other_devices"
|
||||||
|
)
|
||||||
|
: hass.localize("ui.panel.lovelace.strategy.climate.devices"),
|
||||||
|
},
|
||||||
|
...unassignedCards,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
sections.push(section);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "sections",
|
type: "sections",
|
||||||
max_columns: 2,
|
max_columns: 2,
|
||||||
sections: sections || [],
|
sections: sections,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,24 +8,24 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
|||||||
import "../../../components/chips/ha-chip-set";
|
import "../../../components/chips/ha-chip-set";
|
||||||
import "../../../components/chips/ha-input-chip";
|
import "../../../components/chips/ha-input-chip";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-button";
|
|
||||||
import "../../../components/ha-aliases-editor";
|
import "../../../components/ha-aliases-editor";
|
||||||
|
import "../../../components/ha-area-picker";
|
||||||
|
import "../../../components/ha-button";
|
||||||
import { createCloseHeading } from "../../../components/ha-dialog";
|
import { createCloseHeading } from "../../../components/ha-dialog";
|
||||||
import "../../../components/ha-icon-picker";
|
import "../../../components/ha-icon-picker";
|
||||||
import "../../../components/ha-picture-upload";
|
import "../../../components/ha-picture-upload";
|
||||||
import "../../../components/ha-settings-row";
|
import "../../../components/ha-settings-row";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import "../../../components/ha-area-picker";
|
import { updateAreaRegistryEntry } from "../../../data/area_registry";
|
||||||
import type {
|
import type {
|
||||||
FloorRegistryEntry,
|
FloorRegistryEntry,
|
||||||
FloorRegistryEntryMutableParams,
|
FloorRegistryEntryMutableParams,
|
||||||
} from "../../../data/floor_registry";
|
} from "../../../data/floor_registry";
|
||||||
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { FloorRegistryDetailDialogParams } from "./show-dialog-floor-registry-detail";
|
|
||||||
import { showAreaRegistryDetailDialog } from "./show-dialog-area-registry-detail";
|
import { showAreaRegistryDetailDialog } from "./show-dialog-area-registry-detail";
|
||||||
import { updateAreaRegistryEntry } from "../../../data/area_registry";
|
import type { FloorRegistryDetailDialogParams } from "./show-dialog-floor-registry-detail";
|
||||||
|
|
||||||
class DialogFloorDetail extends LitElement {
|
class DialogFloorDetail extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@@ -168,11 +168,6 @@ class DialogFloorDetail extends LitElement {
|
|||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<p class="description">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.floors.editor.areas_description"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
${areas.length
|
${areas.length
|
||||||
? html`<ha-chip-set>
|
? html`<ha-chip-set>
|
||||||
${repeat(
|
${repeat(
|
||||||
@@ -197,13 +192,17 @@ class DialogFloorDetail extends LitElement {
|
|||||||
</ha-input-chip>`
|
</ha-input-chip>`
|
||||||
)}
|
)}
|
||||||
</ha-chip-set>`
|
</ha-chip-set>`
|
||||||
: nothing}
|
: html`<p class="description">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.floors.editor.areas_description"
|
||||||
|
)}
|
||||||
|
</p>`}
|
||||||
<ha-area-picker
|
<ha-area-picker
|
||||||
no-add
|
no-add
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@value-changed=${this._addArea}
|
@value-changed=${this._addArea}
|
||||||
.excludeAreas=${areas.map((a) => a.area_id)}
|
.excludeAreas=${areas.map((a) => a.area_id)}
|
||||||
.label=${this.hass.localize(
|
.addButtonLabel=${this.hass.localize(
|
||||||
"ui.panel.config.floors.editor.add_area"
|
"ui.panel.config.floors.editor.add_area"
|
||||||
)}
|
)}
|
||||||
></ha-area-picker>
|
></ha-area-picker>
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class DialogAddAutomationElement
|
|||||||
|
|
||||||
const results = fuse.multiTermsSearch(filter);
|
const results = fuse.multiTermsSearch(filter);
|
||||||
if (results) {
|
if (results) {
|
||||||
return results.map((result) => result.item);
|
return results.map((result) => result.item).filter((item) => item.name);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ class DialogAddAutomationElement
|
|||||||
|
|
||||||
const results = fuse.multiTermsSearch(filter);
|
const results = fuse.multiTermsSearch(filter);
|
||||||
if (results) {
|
if (results) {
|
||||||
return results.map((result) => result.item);
|
return results.map((result) => result.item).filter((item) => item.name);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
@@ -383,9 +383,16 @@ class DialogAddAutomationElement
|
|||||||
|
|
||||||
generatedCollections.push({
|
generatedCollections.push({
|
||||||
titleKey: collection.titleKey,
|
titleKey: collection.titleKey,
|
||||||
groups: groups.sort((a, b) =>
|
groups: groups.sort((a, b) => {
|
||||||
stringCompare(a.name, b.name, this.hass.locale.language)
|
// make sure device is always on top
|
||||||
),
|
if (a.key === "device" || a.key === "device_id") {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (b.key === "device" || b.key === "device_id") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return stringCompare(a.name, b.name, this.hass.locale.language);
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return generatedCollections;
|
return generatedCollections;
|
||||||
@@ -678,7 +685,7 @@ class DialogAddAutomationElement
|
|||||||
);
|
);
|
||||||
|
|
||||||
const typeTitle = this.hass.localize(
|
const typeTitle = this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.${automationElementType}s.header`
|
`ui.panel.config.automation.editor.${automationElementType}s.add`
|
||||||
);
|
);
|
||||||
|
|
||||||
const tabButtons = [
|
const tabButtons = [
|
||||||
@@ -895,7 +902,9 @@ class DialogAddAutomationElement
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="items-title ${this._itemsScrolled ? "scrolled" : ""}">
|
<div class="items-title ${this._itemsScrolled ? "scrolled" : ""}">
|
||||||
${title}
|
${this._tab === "blocks" && !this._filter
|
||||||
|
? this.hass.localize("ui.panel.config.automation.editor.blocks")
|
||||||
|
: title}
|
||||||
</div>
|
</div>
|
||||||
<ha-md-list
|
<ha-md-list
|
||||||
dialogInitialFocus=${ifDefined(this._fullScreen ? "" : undefined)}
|
dialogInitialFocus=${ifDefined(this._fullScreen ? "" : undefined)}
|
||||||
@@ -1045,6 +1054,7 @@ class DialogAddAutomationElement
|
|||||||
private _onSearchFocus(ev) {
|
private _onSearchFocus(ev) {
|
||||||
this._removeKeyboardShortcuts = tinykeys(ev.target, {
|
this._removeKeyboardShortcuts = tinykeys(ev.target, {
|
||||||
ArrowDown: this._focusSearchList,
|
ArrowDown: this._focusSearchList,
|
||||||
|
Enter: this._pickSingleItem,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1061,6 +1071,39 @@ class DialogAddAutomationElement
|
|||||||
this._itemsListFirstElement.focus();
|
this._itemsListFirstElement.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _pickSingleItem = (ev: KeyboardEvent) => {
|
||||||
|
if (!this._filter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ev.preventDefault();
|
||||||
|
const automationElementType = this._params!.type;
|
||||||
|
|
||||||
|
const items = [
|
||||||
|
...this._getFilteredItems(
|
||||||
|
automationElementType,
|
||||||
|
this._filter,
|
||||||
|
this.hass.localize,
|
||||||
|
this.hass.services,
|
||||||
|
this._manifests
|
||||||
|
),
|
||||||
|
...(automationElementType !== "trigger"
|
||||||
|
? this._getFilteredBuildingBlocks(
|
||||||
|
automationElementType,
|
||||||
|
this._filter,
|
||||||
|
this.hass.localize
|
||||||
|
)
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (items.length !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._params!.add(items[0].key);
|
||||||
|
this.closeDialog();
|
||||||
|
};
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
css`
|
css`
|
||||||
@@ -1137,11 +1180,11 @@ class DialogAddAutomationElement
|
|||||||
}
|
}
|
||||||
.groups .selected {
|
.groups .selected {
|
||||||
background-color: var(--ha-color-fill-primary-normal-active);
|
background-color: var(--ha-color-fill-primary-normal-active);
|
||||||
--md-list-item-label-text-color: var(--primary-color);
|
--md-list-item-label-text-color: var(--ha-color-on-primary-normal);
|
||||||
--icon-primary-color: var(--primary-color);
|
--icon-primary-color: var(--ha-color-on-primary-normal);
|
||||||
}
|
}
|
||||||
.groups .selected ha-svg-icon {
|
.groups .selected ha-svg-icon {
|
||||||
color: var(--primary-color);
|
color: var(--ha-color-on-primary-normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
.collection-title {
|
.collection-title {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
|
mdiIdentifier,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
mdiPlusCircleMultipleOutline,
|
mdiPlusCircleMultipleOutline,
|
||||||
@@ -40,6 +41,8 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@property({ type: Number, attribute: "sidebar-key" })
|
@property({ type: Number, attribute: "sidebar-key" })
|
||||||
public sidebarKey?: number;
|
public sidebarKey?: number;
|
||||||
|
|
||||||
|
@state() private _requestShowId = false;
|
||||||
|
|
||||||
@state() private _warnings?: string[];
|
@state() private _warnings?: string[];
|
||||||
|
|
||||||
@query(".sidebar-editor")
|
@query(".sidebar-editor")
|
||||||
@@ -47,6 +50,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
|
|
||||||
protected willUpdate(changedProperties) {
|
protected willUpdate(changedProperties) {
|
||||||
if (changedProperties.has("config")) {
|
if (changedProperties.has("config")) {
|
||||||
|
this._requestShowId = false;
|
||||||
this._warnings = undefined;
|
this._warnings = undefined;
|
||||||
if (this.config) {
|
if (this.config) {
|
||||||
this.yamlMode = this.config.yamlMode;
|
this.yamlMode = this.config.yamlMode;
|
||||||
@@ -101,6 +105,24 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
|
${!this.yamlMode &&
|
||||||
|
!("id" in this.config.config) &&
|
||||||
|
!this._requestShowId
|
||||||
|
? html`<ha-md-menu-item
|
||||||
|
slot="menu-items"
|
||||||
|
.clickAction=${this._showTriggerId}
|
||||||
|
.disabled=${this.disabled || type === "list"}
|
||||||
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiIdentifier}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.edit_id"
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
|
</ha-md-menu-item>`
|
||||||
|
: nothing}
|
||||||
|
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
role="separator"
|
role="separator"
|
||||||
@@ -250,6 +272,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@value-changed=${this._valueChangedSidebar}
|
@value-changed=${this._valueChangedSidebar}
|
||||||
@yaml-changed=${this._yamlChangedSidebar}
|
@yaml-changed=${this._yamlChangedSidebar}
|
||||||
.uiSupported=${this.config.uiSupported}
|
.uiSupported=${this.config.uiSupported}
|
||||||
|
.showId=${this._requestShowId}
|
||||||
.yamlMode=${this.yamlMode}
|
.yamlMode=${this.yamlMode}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
||||||
@@ -292,6 +315,10 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
fireEvent(this, "toggle-yaml-mode");
|
fireEvent(this, "toggle-yaml-mode");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _showTriggerId = () => {
|
||||||
|
this._requestShowId = true;
|
||||||
|
};
|
||||||
|
|
||||||
static styles = [sidebarEditorStyles, overflowStyles];
|
static styles = [sidebarEditorStyles, overflowStyles];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: "show-id" }) public showId = false;
|
||||||
|
|
||||||
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -36,6 +38,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
const yamlMode = this.yamlMode || !this.uiSupported;
|
const yamlMode = this.yamlMode || !this.uiSupported;
|
||||||
|
|
||||||
|
const showId = "id" in this.trigger || this.showId;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
@@ -70,20 +74,15 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
></ha-yaml-editor>
|
></ha-yaml-editor>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
${!isTriggerList(this.trigger)
|
${showId && !isTriggerList(this.trigger)
|
||||||
? html`
|
? html`
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${`${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.id"
|
"ui.panel.config.automation.editor.triggers.id"
|
||||||
)} (${this.hass.localize(
|
)}
|
||||||
"ui.panel.config.automation.editor.triggers.optional"
|
|
||||||
)})`}
|
|
||||||
.value=${this.trigger.id || ""}
|
.value=${this.trigger.id || ""}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@change=${this._idChanged}
|
@change=${this._idChanged}
|
||||||
.helper=${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.triggers.id_helper"
|
|
||||||
)}
|
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|||||||
@@ -245,18 +245,20 @@ export class HaStateTrigger extends LitElement implements TriggerElement {
|
|||||||
newTrigger.to,
|
newTrigger.to,
|
||||||
newTrigger.attribute
|
newTrigger.attribute
|
||||||
);
|
);
|
||||||
|
if (Array.isArray(newTrigger.to) && newTrigger.to.length === 0) {
|
||||||
|
delete newTrigger.to;
|
||||||
|
}
|
||||||
newTrigger.from = this._applyAnyStateExclusive(
|
newTrigger.from = this._applyAnyStateExclusive(
|
||||||
newTrigger.from,
|
newTrigger.from,
|
||||||
newTrigger.attribute
|
newTrigger.attribute
|
||||||
);
|
);
|
||||||
|
if (Array.isArray(newTrigger.from) && newTrigger.from.length === 0) {
|
||||||
|
delete newTrigger.from;
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(newTrigger).forEach((key) => {
|
Object.keys(newTrigger).forEach((key) => {
|
||||||
const val = newTrigger[key];
|
const val = newTrigger[key];
|
||||||
if (
|
if (val === undefined || val === "") {
|
||||||
val === undefined ||
|
|
||||||
val === "" ||
|
|
||||||
(Array.isArray(val) && val.length === 0)
|
|
||||||
) {
|
|
||||||
delete newTrigger[key];
|
delete newTrigger[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@query("#overflow-menu") private _overflowMenu?: HaMdMenu;
|
@query("#overflow-menu") private _overflowMenu?: HaMdMenu;
|
||||||
|
|
||||||
private _overflowBackup?: BackupContent;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
window.addEventListener("location-changed", this._locationChanged);
|
window.addEventListener("location-changed", this._locationChanged);
|
||||||
@@ -262,7 +260,7 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
type: "overflow-menu",
|
type: "overflow-menu",
|
||||||
template: (backup) => html`
|
template: (backup) => html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
.selected=${backup}
|
.backup=${backup}
|
||||||
.label=${this.hass.localize("ui.common.overflow_menu")}
|
.label=${this.hass.localize("ui.common.overflow_menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
@click=${this._toggleOverflowMenu}
|
@click=${this._toggleOverflowMenu}
|
||||||
@@ -294,7 +292,6 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
this._overflowMenu.close();
|
this._overflowMenu.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._overflowBackup = ev.target.selected;
|
|
||||||
this._overflowMenu.anchorElement = ev.target;
|
this._overflowMenu.anchorElement = ev.target;
|
||||||
this._overflowMenu.show();
|
this._overflowMenu.show();
|
||||||
};
|
};
|
||||||
@@ -375,16 +372,14 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
clickable
|
clickable
|
||||||
id="backup_id"
|
id="backup_id"
|
||||||
has-filters
|
has-filters
|
||||||
.filters=${
|
.filters=${Object.values(this._filters).filter((filter) =>
|
||||||
Object.values(this._filters).filter((filter) =>
|
Array.isArray(filter)
|
||||||
Array.isArray(filter)
|
? filter.length
|
||||||
? filter.length
|
: filter &&
|
||||||
: filter &&
|
Object.values(filter).some((val) =>
|
||||||
Object.values(filter).some((val) =>
|
Array.isArray(val) ? val.length : val
|
||||||
Array.isArray(val) ? val.length : val
|
)
|
||||||
)
|
).length}
|
||||||
).length
|
|
||||||
}
|
|
||||||
selectable
|
selectable
|
||||||
.selected=${this._selected.length}
|
.selected=${this._selected.length}
|
||||||
.initialGroupColumn=${this._activeGrouping}
|
.initialGroupColumn=${this._activeGrouping}
|
||||||
@@ -426,30 +421,28 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="selection-bar">
|
<div slot="selection-bar">
|
||||||
${
|
${!this.narrow
|
||||||
!this.narrow
|
? html`
|
||||||
? html`
|
<ha-button
|
||||||
<ha-button
|
appearance="plain"
|
||||||
appearance="plain"
|
@click=${this._deleteSelected}
|
||||||
@click=${this._deleteSelected}
|
variant="danger"
|
||||||
variant="danger"
|
>
|
||||||
>
|
${this.hass.localize(
|
||||||
${this.hass.localize(
|
"ui.panel.config.backup.backups.delete_selected"
|
||||||
"ui.panel.config.backup.backups.delete_selected"
|
)}
|
||||||
)}
|
</ha-button>
|
||||||
</ha-button>
|
`
|
||||||
`
|
: html`
|
||||||
: html`
|
<ha-icon-button
|
||||||
<ha-icon-button
|
.label=${this.hass.localize(
|
||||||
.label=${this.hass.localize(
|
"ui.panel.config.backup.backups.delete_selected"
|
||||||
"ui.panel.config.backup.backups.delete_selected"
|
)}
|
||||||
)}
|
.path=${mdiDelete}
|
||||||
.path=${mdiDelete}
|
class="warning"
|
||||||
class="warning"
|
@click=${this._deleteSelected}
|
||||||
@click=${this._deleteSelected}
|
></ha-icon-button>
|
||||||
></ha-icon-button>
|
`}
|
||||||
`
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ha-filter-states
|
<ha-filter-states
|
||||||
@@ -462,43 +455,39 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
expanded
|
expanded
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
></ha-filter-states>
|
></ha-filter-states>
|
||||||
${
|
${!this._needsOnboarding
|
||||||
!this._needsOnboarding
|
? html`
|
||||||
? html`
|
<ha-fab
|
||||||
<ha-fab
|
slot="fab"
|
||||||
slot="fab"
|
?disabled=${backupInProgress}
|
||||||
?disabled=${backupInProgress}
|
.label=${this.hass.localize(
|
||||||
.label=${this.hass.localize(
|
"ui.panel.config.backup.backups.new_backup"
|
||||||
"ui.panel.config.backup.backups.new_backup"
|
)}
|
||||||
)}
|
extended
|
||||||
extended
|
@click=${this._newBackup}
|
||||||
@click=${this._newBackup}
|
>
|
||||||
>
|
${backupInProgress
|
||||||
${backupInProgress
|
? html`<div slot="icon" class="loading">
|
||||||
? html`<div slot="icon" class="loading">
|
<ha-spinner .size=${"small"}></ha-spinner>
|
||||||
<ha-spinner .size=${"small"}></ha-spinner>
|
</div>`
|
||||||
</div>`
|
: html`<ha-svg-icon
|
||||||
: html`<ha-svg-icon
|
slot="icon"
|
||||||
slot="icon"
|
.path=${mdiPlus}
|
||||||
.path=${mdiPlus}
|
></ha-svg-icon>`}
|
||||||
></ha-svg-icon>`}
|
</ha-fab>
|
||||||
</ha-fab>
|
`
|
||||||
`
|
: nothing}
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
</hass-tabs-subpage-data-table>
|
</hass-tabs-subpage-data-table>
|
||||||
<ha-md-menu id="overflow-menu" positioning="fixed">
|
<ha-md-menu id="overflow-menu" positioning="fixed">
|
||||||
<ha-md-menu-item .clickAction=${this._downloadBackup}>
|
<ha-md-menu-item .clickAction=${this._downloadBackup}>
|
||||||
<ha-svg-icon slot="start" .path=${mdiDownload}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiDownload}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.common.download")}
|
${this.hass.localize("ui.common.download")}
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
<ha-md-menu-item class="warning" .clickAction=${this._deleteBackup}>
|
<ha-md-menu-item class="warning" .clickAction=${this._deleteBackup}>
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.common.delete")}
|
${this.hass.localize("ui.common.delete")}
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
</ha-md-menu>
|
</ha-md-menu>
|
||||||
>
|
|
||||||
</ha-icon-overflow-menu>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,15 +561,17 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
navigate(`/config/backup/details/${id}`);
|
navigate(`/config/backup/details/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _downloadBackup(): Promise<void> {
|
private _downloadBackup = async (ev): Promise<void> => {
|
||||||
if (!this._overflowBackup) {
|
const backup = ev.parentElement.anchorElement.backup;
|
||||||
|
if (!backup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
downloadBackup(this.hass, this, this._overflowBackup, this.config);
|
downloadBackup(this.hass, this, backup, this.config);
|
||||||
}
|
};
|
||||||
|
|
||||||
private async _deleteBackup(): Promise<void> {
|
private _deleteBackup = async (ev): Promise<void> => {
|
||||||
if (!this._overflowBackup) {
|
const backup = ev.parentElement.anchorElement.backup;
|
||||||
|
if (!backup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,11 +587,9 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deleteBackup(this.hass, this._overflowBackup.backup_id);
|
await deleteBackup(this.hass, backup.backup_id);
|
||||||
if (this._selected.includes(this._overflowBackup.backup_id)) {
|
if (this._selected.includes(backup.backup_id)) {
|
||||||
this._selected = this._selected.filter(
|
this._selected = this._selected.filter((id) => id !== backup.backup_id);
|
||||||
(id) => id !== this._overflowBackup!.backup_id
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
@@ -612,7 +601,7 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fireEvent(this, "ha-refresh-backup-info");
|
fireEvent(this, "ha-refresh-backup-info");
|
||||||
}
|
};
|
||||||
|
|
||||||
private async _deleteSelected() {
|
private async _deleteSelected() {
|
||||||
const confirm = await showConfirmationDialog(this, {
|
const confirm = await showConfirmationDialog(this, {
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export class HaDeviceEntitiesCard extends LitElement {
|
|||||||
addEntitiesToLovelaceView(
|
addEntitiesToLovelaceView(
|
||||||
this,
|
this,
|
||||||
this.hass,
|
this.hass,
|
||||||
computeCards(this.hass.states, entities, {
|
computeCards(this.hass, entities, {
|
||||||
title: this.deviceName,
|
title: this.deviceName,
|
||||||
}),
|
}),
|
||||||
computeSection(entities, {
|
computeSection(entities, {
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name";
|
import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name";
|
||||||
import "../../../../components/ha-alert";
|
import "../../../../components/ha-alert";
|
||||||
import "../../../../components/ha-area-picker";
|
import "../../../../components/ha-area-picker";
|
||||||
import "../../../../components/ha-wa-dialog";
|
import "../../../../components/ha-dialog";
|
||||||
import "../../../../components/ha-dialog-footer";
|
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-labels-picker";
|
import "../../../../components/ha-labels-picker";
|
||||||
import type { HaSwitch } from "../../../../components/ha-switch";
|
import type { HaSwitch } from "../../../../components/ha-switch";
|
||||||
@@ -20,8 +19,6 @@ import type { DeviceRegistryDetailDialogParams } from "./show-dialog-device-regi
|
|||||||
class DialogDeviceRegistryDetail extends LitElement {
|
class DialogDeviceRegistryDetail extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private _open = false;
|
|
||||||
|
|
||||||
@state() private _nameByUser!: string;
|
@state() private _nameByUser!: string;
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
@@ -45,15 +42,10 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
this._areaId = this._params.device.area_id || "";
|
this._areaId = this._params.device.area_id || "";
|
||||||
this._labels = this._params.device.labels || [];
|
this._labels = this._params.device.labels || [];
|
||||||
this._disabledBy = this._params.device.disabled_by;
|
this._disabledBy = this._params.device.disabled_by;
|
||||||
this._open = true;
|
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
this._open = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _dialogClosed(): void {
|
|
||||||
this._error = "";
|
this._error = "";
|
||||||
this._params = undefined;
|
this._params = undefined;
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
@@ -65,12 +57,10 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
}
|
}
|
||||||
const device = this._params.device;
|
const device = this._params.device;
|
||||||
return html`
|
return html`
|
||||||
<ha-wa-dialog
|
<ha-dialog
|
||||||
.hass=${this.hass}
|
open
|
||||||
.open=${this._open}
|
@closed=${this.closeDialog}
|
||||||
header-title=${computeDeviceNameDisplay(device, this.hass)}
|
.heading=${computeDeviceNameDisplay(device, this.hass)}
|
||||||
prevent-scrim-close
|
|
||||||
@closed=${this._dialogClosed}
|
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
${this._error
|
${this._error
|
||||||
@@ -78,7 +68,6 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
autofocus
|
|
||||||
.value=${this._nameByUser}
|
.value=${this._nameByUser}
|
||||||
@input=${this._nameChanged}
|
@input=${this._nameChanged}
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -86,6 +75,7 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
)}
|
)}
|
||||||
.placeholder=${device.name || ""}
|
.placeholder=${device.name || ""}
|
||||||
.disabled=${this._submitting}
|
.disabled=${this._submitting}
|
||||||
|
dialogInitialFocus
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-area-picker
|
<ha-area-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -141,25 +131,22 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ha-button
|
||||||
<ha-dialog-footer slot="footer">
|
slot="secondaryAction"
|
||||||
<ha-button
|
@click=${this.closeDialog}
|
||||||
slot="secondaryAction"
|
.disabled=${this._submitting}
|
||||||
@click=${this.closeDialog}
|
appearance="plain"
|
||||||
.disabled=${this._submitting}
|
>
|
||||||
appearance="plain"
|
${this.hass.localize("ui.common.cancel")}
|
||||||
>
|
</ha-button>
|
||||||
${this.hass.localize("ui.common.cancel")}
|
<ha-button
|
||||||
</ha-button>
|
slot="primaryAction"
|
||||||
<ha-button
|
@click=${this._updateEntry}
|
||||||
slot="primaryAction"
|
.disabled=${this._submitting}
|
||||||
@click=${this._updateEntry}
|
>
|
||||||
.disabled=${this._submitting}
|
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
|
||||||
>
|
</ha-button>
|
||||||
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
|
</ha-dialog>
|
||||||
</ha-button>
|
|
||||||
</ha-dialog-footer>
|
|
||||||
</ha-wa-dialog>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { customElement, property, query, state } from "lit/decorators";
|
|||||||
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
|
||||||
import { dynamicElement } from "../../../../../common/dom/dynamic-element-directive";
|
import { dynamicElement } from "../../../../../common/dom/dynamic-element-directive";
|
||||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||||
|
import "../../../../../components/ha-button";
|
||||||
import type { ExtEntityRegistryEntry } from "../../../../../data/entity_registry";
|
import type { ExtEntityRegistryEntry } from "../../../../../data/entity_registry";
|
||||||
import { removeEntityRegistryEntry } from "../../../../../data/entity_registry";
|
import { removeEntityRegistryEntry } from "../../../../../data/entity_registry";
|
||||||
import { HELPERS_CRUD } from "../../../../../data/helpers_crud";
|
import { HELPERS_CRUD } from "../../../../../data/helpers_crud";
|
||||||
@@ -22,7 +23,6 @@ import "../../../helpers/forms/ha-schedule-form";
|
|||||||
import "../../../helpers/forms/ha-timer-form";
|
import "../../../helpers/forms/ha-timer-form";
|
||||||
import "../../../voice-assistants/entity-voice-settings";
|
import "../../../voice-assistants/entity-voice-settings";
|
||||||
import "../../entity-registry-settings-editor";
|
import "../../entity-registry-settings-editor";
|
||||||
import "../../../../../components/ha-button";
|
|
||||||
import type { EntityRegistrySettingsEditor } from "../../entity-registry-settings-editor";
|
import type { EntityRegistrySettingsEditor } from "../../entity-registry-settings-editor";
|
||||||
|
|
||||||
@customElement("entity-settings-helper-tab")
|
@customElement("entity-settings-helper-tab")
|
||||||
@@ -72,22 +72,28 @@ export class EntitySettingsHelperTab extends LitElement {
|
|||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
|
${this._item === null
|
||||||
|
? html`<ha-alert alert-type="info"
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.dialogs.helper_settings.yaml_not_editable"
|
||||||
|
)}</ha-alert
|
||||||
|
>`
|
||||||
|
: nothing}
|
||||||
${!this._componentLoaded
|
${!this._componentLoaded
|
||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
"ui.dialogs.helper_settings.platform_not_loaded",
|
"ui.dialogs.helper_settings.platform_not_loaded",
|
||||||
{ platform: this.entry.platform }
|
{ platform: this.entry.platform }
|
||||||
)
|
)
|
||||||
: this._item === null
|
: html`
|
||||||
? this.hass.localize("ui.dialogs.helper_settings.yaml_not_editable")
|
<span @value-changed=${this._valueChanged}>
|
||||||
: html`
|
${dynamicElement(`ha-${this.entry.platform}-form`, {
|
||||||
<span @value-changed=${this._valueChanged}>
|
hass: this.hass,
|
||||||
${dynamicElement(`ha-${this.entry.platform}-form`, {
|
item: this._item,
|
||||||
hass: this.hass,
|
entry: this.entry,
|
||||||
item: this._item,
|
disabled: this._item === null,
|
||||||
entry: this.entry,
|
})}
|
||||||
})}
|
</span>
|
||||||
</span>
|
`}
|
||||||
`}
|
|
||||||
<entity-registry-settings-editor
|
<entity-registry-settings-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.entry=${this.entry}
|
.entry=${this.entry}
|
||||||
@@ -122,6 +128,9 @@ export class EntitySettingsHelperTab extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _valueChanged(ev: CustomEvent): void {
|
private _valueChanged(ev: CustomEvent): void {
|
||||||
|
if (this._item === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._item = ev.detail.value;
|
this._item = ev.detail.value;
|
||||||
}
|
}
|
||||||
@@ -195,6 +204,10 @@ export class EntitySettingsHelperTab extends LitElement {
|
|||||||
display: block;
|
display: block;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
|
ha-alert {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: var(--ha-space-4);
|
||||||
|
}
|
||||||
.form {
|
.form {
|
||||||
padding: 20px 24px;
|
padding: 20px 24px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
|
|||||||
<ha-labels-picker
|
<ha-labels-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this._labels}
|
.value=${this._labels}
|
||||||
.disabled=${this.disabled}
|
.disabled=${!!this.disabled}
|
||||||
@value-changed=${this._labelsChanged}
|
@value-changed=${this._labelsChanged}
|
||||||
></ha-labels-picker>
|
></ha-labels-picker>
|
||||||
${this._cameraPrefs
|
${this._cameraPrefs
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class HaCounterForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: Partial<Counter>;
|
private _item?: Partial<Counter>;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -82,6 +84,7 @@ class HaCounterForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -91,6 +94,7 @@ class HaCounterForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._minimum}
|
.value=${this._minimum}
|
||||||
@@ -100,6 +104,7 @@ class HaCounterForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.counter.minimum"
|
"ui.dialogs.helper_settings.counter.minimum"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._maximum}
|
.value=${this._maximum}
|
||||||
@@ -109,6 +114,7 @@ class HaCounterForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.counter.maximum"
|
"ui.dialogs.helper_settings.counter.maximum"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._initial}
|
.value=${this._initial}
|
||||||
@@ -118,6 +124,7 @@ class HaCounterForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.counter.initial"
|
"ui.dialogs.helper_settings.counter.initial"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-expansion-panel
|
<ha-expansion-panel
|
||||||
header=${this.hass.localize(
|
header=${this.hass.localize(
|
||||||
@@ -133,12 +140,14 @@ class HaCounterForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.counter.step"
|
"ui.dialogs.helper_settings.counter.step"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<ha-switch
|
<ha-switch
|
||||||
.checked=${this._restore}
|
.checked=${this._restore}
|
||||||
.configValue=${"restore"}
|
.configValue=${"restore"}
|
||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
</ha-switch>
|
</ha-switch>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class HaInputBooleanForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: InputBoolean;
|
private _item?: InputBoolean;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -59,6 +61,7 @@ class HaInputBooleanForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -68,6 +71,7 @@ class HaInputBooleanForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class HaInputButtonForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
|
|
||||||
@state() private _icon!: string;
|
@state() private _icon!: string;
|
||||||
@@ -59,6 +61,7 @@ class HaInputButtonForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -68,6 +71,7 @@ class HaInputButtonForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: InputDateTime;
|
private _item?: InputDateTime;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -73,6 +75,7 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -82,6 +85,7 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<br />
|
<br />
|
||||||
${this.hass.localize("ui.dialogs.helper_settings.input_datetime.mode")}:
|
${this.hass.localize("ui.dialogs.helper_settings.input_datetime.mode")}:
|
||||||
@@ -97,6 +101,7 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
value="date"
|
value="date"
|
||||||
.checked=${this._mode === "date"}
|
.checked=${this._mode === "date"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
@@ -109,6 +114,7 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
value="time"
|
value="time"
|
||||||
.checked=${this._mode === "time"}
|
.checked=${this._mode === "time"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
@@ -121,6 +127,7 @@ class HaInputDateTimeForm extends LitElement {
|
|||||||
value="datetime"
|
value="datetime"
|
||||||
.checked=${this._mode === "datetime"}
|
.checked=${this._mode === "datetime"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class HaInputNumberForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: Partial<InputNumber>;
|
private _item?: Partial<InputNumber>;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -89,6 +91,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -98,6 +101,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._min}
|
.value=${this._min}
|
||||||
@@ -108,6 +112,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_number.min"
|
"ui.dialogs.helper_settings.input_number.min"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._max}
|
.value=${this._max}
|
||||||
@@ -118,6 +123,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_number.max"
|
"ui.dialogs.helper_settings.input_number.max"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-expansion-panel
|
<ha-expansion-panel
|
||||||
header=${this.hass.localize(
|
header=${this.hass.localize(
|
||||||
@@ -139,6 +145,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
value="slider"
|
value="slider"
|
||||||
.checked=${this._mode === "slider"}
|
.checked=${this._mode === "slider"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
@@ -151,6 +158,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
value="box"
|
value="box"
|
||||||
.checked=${this._mode === "box"}
|
.checked=${this._mode === "box"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
</div>
|
</div>
|
||||||
@@ -163,6 +171,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_number.step"
|
"ui.dialogs.helper_settings.input_number.step"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
|
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
@@ -172,6 +181,7 @@ class HaInputNumberForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_number.unit_of_measurement"
|
"ui.dialogs.helper_settings.input_number.unit_of_measurement"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
</ha-expansion-panel>
|
</ha-expansion-panel>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class HaInputSelectForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: InputSelect;
|
private _item?: InputSelect;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -86,6 +88,7 @@ class HaInputSelectForm extends LitElement {
|
|||||||
)}
|
)}
|
||||||
.configValue=${"name"}
|
.configValue=${"name"}
|
||||||
@input=${this._valueChanged}
|
@input=${this._valueChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -95,13 +98,18 @@ class HaInputSelectForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
${this.hass!.localize(
|
${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_select.options"
|
"ui.dialogs.helper_settings.input_select.options"
|
||||||
)}:
|
)}:
|
||||||
</div>
|
</div>
|
||||||
<ha-sortable @item-moved=${this._optionMoved} handle-selector=".handle">
|
<ha-sortable
|
||||||
|
@item-moved=${this._optionMoved}
|
||||||
|
handle-selector=".handle"
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
>
|
||||||
<ha-list class="options">
|
<ha-list class="options">
|
||||||
${this._options.length
|
${this._options.length
|
||||||
? repeat(
|
? repeat(
|
||||||
@@ -124,6 +132,7 @@ class HaInputSelectForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.input_select.remove_option"
|
"ui.dialogs.helper_settings.input_select.remove_option"
|
||||||
)}
|
)}
|
||||||
@click=${this._removeOption}
|
@click=${this._removeOption}
|
||||||
|
.disabled=${this.disabled}
|
||||||
.path=${mdiDelete}
|
.path=${mdiDelete}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
@@ -146,8 +155,13 @@ class HaInputSelectForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.input_select.add_option"
|
"ui.dialogs.helper_settings.input_select.add_option"
|
||||||
)}
|
)}
|
||||||
@keydown=${this._handleKeyAdd}
|
@keydown=${this._handleKeyAdd}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-button size="small" appearance="plain" @click=${this._addOption}
|
<ha-button
|
||||||
|
size="small"
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._addOption}
|
||||||
|
.disabled=${this.disabled}
|
||||||
>${this.hass!.localize(
|
>${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_select.add"
|
"ui.dialogs.helper_settings.input_select.add"
|
||||||
)}</ha-button
|
)}</ha-button
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class HaInputTextForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: InputText;
|
private _item?: InputText;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -79,6 +81,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -88,6 +91,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-expansion-panel
|
<ha-expansion-panel
|
||||||
header=${this.hass.localize(
|
header=${this.hass.localize(
|
||||||
@@ -105,6 +109,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_text.min"
|
"ui.dialogs.helper_settings.input_text.min"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.value=${this._max}
|
.value=${this._max}
|
||||||
@@ -129,6 +134,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
value="text"
|
value="text"
|
||||||
.checked=${this._mode === "text"}
|
.checked=${this._mode === "text"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
@@ -141,6 +147,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
value="password"
|
value="password"
|
||||||
.checked=${this._mode === "password"}
|
.checked=${this._mode === "password"}
|
||||||
@change=${this._modeChanged}
|
@change=${this._modeChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-radio>
|
></ha-radio>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,6 +161,7 @@ class HaInputTextForm extends LitElement {
|
|||||||
.helper=${this.hass!.localize(
|
.helper=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.input_text.pattern_helper"
|
"ui.dialogs.helper_settings.input_text.pattern_helper"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
</ha-expansion-panel>
|
</ha-expansion-panel>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ import "../../../../components/ha-textfield";
|
|||||||
import type { Schedule, ScheduleDay } from "../../../../data/schedule";
|
import type { Schedule, ScheduleDay } from "../../../../data/schedule";
|
||||||
import { weekdays } from "../../../../data/schedule";
|
import { weekdays } from "../../../../data/schedule";
|
||||||
import { TimeZone } from "../../../../data/translation";
|
import { TimeZone } from "../../../../data/translation";
|
||||||
import { showScheduleBlockInfoDialog } from "./show-dialog-schedule-block-info";
|
|
||||||
import { haStyle } from "../../../../resources/styles";
|
import { haStyle } from "../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { showScheduleBlockInfoDialog } from "./show-dialog-schedule-block-info";
|
||||||
|
|
||||||
const defaultFullCalendarConfig: CalendarOptions = {
|
const defaultFullCalendarConfig: CalendarOptions = {
|
||||||
plugins: [timeGridPlugin, interactionPlugin],
|
plugins: [timeGridPlugin, interactionPlugin],
|
||||||
@@ -43,6 +43,8 @@ class HaScheduleForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
|
|
||||||
@state() private _icon!: string;
|
@state() private _icon!: string;
|
||||||
@@ -132,6 +134,7 @@ class HaScheduleForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -141,8 +144,9 @@ class HaScheduleForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<div id="calendar"></div>
|
${!this.disabled ? html`<div id="calendar"></div>` : nothing}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -175,7 +179,9 @@ class HaScheduleForm extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(): void {
|
protected firstUpdated(): void {
|
||||||
this._setupCalendar();
|
if (!this.disabled) {
|
||||||
|
this._setupCalendar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setupCalendar(): void {
|
private _setupCalendar(): void {
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { createDurationData } from "../../../../common/datetime/create_duration_data";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/ha-checkbox";
|
import "../../../../components/ha-checkbox";
|
||||||
|
import "../../../../components/ha-duration-input";
|
||||||
|
import type { HaDurationData } from "../../../../components/ha-duration-input";
|
||||||
import "../../../../components/ha-formfield";
|
import "../../../../components/ha-formfield";
|
||||||
import "../../../../components/ha-icon-picker";
|
import "../../../../components/ha-icon-picker";
|
||||||
import "../../../../components/ha-duration-input";
|
|
||||||
import "../../../../components/ha-textfield";
|
import "../../../../components/ha-textfield";
|
||||||
|
import type { ForDict } from "../../../../data/automation";
|
||||||
import type { DurationDict, Timer } from "../../../../data/timer";
|
import type { DurationDict, Timer } from "../../../../data/timer";
|
||||||
import { haStyle } from "../../../../resources/styles";
|
import { haStyle } from "../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
import { createDurationData } from "../../../../common/datetime/create_duration_data";
|
|
||||||
import type { HaDurationData } from "../../../../components/ha-duration-input";
|
|
||||||
import type { ForDict } from "../../../../data/automation";
|
|
||||||
|
|
||||||
@customElement("ha-timer-form")
|
@customElement("ha-timer-form")
|
||||||
class HaTimerForm extends LitElement {
|
class HaTimerForm extends LitElement {
|
||||||
@@ -20,6 +20,8 @@ class HaTimerForm extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public new = false;
|
@property({ type: Boolean }) public new = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
private _item?: Timer;
|
private _item?: Timer;
|
||||||
|
|
||||||
@state() private _name!: string;
|
@state() private _name!: string;
|
||||||
@@ -77,6 +79,7 @@ class HaTimerForm extends LitElement {
|
|||||||
"ui.dialogs.helper_settings.required_error_msg"
|
"ui.dialogs.helper_settings.required_error_msg"
|
||||||
)}
|
)}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-icon-picker
|
<ha-icon-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -86,11 +89,13 @@ class HaTimerForm extends LitElement {
|
|||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.dialogs.helper_settings.generic.icon"
|
"ui.dialogs.helper_settings.generic.icon"
|
||||||
)}
|
)}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-duration-input
|
<ha-duration-input
|
||||||
.configValue=${"duration"}
|
.configValue=${"duration"}
|
||||||
.data=${this._duration_data}
|
.data=${this._duration_data}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
|
.disabled=${this.disabled}
|
||||||
></ha-duration-input>
|
></ha-duration-input>
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -101,6 +106,7 @@ class HaTimerForm extends LitElement {
|
|||||||
.configValue=${"restore"}
|
.configValue=${"restore"}
|
||||||
.checked=${this._restore}
|
.checked=${this._restore}
|
||||||
@click=${this._toggleRestore}
|
@click=${this._toggleRestore}
|
||||||
|
.disabled=${this.disabled}
|
||||||
>
|
>
|
||||||
</ha-checkbox>
|
</ha-checkbox>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
@@ -130,6 +136,9 @@ class HaTimerForm extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _toggleRestore() {
|
private _toggleRestore() {
|
||||||
|
if (this.disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._restore = !this._restore;
|
this._restore = !this._restore;
|
||||||
fireEvent(this, "value-changed", {
|
fireEvent(this, "value-changed", {
|
||||||
value: { ...this._item, restore: this._restore },
|
value: { ...this._item, restore: this._restore },
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ class HaConfigInfo extends LitElement {
|
|||||||
const customUiList: { name: string; url: string; version: string }[] =
|
const customUiList: { name: string; url: string; version: string }[] =
|
||||||
(window as any).CUSTOM_UI_LIST || [];
|
(window as any).CUSTOM_UI_LIST || [];
|
||||||
|
|
||||||
|
const isDark = this.hass.themes?.darkMode || false;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hass-subpage
|
<hass-subpage
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -186,7 +188,7 @@ class HaConfigInfo extends LitElement {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</ul>
|
</ul>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
<ha-card outlined class="ohf">
|
<ha-card outlined class="ohf ${isDark ? "dark" : ""}">
|
||||||
<div>
|
<div>
|
||||||
${this.hass.localize("ui.panel.config.info.proud_part_of")}
|
${this.hass.localize("ui.panel.config.info.proud_part_of")}
|
||||||
</div>
|
</div>
|
||||||
@@ -346,6 +348,10 @@ class HaConfigInfo extends LitElement {
|
|||||||
max-width: 250px;
|
max-width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ohf.dark img {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
.versions {
|
.versions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -790,7 +790,10 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
const timeString = new Date().toISOString().replace(/:/g, "-");
|
const timeString = new Date().toISOString().replace(/:/g, "-");
|
||||||
const logFileName = `home-assistant_${integration}_${timeString}.log`;
|
const logFileName = `home-assistant_${integration}_${timeString}.log`;
|
||||||
const signedUrl = await getSignedPath(this.hass, getErrorLogDownloadUrl);
|
const signedUrl = await getSignedPath(
|
||||||
|
this.hass,
|
||||||
|
getErrorLogDownloadUrl(this.hass)
|
||||||
|
);
|
||||||
fileDownload(signedUrl.path, logFileName);
|
fileDownload(signedUrl.path, logFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -426,6 +426,10 @@ class DialogZHAReconfigureDevice extends LitElement {
|
|||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
|
ha-dialog {
|
||||||
|
--mdc-dialog-max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 3fr 1fr 2fr;
|
grid-template-columns: 3fr 1fr 2fr;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class DialogLabelDetail
|
|||||||
this.hass,
|
this.hass,
|
||||||
this._params.entry
|
this._params.entry
|
||||||
? this._params.entry.name || this._params.entry.label_id
|
? this._params.entry.name || this._params.entry.label_id
|
||||||
: this.hass!.localize("ui.panel.config.labels.detail.new_label")
|
: this.hass!.localize("ui.dialogs.label-detail.new_label")
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@@ -95,11 +95,9 @@ class DialogLabelDetail
|
|||||||
.value=${this._name}
|
.value=${this._name}
|
||||||
.configValue=${"name"}
|
.configValue=${"name"}
|
||||||
@input=${this._input}
|
@input=${this._input}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.name")}
|
||||||
"ui.panel.config.labels.detail.name"
|
|
||||||
)}
|
|
||||||
.validationMessage=${this.hass!.localize(
|
.validationMessage=${this.hass!.localize(
|
||||||
"ui.panel.config.labels.detail.required_error_msg"
|
"ui.dialogs.label-detail.required_error_msg"
|
||||||
)}
|
)}
|
||||||
required
|
required
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
@@ -108,25 +106,21 @@ class DialogLabelDetail
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.configValue=${"icon"}
|
.configValue=${"icon"}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.icon")}
|
||||||
"ui.panel.config.labels.detail.icon"
|
|
||||||
)}
|
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-color-picker
|
<ha-color-picker
|
||||||
.value=${this._color}
|
.value=${this._color}
|
||||||
.configValue=${"color"}
|
.configValue=${"color"}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.color")}
|
||||||
"ui.panel.config.labels.detail.color"
|
|
||||||
)}
|
|
||||||
></ha-color-picker>
|
></ha-color-picker>
|
||||||
<ha-textarea
|
<ha-textarea
|
||||||
.value=${this._description}
|
.value=${this._description}
|
||||||
.configValue=${"description"}
|
.configValue=${"description"}
|
||||||
@input=${this._input}
|
@input=${this._input}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.panel.config.labels.detail.description"
|
"ui.dialogs.label-detail.description"
|
||||||
)}
|
)}
|
||||||
></ha-textarea>
|
></ha-textarea>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,7 +134,7 @@ class DialogLabelDetail
|
|||||||
@click=${this._deleteEntry}
|
@click=${this._deleteEntry}
|
||||||
.disabled=${this._submitting}
|
.disabled=${this._submitting}
|
||||||
>
|
>
|
||||||
${this.hass!.localize("ui.panel.config.labels.detail.delete")}
|
${this.hass!.localize("ui.common.delete")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
@@ -150,8 +144,8 @@ class DialogLabelDetail
|
|||||||
.disabled=${this._submitting || !this._name}
|
.disabled=${this._submitting || !this._name}
|
||||||
>
|
>
|
||||||
${this._params.entry
|
${this._params.entry
|
||||||
? this.hass!.localize("ui.panel.config.labels.detail.update")
|
? this.hass!.localize("ui.common.update")
|
||||||
: this.hass!.localize("ui.panel.config.labels.detail.create")}
|
: this.hass!.localize("ui.common.create")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class ErrorLogCard extends LitElement {
|
|||||||
const downloadUrl =
|
const downloadUrl =
|
||||||
this.provider && this.provider !== "core"
|
this.provider && this.provider !== "core"
|
||||||
? getHassioLogDownloadUrl(this.provider)
|
? getHassioLogDownloadUrl(this.provider)
|
||||||
: getErrorLogDownloadUrl;
|
: getErrorLogDownloadUrl(this.hass);
|
||||||
const logFileName =
|
const logFileName =
|
||||||
this.provider && this.provider !== "core"
|
this.provider && this.provider !== "core"
|
||||||
? `${this.provider}_${timeString}.log`
|
? `${this.provider}_${timeString}.log`
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { mdiDotsVertical, mdiDownload, mdiRefresh, mdiText } from "@mdi/js";
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
|
||||||
import { atLeastVersion } from "../../../common/config/version";
|
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import "../../../components/buttons/ha-call-service-button";
|
import "../../../components/buttons/ha-call-service-button";
|
||||||
@@ -15,7 +13,6 @@ import "../../../components/ha-list-item";
|
|||||||
import "../../../components/ha-spinner";
|
import "../../../components/ha-spinner";
|
||||||
import { getSignedPath } from "../../../data/auth";
|
import { getSignedPath } from "../../../data/auth";
|
||||||
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
||||||
import { coreLatestLogsUrl } from "../../../data/hassio/supervisor";
|
|
||||||
import { domainToName } from "../../../data/integration";
|
import { domainToName } from "../../../data/integration";
|
||||||
import type { LoggedError } from "../../../data/system_log";
|
import type { LoggedError } from "../../../data/system_log";
|
||||||
import {
|
import {
|
||||||
@@ -231,11 +228,7 @@ export class SystemLogCard extends LitElement {
|
|||||||
|
|
||||||
private async _downloadLogs() {
|
private async _downloadLogs() {
|
||||||
const timeString = new Date().toISOString().replace(/:/g, "-");
|
const timeString = new Date().toISOString().replace(/:/g, "-");
|
||||||
const downloadUrl =
|
const downloadUrl = getErrorLogDownloadUrl(this.hass);
|
||||||
isComponentLoaded(this.hass, "hassio") &&
|
|
||||||
atLeastVersion(this.hass.config.version, 2025, 10)
|
|
||||||
? coreLatestLogsUrl
|
|
||||||
: getErrorLogDownloadUrl;
|
|
||||||
const logFileName = `home-assistant_${timeString}.log`;
|
const logFileName = `home-assistant_${timeString}.log`;
|
||||||
const signedUrl = await getSignedPath(this.hass, downloadUrl);
|
const signedUrl = await getSignedPath(this.hass, downloadUrl);
|
||||||
fileDownload(signedUrl.path, logFileName);
|
fileDownload(signedUrl.path, logFileName);
|
||||||
|
|||||||
@@ -332,13 +332,13 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hass.panels.safety) {
|
if (this.hass.panels.security) {
|
||||||
result.push({
|
result.push({
|
||||||
icon: "mdi:security",
|
icon: "mdi:security",
|
||||||
title: this.hass.localize("panel.safety"),
|
title: this.hass.localize("panel.security"),
|
||||||
show_in_sidebar: false,
|
show_in_sidebar: false,
|
||||||
mode: "storage",
|
mode: "storage",
|
||||||
url_path: "safety",
|
url_path: "security",
|
||||||
filename: "",
|
filename: "",
|
||||||
default: false,
|
default: false,
|
||||||
require_admin: false,
|
require_admin: false,
|
||||||
@@ -470,13 +470,13 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _canDelete(urlPath: string) {
|
private _canDelete(urlPath: string) {
|
||||||
return !["lovelace", "energy", "light", "safety", "climate"].includes(
|
return !["lovelace", "energy", "light", "security", "climate"].includes(
|
||||||
urlPath
|
urlPath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _canEdit(urlPath: string) {
|
private _canEdit(urlPath: string) {
|
||||||
return !["light", "safety", "climate"].includes(urlPath);
|
return !["light", "security", "climate"].includes(urlPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleDelete = async (item: DataTableItem) => {
|
private _handleDelete = async (item: DataTableItem) => {
|
||||||
|
|||||||
@@ -109,15 +109,26 @@ export class AssistPipelineDetailConversation extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _supportedLanguagesChanged(ev) {
|
private _supportedLanguagesChanged(ev) {
|
||||||
if (ev.detail.value === "*") {
|
this._supportedLanguages = ev.detail.value;
|
||||||
|
|
||||||
|
if (
|
||||||
|
this._supportedLanguages === "*" ||
|
||||||
|
!this._supportedLanguages?.includes(
|
||||||
|
this.data?.conversation_language || ""
|
||||||
|
) ||
|
||||||
|
!this.data?.conversation_language
|
||||||
|
) {
|
||||||
// wait for update of conversation_engine
|
// wait for update of conversation_engine
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const value = { ...this.data };
|
const value = { ...this.data };
|
||||||
value.conversation_language = "*";
|
if (this._supportedLanguages === "*") {
|
||||||
|
value.conversation_language = "*";
|
||||||
|
} else {
|
||||||
|
value.conversation_language = this._supportedLanguages?.[0] ?? null;
|
||||||
|
}
|
||||||
fireEvent(this, "value-changed", { value });
|
fireEvent(this, "value-changed", { value });
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
this._supportedLanguages = ev.detail.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
<ha-button
|
<ha-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
@click=${this._updatePipeline}
|
@click=${this._updatePipeline}
|
||||||
.disabled=${this._submitting}
|
.loading=${this._submitting}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
>
|
>
|
||||||
${this._params.pipeline?.id
|
${this._params.pipeline?.id
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { LitElement, css, html } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { goBack } from "../../common/navigate";
|
import { goBack } from "../../common/navigate";
|
||||||
|
import { debounce } from "../../common/util/debounce";
|
||||||
|
import { deepEqual } from "../../common/util/deep-equal";
|
||||||
import "../../components/ha-icon-button-arrow-prev";
|
import "../../components/ha-icon-button-arrow-prev";
|
||||||
import "../../components/ha-menu-button";
|
import "../../components/ha-menu-button";
|
||||||
import type { LovelaceConfig } from "../../data/lovelace/config/types";
|
import type { LovelaceStrategyViewConfig } from "../../data/lovelace/config/view";
|
||||||
import { haStyle } from "../../resources/styles";
|
import { haStyle } from "../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import { generateLovelaceViewStrategy } from "../lovelace/strategies/get-strategy";
|
||||||
import type { Lovelace } from "../lovelace/types";
|
import type { Lovelace } from "../lovelace/types";
|
||||||
import "../lovelace/views/hui-view";
|
import "../lovelace/views/hui-view";
|
||||||
import "../lovelace/views/hui-view-container";
|
import "../lovelace/views/hui-view-container";
|
||||||
|
|
||||||
const LIGHT_LOVELACE_CONFIG: LovelaceConfig = {
|
const LIGHT_LOVELACE_VIEW_CONFIG: LovelaceStrategyViewConfig = {
|
||||||
views: [
|
strategy: {
|
||||||
{
|
type: "light",
|
||||||
strategy: {
|
},
|
||||||
type: "light",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("ha-panel-light")
|
@customElement("ha-panel-light")
|
||||||
@@ -34,60 +33,118 @@ class PanelLight extends LitElement {
|
|||||||
@state() private _searchParms = new URLSearchParams(window.location.search);
|
@state() private _searchParms = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
public willUpdate(changedProps: PropertyValues) {
|
public willUpdate(changedProps: PropertyValues) {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
// Initial setup
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
this.hass.loadFragmentTranslation("lovelace");
|
this.hass.loadFragmentTranslation("lovelace");
|
||||||
|
this._setLovelace();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changedProps.has("hass")) {
|
if (!changedProps.has("hass")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldHass = changedProps.get("hass") as this["hass"];
|
const oldHass = changedProps.get("hass") as this["hass"];
|
||||||
if (oldHass?.locale !== this.hass.locale) {
|
if (oldHass && oldHass.localize !== this.hass.localize) {
|
||||||
this._setLovelace();
|
this._setLovelace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldHass && this.hass) {
|
||||||
|
// If the entity registry changed, ask the user if they want to refresh the config
|
||||||
|
if (
|
||||||
|
oldHass.entities !== this.hass.entities ||
|
||||||
|
oldHass.devices !== this.hass.devices ||
|
||||||
|
oldHass.areas !== this.hass.areas ||
|
||||||
|
oldHass.floors !== this.hass.floors
|
||||||
|
) {
|
||||||
|
if (this.hass.config.state === "RUNNING") {
|
||||||
|
this._debounceRegistriesChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If ha started, refresh the config
|
||||||
|
if (
|
||||||
|
this.hass.config.state === "RUNNING" &&
|
||||||
|
oldHass.config.state !== "RUNNING"
|
||||||
|
) {
|
||||||
|
this._setLovelace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _debounceRegistriesChanged = debounce(
|
||||||
|
() => this._registriesChanged(),
|
||||||
|
200
|
||||||
|
);
|
||||||
|
|
||||||
|
private _registriesChanged = async () => {
|
||||||
|
this._setLovelace();
|
||||||
|
};
|
||||||
|
|
||||||
private _back(ev) {
|
private _back(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
goBack();
|
goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
${this._searchParms.has("historyBack")
|
${
|
||||||
? html`
|
this._searchParms.has("historyBack")
|
||||||
<ha-icon-button-arrow-prev
|
? html`
|
||||||
@click=${this._back}
|
<ha-icon-button-arrow-prev
|
||||||
slot="navigationIcon"
|
@click=${this._back}
|
||||||
></ha-icon-button-arrow-prev>
|
slot="navigationIcon"
|
||||||
`
|
></ha-icon-button-arrow-prev>
|
||||||
: html`
|
`
|
||||||
<ha-menu-button
|
: html`
|
||||||
slot="navigationIcon"
|
<ha-menu-button
|
||||||
.hass=${this.hass}
|
slot="navigationIcon"
|
||||||
.narrow=${this.narrow}
|
.hass=${this.hass}
|
||||||
></ha-menu-button>
|
.narrow=${this.narrow}
|
||||||
`}
|
></ha-menu-button>
|
||||||
|
`
|
||||||
|
}
|
||||||
<div class="main-title">${this.hass.localize("panel.light")}</div>
|
<div class="main-title">${this.hass.localize("panel.light")}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
${
|
||||||
<hui-view-container .hass=${this.hass}>
|
this._lovelace
|
||||||
<hui-view
|
? html`
|
||||||
.hass=${this.hass}
|
<hui-view-container .hass=${this.hass}>
|
||||||
.narrow=${this.narrow}
|
<hui-view
|
||||||
.lovelace=${this._lovelace}
|
.hass=${this.hass}
|
||||||
.index=${this._viewIndex}
|
.narrow=${this.narrow}
|
||||||
></hui-view>
|
.lovelace=${this._lovelace}
|
||||||
|
.index=${this._viewIndex}
|
||||||
|
></hui-view
|
||||||
|
></hui-view-container>
|
||||||
|
`
|
||||||
|
: nothing
|
||||||
|
}
|
||||||
</hui-view-container>
|
</hui-view-container>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setLovelace() {
|
private async _setLovelace() {
|
||||||
|
const viewConfig = await generateLovelaceViewStrategy(
|
||||||
|
LIGHT_LOVELACE_VIEW_CONFIG,
|
||||||
|
this.hass
|
||||||
|
);
|
||||||
|
|
||||||
|
const config = { views: [viewConfig] };
|
||||||
|
const rawConfig = { views: [LIGHT_LOVELACE_VIEW_CONFIG] };
|
||||||
|
|
||||||
|
if (deepEqual(config, this._lovelace?.config)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._lovelace = {
|
this._lovelace = {
|
||||||
config: LIGHT_LOVELACE_CONFIG,
|
config: config,
|
||||||
rawConfig: LIGHT_LOVELACE_CONFIG,
|
rawConfig: rawConfig,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
urlPath: "light",
|
urlPath: "light",
|
||||||
mode: "generated",
|
mode: "generated",
|
||||||
|
|||||||
@@ -61,6 +61,24 @@ const processAreasForLight = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const processUnassignedLights = (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entities: string[]
|
||||||
|
): LovelaceCardConfig[] => {
|
||||||
|
const unassignedFilter = generateEntityFilter(hass, {
|
||||||
|
area: null,
|
||||||
|
});
|
||||||
|
const unassignedLights = entities.filter(unassignedFilter);
|
||||||
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
|
||||||
|
|
||||||
|
for (const entityId of unassignedLights) {
|
||||||
|
areaCards.push(computeTileCard(entityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return areaCards;
|
||||||
|
};
|
||||||
|
|
||||||
@customElement("light-view-strategy")
|
@customElement("light-view-strategy")
|
||||||
export class LightViewStrategy extends ReactiveElement {
|
export class LightViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
@@ -136,10 +154,30 @@ export class LightViewStrategy extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process unassigned lights
|
||||||
|
const unassignedCards = processUnassignedLights(hass, entities);
|
||||||
|
if (unassignedCards.length > 0) {
|
||||||
|
const section: LovelaceSectionRawConfig = {
|
||||||
|
type: "grid",
|
||||||
|
column_span: 2,
|
||||||
|
cards: [
|
||||||
|
{
|
||||||
|
type: "heading",
|
||||||
|
heading:
|
||||||
|
sections.length > 0
|
||||||
|
? hass.localize("ui.panel.lovelace.strategy.light.other_lights")
|
||||||
|
: hass.localize("ui.panel.lovelace.strategy.light.lights"),
|
||||||
|
},
|
||||||
|
...unassignedCards,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
sections.push(section);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: "sections",
|
type: "sections",
|
||||||
max_columns: 2,
|
max_columns: 2,
|
||||||
sections: sections || [],
|
sections: sections,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class HuiHistoryChartCardFeature
|
|||||||
}
|
}
|
||||||
if (!this._coordinates) {
|
if (!this._coordinates) {
|
||||||
return html`
|
return html`
|
||||||
<div class="container">
|
<div class="container loading">
|
||||||
<ha-spinner size="small"></ha-spinner>
|
<ha-spinner size="small"></ha-spinner>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@@ -153,6 +153,14 @@ class HuiHistoryChartCardFeature
|
|||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
pointer-events: none !important;
|
pointer-events: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container.loading {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
hui-graph-base {
|
hui-graph-base {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
--accent-color: var(--feature-color);
|
--accent-color: var(--feature-color);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import memoizeOne from "memoize-one";
|
|||||||
import type { BarSeriesOption, PieSeriesOption } from "echarts/charts";
|
import type { BarSeriesOption, PieSeriesOption } from "echarts/charts";
|
||||||
import { PieChart } from "echarts/charts";
|
import { PieChart } from "echarts/charts";
|
||||||
import type { ECElementEvent } from "echarts/types/dist/shared";
|
import type { ECElementEvent } from "echarts/types/dist/shared";
|
||||||
|
import type { PieDataItemOption } from "echarts/types/src/chart/pie/PieSeries";
|
||||||
import { filterXSS } from "../../../../common/util/xss";
|
import { filterXSS } from "../../../../common/util/xss";
|
||||||
import { getGraphColorByIndex } from "../../../../common/color/colors";
|
import { getGraphColorByIndex } from "../../../../common/color/colors";
|
||||||
import { formatNumber } from "../../../../common/number/format_number";
|
import { formatNumber } from "../../../../common/number/format_number";
|
||||||
@@ -387,6 +388,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this._chartType === "pie") {
|
if (this._chartType === "pie") {
|
||||||
|
const pieChartData = chartData as NonNullable<PieSeriesOption["data"]>;
|
||||||
const { summedData, compareSummedData } = getSummedData(energyData);
|
const { summedData, compareSummedData } = getSummedData(energyData);
|
||||||
const { consumption, compareConsumption } = computeConsumptionData(
|
const { consumption, compareConsumption } = computeConsumptionData(
|
||||||
summedData,
|
summedData,
|
||||||
@@ -399,7 +401,10 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
"from_battery" in summedData;
|
"from_battery" in summedData;
|
||||||
const untracked = showUntracked
|
const untracked = showUntracked
|
||||||
? totalUsed -
|
? totalUsed -
|
||||||
chartData.reduce((acc: number, d: any) => acc + d.value[0], 0)
|
pieChartData.reduce(
|
||||||
|
(acc: number, d) => acc + (d as PieDataItemOption).value![0],
|
||||||
|
0
|
||||||
|
)
|
||||||
: 0;
|
: 0;
|
||||||
if (untracked > 0) {
|
if (untracked > 0) {
|
||||||
const color = getEnergyColor(
|
const color = getEnergyColor(
|
||||||
@@ -409,7 +414,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
false,
|
false,
|
||||||
"--history-unknown-color"
|
"--history-unknown-color"
|
||||||
);
|
);
|
||||||
chartData.push({
|
pieChartData.push({
|
||||||
id: "untracked",
|
id: "untracked",
|
||||||
value: [untracked, "untracked"] as any,
|
value: [untracked, "untracked"] as any,
|
||||||
name: this.hass.localize(
|
name: this.hass.localize(
|
||||||
@@ -442,13 +447,20 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const totalChart = pieChartData.reduce(
|
||||||
|
(acc: number, d) =>
|
||||||
|
this._hiddenStats.includes((d as PieDataItemOption).id as string)
|
||||||
|
? acc
|
||||||
|
: acc + (d as PieDataItemOption).value![0],
|
||||||
|
0
|
||||||
|
);
|
||||||
datasets.push({
|
datasets.push({
|
||||||
type: "pie",
|
type: "pie",
|
||||||
radius: ["0%", compareData ? "30%" : "40%"],
|
radius: ["0%", compareData ? "30%" : "40%"],
|
||||||
name: this.hass.localize(
|
name: this.hass.localize(
|
||||||
"ui.panel.lovelace.cards.energy.energy_devices_graph.total_energy_usage"
|
"ui.panel.lovelace.cards.energy.energy_devices_graph.total_energy_usage"
|
||||||
),
|
),
|
||||||
data: [totalUsed],
|
data: [totalChart],
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: "center",
|
position: "center",
|
||||||
@@ -456,7 +468,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
fontSize: computedStyle.getPropertyValue("--ha-font-size-l"),
|
fontSize: computedStyle.getPropertyValue("--ha-font-size-l"),
|
||||||
lineHeight: 24,
|
lineHeight: 24,
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
formatter: `{a}\n${formatNumber(totalUsed, this.hass.locale)} kWh`,
|
formatter: `{a}\n${formatNumber(totalChart, this.hass.locale)} kWh`,
|
||||||
},
|
},
|
||||||
cursor: "default",
|
cursor: "default",
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
|
|||||||
@@ -419,13 +419,15 @@ class HuiEnergySankeyCard
|
|||||||
};
|
};
|
||||||
deviceNodes.forEach((deviceNode) => {
|
deviceNodes.forEach((deviceNode) => {
|
||||||
const entity = this.hass.states[deviceNode.id];
|
const entity = this.hass.states[deviceNode.id];
|
||||||
const { area, floor } = getEntityContext(
|
const { area, floor } = entity
|
||||||
entity,
|
? getEntityContext(
|
||||||
this.hass.entities,
|
entity,
|
||||||
this.hass.devices,
|
this.hass.entities,
|
||||||
this.hass.areas,
|
this.hass.devices,
|
||||||
this.hass.floors
|
this.hass.areas,
|
||||||
);
|
this.hass.floors
|
||||||
|
)
|
||||||
|
: { area: null, floor: null };
|
||||||
if (area) {
|
if (area) {
|
||||||
if (area.area_id in areas) {
|
if (area.area_id in areas) {
|
||||||
areas[area.area_id].value += deviceNode.value;
|
areas[area.area_id].value += deviceNode.value;
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
class=${classMap({
|
class=${classMap({
|
||||||
"is-grid": this.layout === "grid",
|
"is-grid": this.layout === "grid",
|
||||||
"is-panel": this.layout === "panel",
|
"is-panel": this.layout === "panel",
|
||||||
|
"has-title": !!this._config.title,
|
||||||
})}
|
})}
|
||||||
.narrow=${this._narrow}
|
.narrow=${this._narrow}
|
||||||
.events=${this._events}
|
.events=${this._events}
|
||||||
@@ -229,6 +230,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
padding: 0 8px 8px;
|
padding: 0 8px 8px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@@ -239,15 +241,25 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
padding-inline-start: 8px;
|
padding-inline-start: 8px;
|
||||||
direction: var(--direction);
|
direction: var(--direction);
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-full-calendar {
|
ha-full-calendar {
|
||||||
--calendar-height: 400px;
|
--calendar-height: 400px;
|
||||||
|
height: var(--calendar-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-full-calendar.is-grid,
|
ha-full-calendar.is-grid,
|
||||||
ha-full-calendar.is-panel {
|
ha-full-calendar.is-panel {
|
||||||
height: calc(100% - 16px);
|
--calendar-height: calc(100% - 16px);
|
||||||
|
}
|
||||||
|
|
||||||
|
ha-full-calendar.is-grid.has-title,
|
||||||
|
ha-full-calendar.is-panel.has-title {
|
||||||
|
--calendar-height: calc(
|
||||||
|
100% - var(--ha-card-header-font-size, var(--ha-font-size-2xl)) - 22px
|
||||||
|
);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { PropertyValues, TemplateResult } from "lit";
|
import type { PropertyValues, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
@@ -20,11 +20,9 @@ import type {
|
|||||||
import type {
|
import type {
|
||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceGridOptions,
|
|
||||||
LovelaceHeaderFooter,
|
LovelaceHeaderFooter,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { EntitiesCardConfig } from "./types";
|
import type { EntitiesCardConfig } from "./types";
|
||||||
import { haStyleScrollbar } from "../../../resources/styles";
|
|
||||||
|
|
||||||
export const computeShowHeaderToggle = <
|
export const computeShowHeaderToggle = <
|
||||||
T extends EntityConfig | LovelaceRowConfig,
|
T extends EntityConfig | LovelaceRowConfig,
|
||||||
@@ -77,8 +75,6 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _hass?: HomeAssistant;
|
private _hass?: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public layout?: string;
|
|
||||||
|
|
||||||
private _configEntities?: LovelaceRowConfig[];
|
private _configEntities?: LovelaceRowConfig[];
|
||||||
|
|
||||||
private _showHeaderToggle?: boolean;
|
private _showHeaderToggle?: boolean;
|
||||||
@@ -143,14 +139,6 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getGridOptions(): LovelaceGridOptions {
|
|
||||||
return {
|
|
||||||
columns: 12,
|
|
||||||
min_columns: 6,
|
|
||||||
min_rows: this._config?.title || this._showHeaderToggle ? 3 : 2,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public setConfig(config: EntitiesCardConfig): void {
|
public setConfig(config: EntitiesCardConfig): void {
|
||||||
if (!config.entities || !Array.isArray(config.entities)) {
|
if (!config.entities || !Array.isArray(config.entities)) {
|
||||||
throw new Error("Entities must be specified");
|
throw new Error("Entities must be specified");
|
||||||
@@ -245,7 +233,7 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
`}
|
`}
|
||||||
</h1>
|
</h1>
|
||||||
`}
|
`}
|
||||||
<div id="states" class="card-content ha-scrollbar">
|
<div id="states" class="card-content">
|
||||||
${this._configEntities!.map((entityConf) =>
|
${this._configEntities!.map((entityConf) =>
|
||||||
this._renderEntity(entityConf)
|
this._renderEntity(entityConf)
|
||||||
)}
|
)}
|
||||||
@@ -258,73 +246,69 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = [
|
static styles = css`
|
||||||
haStyleScrollbar,
|
ha-card {
|
||||||
css`
|
height: 100%;
|
||||||
ha-card {
|
display: flex;
|
||||||
height: 100%;
|
flex-direction: column;
|
||||||
display: flex;
|
justify-content: space-between;
|
||||||
flex-direction: column;
|
}
|
||||||
justify-content: space-between;
|
.card-header {
|
||||||
}
|
display: flex;
|
||||||
.card-header {
|
justify-content: space-between;
|
||||||
display: flex;
|
}
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header .name {
|
.card-header .name {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
#states {
|
#states {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--entities-card-row-gap, var(--card-row-gap, 8px));
|
gap: var(--entities-card-row-gap, var(--card-row-gap, 8px));
|
||||||
overflow-y: auto;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#states > div > * {
|
#states > div > * {
|
||||||
overflow: clip visible;
|
overflow: clip visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#states > div {
|
#states > div {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
padding: 0px 18px 0px 8px;
|
padding: 0px 18px 0px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
border-top-left-radius: var(
|
border-top-left-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
border-top-right-radius: var(
|
border-top-right-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
border-bottom-left-radius: var(
|
border-bottom-left-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
border-bottom-right-radius: var(
|
border-bottom-right-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
margin-top: -16px;
|
margin-top: -16px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
`,
|
`;
|
||||||
];
|
|
||||||
|
|
||||||
private _renderEntity(entityConf: LovelaceRowConfig): TemplateResult {
|
private _renderEntity(entityConf: LovelaceRowConfig): TemplateResult {
|
||||||
const element = createRowElement(
|
const element = createRowElement(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { classMap } from "lit/directives/class-map";
|
|||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
@@ -19,6 +18,7 @@ import type {
|
|||||||
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||||
@@ -252,7 +252,11 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = entityConf.name ?? computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
entityConf.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -3,25 +3,27 @@ import { LitElement, css, html, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
import { createSearchParam } from "../../../common/url/search-params";
|
||||||
import "../../../components/chart/state-history-charts";
|
import "../../../components/chart/state-history-charts";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon-next";
|
import "../../../components/ha-icon-next";
|
||||||
import {
|
import {
|
||||||
computeHistory,
|
computeHistory,
|
||||||
subscribeHistoryStatesTimeWindow,
|
|
||||||
type HistoryResult,
|
|
||||||
convertStatisticsToHistory,
|
convertStatisticsToHistory,
|
||||||
mergeHistoryResults,
|
mergeHistoryResults,
|
||||||
|
subscribeHistoryStatesTimeWindow,
|
||||||
|
type HistoryResult,
|
||||||
} from "../../../data/history";
|
} from "../../../data/history";
|
||||||
|
import { fetchStatistics } from "../../../data/recorder";
|
||||||
import { getSensorNumericDeviceClasses } from "../../../data/sensor";
|
import { getSensorNumericDeviceClasses } from "../../../data/sensor";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
import type { HistoryGraphCardConfig } from "./types";
|
import type { HistoryGraphCardConfig } from "./types";
|
||||||
import { createSearchParam } from "../../../common/url/search-params";
|
|
||||||
import { fetchStatistics } from "../../../data/recorder";
|
|
||||||
|
|
||||||
export const DEFAULT_HOURS_TO_SHOW = 24;
|
export const DEFAULT_HOURS_TO_SHOW = 24;
|
||||||
|
|
||||||
@@ -51,6 +53,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _entityIds: string[] = [];
|
private _entityIds: string[] = [];
|
||||||
|
|
||||||
|
private _entities: EntityConfig[] = [];
|
||||||
|
|
||||||
private _hoursToShow = DEFAULT_HOURS_TO_SHOW;
|
private _hoursToShow = DEFAULT_HOURS_TO_SHOW;
|
||||||
|
|
||||||
private _interval?: number;
|
private _interval?: number;
|
||||||
@@ -80,21 +84,35 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
throw new Error("You must include at least one entity");
|
throw new Error("You must include at least one entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
const configEntities = config.entities
|
this._entities = config.entities
|
||||||
? processConfigEntities(config.entities)
|
? processConfigEntities(config.entities)
|
||||||
: [];
|
: [];
|
||||||
|
this._entityIds = this._entities.map((entity) => entity.entity);
|
||||||
this._entityIds = [];
|
|
||||||
configEntities.forEach((entity) => {
|
|
||||||
this._entityIds.push(entity.entity);
|
|
||||||
if (entity.name) {
|
|
||||||
this._names[entity.entity] = entity.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this._hoursToShow = config.hours_to_show || DEFAULT_HOURS_TO_SHOW;
|
this._hoursToShow = config.hours_to_show || DEFAULT_HOURS_TO_SHOW;
|
||||||
|
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _computeNames() {
|
||||||
|
if (!this.hass || !this._config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._names = {};
|
||||||
|
this._entities.forEach((entity) => {
|
||||||
|
const stateObj = this.hass!.states[entity.entity];
|
||||||
|
this._names[entity.entity] = stateObj
|
||||||
|
? computeLovelaceEntityName(this.hass!, stateObj, entity.name)
|
||||||
|
: entity.entity;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public willUpdate(changedProps: PropertyValues) {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
if (changedProps.has("hass")) {
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import type { HomeSummaryCard } from "./types";
|
|||||||
const COLORS: Record<HomeSummary, string> = {
|
const COLORS: Record<HomeSummary, string> = {
|
||||||
light: "amber",
|
light: "amber",
|
||||||
climate: "deep-orange",
|
climate: "deep-orange",
|
||||||
safety: "blue-grey",
|
security: "blue-grey",
|
||||||
media_players: "blue",
|
media_players: "blue",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,11 +87,6 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
const allEntities = Object.keys(this.hass!.states);
|
const allEntities = Object.keys(this.hass!.states);
|
||||||
|
|
||||||
const areas = Object.values(this.hass.areas);
|
const areas = Object.values(this.hass.areas);
|
||||||
const areasFilter = generateEntityFilter(this.hass, {
|
|
||||||
area: areas.map((area) => area.area_id),
|
|
||||||
});
|
|
||||||
|
|
||||||
const entitiesInsideArea = allEntities.filter(areasFilter);
|
|
||||||
|
|
||||||
switch (this._config.summary) {
|
switch (this._config.summary) {
|
||||||
case "light": {
|
case "light": {
|
||||||
@@ -100,7 +95,7 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
generateEntityFilter(this.hass!, filter)
|
generateEntityFilter(this.hass!, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const lightEntities = findEntities(entitiesInsideArea, lightsFilters);
|
const lightEntities = findEntities(allEntities, lightsFilters);
|
||||||
|
|
||||||
const onLights = lightEntities.filter((entityId) => {
|
const onLights = lightEntities.filter((entityId) => {
|
||||||
const s = this.hass!.states[entityId]?.state;
|
const s = this.hass!.states[entityId]?.state;
|
||||||
@@ -147,20 +142,20 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
? `${formattedMinTemp}°`
|
? `${formattedMinTemp}°`
|
||||||
: `${formattedMinTemp} - ${formattedMaxTemp}°`;
|
: `${formattedMinTemp} - ${formattedMaxTemp}°`;
|
||||||
}
|
}
|
||||||
case "safety": {
|
case "security": {
|
||||||
// Alarm and lock status
|
// Alarm and lock status
|
||||||
const safetyFilters = HOME_SUMMARIES_FILTERS.safety.map((filter) =>
|
const securityFilters = HOME_SUMMARIES_FILTERS.security.map((filter) =>
|
||||||
generateEntityFilter(this.hass!, filter)
|
generateEntityFilter(this.hass!, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const safetyEntities = findEntities(entitiesInsideArea, safetyFilters);
|
const securityEntities = findEntities(allEntities, securityFilters);
|
||||||
|
|
||||||
const locks = safetyEntities.filter((entityId) => {
|
const locks = securityEntities.filter((entityId) => {
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
return domain === "lock";
|
return domain === "lock";
|
||||||
});
|
});
|
||||||
|
|
||||||
const alarms = safetyEntities.filter((entityId) => {
|
const alarms = securityEntities.filter((entityId) => {
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
return domain === "alarm_control_panel";
|
return domain === "alarm_control_panel";
|
||||||
});
|
});
|
||||||
@@ -204,7 +199,7 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const mediaPlayerEntities = findEntities(
|
const mediaPlayerEntities = findEntities(
|
||||||
entitiesInsideArea,
|
allEntities,
|
||||||
mediaPlayerFilters
|
mediaPlayerFilters
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -35,20 +35,12 @@ import {
|
|||||||
hasConfigOrEntitiesChanged,
|
hasConfigOrEntitiesChanged,
|
||||||
} from "../common/has-changed";
|
} from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
import type { EntityConfig } from "../entity-rows/types";
|
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
import type { MapCardConfig } from "./types";
|
import type { MapCardConfig, MapEntityConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_HOURS_TO_SHOW = 0;
|
export const DEFAULT_HOURS_TO_SHOW = 0;
|
||||||
export const DEFAULT_ZOOM = 14;
|
export const DEFAULT_ZOOM = 14;
|
||||||
|
|
||||||
interface MapEntityConfig extends EntityConfig {
|
|
||||||
label_mode?: "state" | "attribute" | "name";
|
|
||||||
attribute?: string;
|
|
||||||
unit?: string;
|
|
||||||
focus?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GeoEntity {
|
interface GeoEntity {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
label_mode?: "state" | "attribute" | "name" | "icon";
|
label_mode?: "state" | "attribute" | "name" | "icon";
|
||||||
|
|||||||
@@ -20,14 +20,15 @@ import {
|
|||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { computeCardSize } from "../common/compute-card-size";
|
import { computeCardSize } from "../common/compute-card-size";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
||||||
import type {
|
import type {
|
||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceHeaderFooter,
|
|
||||||
LovelaceGridOptions,
|
LovelaceGridOptions,
|
||||||
|
LovelaceHeaderFooter,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { HuiErrorCard } from "./hui-error-card";
|
import type { HuiErrorCard } from "./hui-error-card";
|
||||||
import type { EntityCardConfig, StatisticCardConfig } from "./types";
|
import type { EntityCardConfig, StatisticCardConfig } from "./types";
|
||||||
@@ -180,7 +181,9 @@ export class HuiStatisticCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const stateObj = this.hass.states[this._config.entity];
|
const stateObj = this.hass.states[this._config.entity];
|
||||||
const name =
|
const name =
|
||||||
this._config.name ||
|
(this._config.name
|
||||||
|
? computeLovelaceEntityName(this.hass, stateObj, this._config.name)
|
||||||
|
: "") ||
|
||||||
getStatisticLabel(this.hass, this._config.entity, this._metadata);
|
getStatisticLabel(this.hass, this._config.entity, this._metadata);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
|
import { differenceInDays, subHours } from "date-fns";
|
||||||
import type { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import { subHours, differenceInDays } from "date-fns";
|
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import { getEnergyDataCollection } from "../../../data/energy";
|
import { getEnergyDataCollection } from "../../../data/energy";
|
||||||
import {
|
|
||||||
getSuggestedMax,
|
|
||||||
getSuggestedPeriod,
|
|
||||||
} from "./energy/common/energy-chart-options";
|
|
||||||
import type {
|
import type {
|
||||||
Statistics,
|
Statistics,
|
||||||
StatisticsMetaData,
|
StatisticsMetaData,
|
||||||
@@ -21,10 +17,16 @@ import {
|
|||||||
getStatisticMetadata,
|
getStatisticMetadata,
|
||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
|
import {
|
||||||
|
getSuggestedMax,
|
||||||
|
getSuggestedPeriod,
|
||||||
|
} from "./energy/common/energy-chart-options";
|
||||||
import type { StatisticsGraphCardConfig } from "./types";
|
import type { StatisticsGraphCardConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_DAYS_TO_SHOW = 30;
|
export const DEFAULT_DAYS_TO_SHOW = 30;
|
||||||
@@ -67,7 +69,9 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
@state() private _unit?: string;
|
@state() private _unit?: string;
|
||||||
|
|
||||||
private _entities: string[] = [];
|
private _entities: EntityConfig[] = [];
|
||||||
|
|
||||||
|
private _entityIds: string[] = [];
|
||||||
|
|
||||||
private _names: Record<string, string> = {};
|
private _names: Record<string, string> = {};
|
||||||
|
|
||||||
@@ -148,17 +152,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
throw new Error("You must include at least one entity");
|
throw new Error("You must include at least one entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
const configEntities = config.entities
|
this._entities = config.entities
|
||||||
? processConfigEntities(config.entities, false)
|
? processConfigEntities(config.entities, false)
|
||||||
: [];
|
: [];
|
||||||
|
this._entityIds = this._entities.map((ent) => ent.entity);
|
||||||
this._entities = [];
|
|
||||||
configEntities.forEach((entity) => {
|
|
||||||
this._entities.push(entity.entity);
|
|
||||||
if (entity.name) {
|
|
||||||
this._names[entity.entity] = entity.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof config.stat_types === "string") {
|
if (typeof config.stat_types === "string") {
|
||||||
this._statTypes = [config.stat_types];
|
this._statTypes = [config.stat_types];
|
||||||
@@ -168,6 +165,20 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._statTypes = config.stat_types;
|
this._statTypes = config.stat_types;
|
||||||
}
|
}
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _computeNames() {
|
||||||
|
if (!this.hass || !this._config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._names = {};
|
||||||
|
this._entities.forEach((config) => {
|
||||||
|
const stateObj = this.hass!.states[config.entity];
|
||||||
|
this._names[config.entity] =
|
||||||
|
computeLovelaceEntityName(this.hass!, stateObj, config.name) ||
|
||||||
|
config.entity;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
@@ -209,6 +220,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProps.has("hass")) {
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
changedProps.has("_config") &&
|
changedProps.has("_config") &&
|
||||||
oldConfig?.entities !== this._config.entities
|
oldConfig?.entities !== this._config.entities
|
||||||
@@ -232,7 +247,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
clearInterval(this._interval);
|
clearInterval(this._interval);
|
||||||
this._interval = 0; // block concurrent calls
|
this._interval = 0; // block concurrent calls
|
||||||
if (fetchMetadata) {
|
if (fetchMetadata) {
|
||||||
await this._getStatisticsMetaData(this._entities);
|
await this._getStatisticsMetaData(this._entityIds);
|
||||||
}
|
}
|
||||||
await this._getStatistics();
|
await this._getStatistics();
|
||||||
// statistics are created every hour
|
// statistics are created every hour
|
||||||
@@ -344,7 +359,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!unitClass && this._metadata) {
|
if (!unitClass && this._metadata) {
|
||||||
const metadata = this._metadata[this._entities[0]];
|
const metadata = this._metadata[this._entityIds[0]];
|
||||||
unitClass = metadata?.unit_class;
|
unitClass = metadata?.unit_class;
|
||||||
this._unit = unitClass
|
this._unit = unitClass
|
||||||
? getDisplayUnit(this.hass!, metadata.statistic_id, metadata) ||
|
? getDisplayUnit(this.hass!, metadata.statistic_id, metadata) ||
|
||||||
@@ -356,14 +371,15 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this.hass!,
|
this.hass!,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
this._entities,
|
this._entityIds,
|
||||||
this._period,
|
this._period,
|
||||||
unitconfig,
|
unitconfig,
|
||||||
this._statTypes
|
this._statTypes
|
||||||
);
|
);
|
||||||
|
|
||||||
this._statistics = {};
|
this._statistics = {};
|
||||||
this._entities.forEach((id) => {
|
this._entities.forEach((entity) => {
|
||||||
|
const id = entity.entity;
|
||||||
if (id in statistics) {
|
if (id in statistics) {
|
||||||
this._statistics![id] = statistics[id];
|
this._statistics![id] = statistics[id];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { EnergySourceByType } from "../../../data/energy";
|
|||||||
import type { ActionConfig } from "../../../data/lovelace/config/action";
|
import type { ActionConfig } from "../../../data/lovelace/config/action";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { Statistic, StatisticType } from "../../../data/recorder";
|
import type { Statistic, StatisticType } from "../../../data/recorder";
|
||||||
|
import type { MediaSelectorValue } from "../../../data/selector";
|
||||||
import type { TimeFormat } from "../../../data/translation";
|
import type { TimeFormat } from "../../../data/translation";
|
||||||
import type { ForecastType } from "../../../data/weather";
|
import type { ForecastType } from "../../../data/weather";
|
||||||
import type {
|
import type {
|
||||||
@@ -29,7 +30,6 @@ import type {
|
|||||||
import type { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
import type { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||||
import type { LovelaceHeadingBadgeConfig } from "../heading-badges/types";
|
import type { LovelaceHeadingBadgeConfig } from "../heading-badges/types";
|
||||||
import type { HomeSummary } from "../strategies/home/helpers/home-summaries";
|
import type { HomeSummary } from "../strategies/home/helpers/home-summaries";
|
||||||
import type { MediaSelectorValue } from "../../../data/selector";
|
|
||||||
|
|
||||||
export type AlarmPanelCardConfigState =
|
export type AlarmPanelCardConfigState =
|
||||||
| "arm_away"
|
| "arm_away"
|
||||||
@@ -347,7 +347,15 @@ export interface LogbookCardConfig extends LovelaceCardConfig {
|
|||||||
theme?: string;
|
theme?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GeoLocationSourceConfig {
|
export interface MapEntityConfig extends EntityConfig {
|
||||||
|
label_mode?: "state" | "attribute" | "name";
|
||||||
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
|
focus?: boolean;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GeoLocationSourceConfig {
|
||||||
source: string;
|
source: string;
|
||||||
label_mode?: "name" | "state" | "attribute" | "icon";
|
label_mode?: "name" | "state" | "attribute" | "icon";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
@@ -362,7 +370,7 @@ export interface MapCardConfig extends LovelaceCardConfig {
|
|||||||
auto_fit?: boolean;
|
auto_fit?: boolean;
|
||||||
fit_zones?: boolean;
|
fit_zones?: boolean;
|
||||||
default_zoom?: number;
|
default_zoom?: number;
|
||||||
entities?: (EntityConfig | string)[];
|
entities?: (MapEntityConfig | string)[];
|
||||||
hours_to_show?: number;
|
hours_to_show?: number;
|
||||||
geo_location_sources?: (GeoLocationSourceConfig | string)[];
|
geo_location_sources?: (GeoLocationSourceConfig | string)[];
|
||||||
dark_mode?: boolean;
|
dark_mode?: boolean;
|
||||||
@@ -434,7 +442,7 @@ export interface StatisticsGraphCardConfig extends EnergyCardBaseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface StatisticCardConfig extends LovelaceCardConfig {
|
export interface StatisticCardConfig extends LovelaceCardConfig {
|
||||||
name?: string;
|
name?: string | EntityNameItem | EntityNameItem[];
|
||||||
entities: (EntityConfig | string)[];
|
entities: (EntityConfig | string)[];
|
||||||
period:
|
period:
|
||||||
| {
|
| {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||||
import { SENSOR_ENTITIES, ASSIST_ENTITIES } from "../../../common/const";
|
import { ASSIST_ENTITIES, SENSOR_ENTITIES } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
@@ -14,12 +14,14 @@ import type {
|
|||||||
GridSourceTypeEnergyPreference,
|
GridSourceTypeEnergyPreference,
|
||||||
} from "../../../data/energy";
|
} from "../../../data/energy";
|
||||||
import { domainToName } from "../../../data/integration";
|
import { domainToName } from "../../../data/integration";
|
||||||
|
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
|
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||||
import { computeUserInitials } from "../../../data/user";
|
import { computeUserInitials } from "../../../data/user";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { HELPER_DOMAINS } from "../../config/helpers/const";
|
import { HELPER_DOMAINS } from "../../config/helpers/const";
|
||||||
|
import type { EntityBadgeConfig } from "../badges/types";
|
||||||
import type {
|
import type {
|
||||||
AlarmPanelCardConfig,
|
AlarmPanelCardConfig,
|
||||||
EntitiesCardConfig,
|
EntitiesCardConfig,
|
||||||
@@ -31,8 +33,7 @@ import type {
|
|||||||
} from "../cards/types";
|
} from "../cards/types";
|
||||||
import type { EntityConfig } from "../entity-rows/types";
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { ButtonsHeaderFooterConfig } from "../header-footer/types";
|
import type { ButtonsHeaderFooterConfig } from "../header-footer/types";
|
||||||
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
import { computeLovelaceEntityName } from "./entity/compute-lovelace-entity-name";
|
||||||
import type { EntityBadgeConfig } from "../badges/types";
|
|
||||||
|
|
||||||
const HIDE_DOMAIN = new Set([
|
const HIDE_DOMAIN = new Set([
|
||||||
"ai_task",
|
"ai_task",
|
||||||
@@ -125,13 +126,13 @@ export const computeSection = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const computeCards = (
|
export const computeCards = (
|
||||||
states: HassEntities,
|
hass: HomeAssistant,
|
||||||
entityIds: string[],
|
entityIds: string[],
|
||||||
entityCardOptions: Partial<EntitiesCardConfig>,
|
entityCardOptions: Partial<EntitiesCardConfig>,
|
||||||
renderFooterEntities = true
|
renderFooterEntities = true
|
||||||
): LovelaceCardConfig[] => {
|
): LovelaceCardConfig[] => {
|
||||||
const cards: LovelaceCardConfig[] = [];
|
const cards: LovelaceCardConfig[] = [];
|
||||||
|
const states = hass.states;
|
||||||
// For entity card
|
// For entity card
|
||||||
const entitiesConf: (string | EntityConfig)[] = [];
|
const entitiesConf: (string | EntityConfig)[] = [];
|
||||||
|
|
||||||
@@ -270,19 +271,23 @@ export const computeCards = (
|
|||||||
? states[a]
|
? states[a]
|
||||||
? computeStateName(states[a])
|
? computeStateName(states[a])
|
||||||
: ""
|
: ""
|
||||||
: a.name || "",
|
: states[a.entity]
|
||||||
|
? computeLovelaceEntityName(hass, states[a.entity], a.name)
|
||||||
|
: "",
|
||||||
typeof b === "string"
|
typeof b === "string"
|
||||||
? states[b]
|
? states[b]
|
||||||
? computeStateName(states[b])
|
? computeStateName(states[b])
|
||||||
: ""
|
: ""
|
||||||
: b.name || ""
|
: states[b.entity]
|
||||||
|
? computeLovelaceEntityName(hass, states[b.entity], b.name)
|
||||||
|
: ""
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we ended up with footer entities but no normal entities,
|
// If we ended up with footer entities but no normal entities,
|
||||||
// render the footer entities as normal entities.
|
// render the footer entities as normal entities.
|
||||||
if (entitiesConf.length === 0 && footerEntities.length > 0) {
|
if (entitiesConf.length === 0 && footerEntities.length > 0) {
|
||||||
return computeCards(states, entityIds, entityCardOptions, false);
|
return computeCards(hass, entityIds, entityCardOptions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entitiesConf.length > 0 || footerEntities.length > 0) {
|
if (entitiesConf.length > 0 || footerEntities.length > 0) {
|
||||||
@@ -360,14 +365,14 @@ const computeDefaultViewStates = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const generateViewConfig = (
|
export const generateViewConfig = (
|
||||||
localize: LocalizeFunc,
|
hass: HomeAssistant,
|
||||||
path: string,
|
path: string,
|
||||||
title: string | undefined,
|
title: string | undefined,
|
||||||
icon: string | undefined,
|
icon: string | undefined,
|
||||||
entities: HassEntities
|
entities: HassEntities
|
||||||
): LovelaceViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
const ungroupedEntitites: Record<string, string[]> = {};
|
const ungroupedEntitites: Record<string, string[]> = {};
|
||||||
|
const { localize } = hass;
|
||||||
// Organize ungrouped entities in ungrouped things
|
// Organize ungrouped entities in ungrouped things
|
||||||
for (const entityId of Object.keys(entities)) {
|
for (const entityId of Object.keys(entities)) {
|
||||||
const state = entities[entityId];
|
const state = entities[entityId];
|
||||||
@@ -470,7 +475,7 @@ export const generateViewConfig = (
|
|||||||
.forEach((domain) => {
|
.forEach((domain) => {
|
||||||
cards.push(
|
cards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
ungroupedEntitites[domain].sort((a, b) =>
|
ungroupedEntitites[domain].sort((a, b) =>
|
||||||
stringCompare(
|
stringCompare(
|
||||||
computeStateName(entities[a]),
|
computeStateName(entities[a]),
|
||||||
@@ -498,16 +503,17 @@ export const generateViewConfig = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const generateDefaultViewConfig = (
|
export const generateDefaultViewConfig = (
|
||||||
areaEntries: HomeAssistant["areas"],
|
hass: HomeAssistant,
|
||||||
deviceEntries: HomeAssistant["devices"],
|
|
||||||
entityEntries: HomeAssistant["entities"],
|
|
||||||
entities: HassEntities,
|
|
||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
energyPrefs?: EnergyPreferences,
|
energyPrefs?: EnergyPreferences,
|
||||||
areasPrefs?: AreasDisplayValue,
|
areasPrefs?: AreasDisplayValue,
|
||||||
hideEntitiesWithoutAreas?: boolean,
|
hideEntitiesWithoutAreas?: boolean,
|
||||||
hideEnergy?: boolean
|
hideEnergy?: boolean
|
||||||
): LovelaceViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
|
const entities = hass.states;
|
||||||
|
const areaEntries = hass.areas;
|
||||||
|
const deviceEntries = hass.devices;
|
||||||
|
const entityEntries = hass.entities;
|
||||||
const states = computeDefaultViewStates(entities, entityEntries);
|
const states = computeDefaultViewStates(entities, entityEntries);
|
||||||
const path = "default_view";
|
const path = "default_view";
|
||||||
const title = "Home";
|
const title = "Home";
|
||||||
@@ -549,7 +555,7 @@ export const generateDefaultViewConfig = (
|
|||||||
|
|
||||||
for (const groupEntity of splittedByGroups.groups) {
|
for (const groupEntity of splittedByGroups.groups) {
|
||||||
groupCards.push(
|
groupCards.push(
|
||||||
...computeCards(entities, groupEntity.attributes.entity_id, {
|
...computeCards(hass, groupEntity.attributes.entity_id, {
|
||||||
title: computeStateName(groupEntity),
|
title: computeStateName(groupEntity),
|
||||||
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
||||||
})
|
})
|
||||||
@@ -557,7 +563,7 @@ export const generateDefaultViewConfig = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = generateViewConfig(
|
const config = generateViewConfig(
|
||||||
localize,
|
hass,
|
||||||
path,
|
path,
|
||||||
title,
|
title,
|
||||||
icon,
|
icon,
|
||||||
@@ -575,7 +581,7 @@ export const generateDefaultViewConfig = (
|
|||||||
const area = areaEntries[areaId];
|
const area = areaEntries[areaId];
|
||||||
areaCards.push(
|
areaCards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
areaEntities.map((entity) => entity.entity_id),
|
areaEntities.map((entity) => entity.entity_id),
|
||||||
{
|
{
|
||||||
title: area.name,
|
title: area.name,
|
||||||
@@ -601,7 +607,7 @@ export const generateDefaultViewConfig = (
|
|||||||
const device = deviceEntries[deviceId];
|
const device = deviceEntries[deviceId];
|
||||||
deviceCards.push(
|
deviceCards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
deviceEntities.map((entity) => entity.entity_id),
|
deviceEntities.map((entity) => entity.entity_id),
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ export const coordinates = (
|
|||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
maxDetails: number,
|
maxDetails: number,
|
||||||
limits?: { minX?: number; maxX?: number; minY?: number; maxY?: number }
|
limits?: { minX?: number; maxX?: number; minY?: number; maxY?: number },
|
||||||
|
useMean = false
|
||||||
) => {
|
) => {
|
||||||
history = history.filter((item) => !Number.isNaN(item[1]));
|
history = history.filter((item) => !Number.isNaN(item[1]));
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ export const coordinates = (
|
|||||||
history,
|
history,
|
||||||
maxDetails,
|
maxDetails,
|
||||||
limits?.minX,
|
limits?.minX,
|
||||||
limits?.maxX
|
limits?.maxX,
|
||||||
|
useMean
|
||||||
);
|
);
|
||||||
return calcPoints(sampledData, width, height, limits);
|
return calcPoints(sampledData, width, height, limits);
|
||||||
};
|
};
|
||||||
@@ -69,7 +71,8 @@ export const coordinatesMinimalResponseCompressedState = (
|
|||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
maxDetails: number,
|
maxDetails: number,
|
||||||
limits?: { minX?: number; maxX?: number; minY?: number; maxY?: number }
|
limits?: { minX?: number; maxX?: number; minY?: number; maxY?: number },
|
||||||
|
useMean = false
|
||||||
) => {
|
) => {
|
||||||
if (!history?.length) {
|
if (!history?.length) {
|
||||||
return { points: [], yAxisOrigin: 0 };
|
return { points: [], yAxisOrigin: 0 };
|
||||||
@@ -81,5 +84,5 @@ export const coordinatesMinimalResponseCompressedState = (
|
|||||||
item.lu * 1000,
|
item.lu * 1000,
|
||||||
Number(item.s),
|
Number(item.s),
|
||||||
]);
|
]);
|
||||||
return coordinates(mappedHistory, width, height, maxDetails, limits);
|
return coordinates(mappedHistory, width, height, maxDetails, limits, useMean);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const handleAction = async (
|
|||||||
await hass.loadBackendTranslation("title");
|
await hass.loadBackendTranslation("title");
|
||||||
const localize = await hass.loadBackendTranslation("services");
|
const localize = await hass.loadBackendTranslation("services");
|
||||||
serviceName = `${domainToName(localize, domain)}: ${
|
serviceName = `${domainToName(localize, domain)}: ${
|
||||||
localize(`component.${domain}.services.${serviceName}.name`) ||
|
localize(`component.${domain}.services.${service}.name`) ||
|
||||||
serviceDomains[domain][service].name ||
|
serviceDomains[domain][service].name ||
|
||||||
service
|
service
|
||||||
}`;
|
}`;
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
||||||
import type { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
import type { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
||||||
|
|
||||||
|
interface BaseEntityConfig {
|
||||||
|
type: string;
|
||||||
|
entity: string;
|
||||||
|
}
|
||||||
export const processConfigEntities = <
|
export const processConfigEntities = <
|
||||||
T extends EntityConfig | LovelaceRowConfig,
|
T extends BaseEntityConfig | LovelaceRowConfig,
|
||||||
>(
|
>(
|
||||||
entities: (T | string)[],
|
entities: (T | string)[],
|
||||||
checkEntityId = true
|
checkEntityId = true
|
||||||
|
|||||||
@@ -39,30 +39,31 @@ export class HuiEntityEditor extends LitElement {
|
|||||||
private _renderItem(item: EntityConfig, index: number) {
|
private _renderItem(item: EntityConfig, index: number) {
|
||||||
const stateObj = this.hass.states[item.entity];
|
const stateObj = this.hass.states[item.entity];
|
||||||
|
|
||||||
const useDeviceName = entityUseDeviceName(
|
const useDeviceName =
|
||||||
stateObj,
|
stateObj &&
|
||||||
this.hass.entities,
|
entityUseDeviceName(stateObj, this.hass.entities, this.hass.devices);
|
||||||
this.hass.devices
|
|
||||||
);
|
|
||||||
|
|
||||||
const name = this.hass.formatEntityName(
|
|
||||||
stateObj,
|
|
||||||
useDeviceName ? { type: "device" } : { type: "entity" }
|
|
||||||
);
|
|
||||||
|
|
||||||
const isRTL = computeRTL(this.hass);
|
const isRTL = computeRTL(this.hass);
|
||||||
|
|
||||||
const primary = item.name || name || item.entity;
|
const primary =
|
||||||
|
(stateObj &&
|
||||||
|
this.hass.formatEntityName(
|
||||||
|
stateObj,
|
||||||
|
useDeviceName ? { type: "device" } : { type: "entity" }
|
||||||
|
)) ||
|
||||||
|
item.entity;
|
||||||
|
|
||||||
const secondary = this.hass.formatEntityName(
|
const secondary =
|
||||||
stateObj,
|
stateObj &&
|
||||||
useDeviceName
|
this.hass.formatEntityName(
|
||||||
? [{ type: "area" }]
|
stateObj,
|
||||||
: [{ type: "area" }, { type: "device" }],
|
useDeviceName
|
||||||
{
|
? [{ type: "area" }]
|
||||||
separator: isRTL ? " ◂ " : " ▸ ",
|
: [{ type: "area" }, { type: "device" }],
|
||||||
}
|
{
|
||||||
);
|
separator: isRTL ? " ◂ " : " ▸ ",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-md-list-item class="item">
|
<ha-md-list-item class="item">
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ import { customElement, property } from "lit/decorators";
|
|||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { DOMAINS_INPUT_ROW } from "../../../common/const";
|
import { DOMAINS_INPUT_ROW } from "../../../common/const";
|
||||||
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { toggleAttribute } from "../../../common/dom/toggle_attribute";
|
import { toggleAttribute } from "../../../common/dom/toggle_attribute";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-relative-time";
|
import "../../../components/ha-relative-time";
|
||||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||||
import { createEntityNotFoundWarning } from "./hui-warning";
|
import { createEntityNotFoundWarning } from "./hui-warning";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
|
||||||
|
|
||||||
@customElement("hui-generic-entity-row")
|
@customElement("hui-generic-entity-row")
|
||||||
export class HuiGenericEntityRow extends LitElement {
|
export class HuiGenericEntityRow extends LitElement {
|
||||||
@@ -59,7 +59,11 @@ export class HuiGenericEntityRow extends LitElement {
|
|||||||
const pointer = hasAnyAction(this.config);
|
const pointer = hasAnyAction(this.config);
|
||||||
|
|
||||||
const hasSecondary = this.secondaryText || this.config.secondary_info;
|
const hasSecondary = this.secondaryText || this.config.secondary_info;
|
||||||
const name = this.config.name ?? computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass,
|
||||||
|
stateObj,
|
||||||
|
this.config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
@@ -87,7 +91,7 @@ export class HuiGenericEntityRow extends LitElement {
|
|||||||
class="info ${classMap({ "text-content": !hasSecondary })}"
|
class="info ${classMap({ "text-content": !hasSecondary })}"
|
||||||
.title=${name}
|
.title=${name}
|
||||||
>
|
>
|
||||||
${this.config.name || computeStateName(stateObj)}
|
${name}
|
||||||
${hasSecondary
|
${hasSecondary
|
||||||
? html`
|
? html`
|
||||||
<div class="secondary">
|
<div class="secondary">
|
||||||
|
|||||||
@@ -296,11 +296,7 @@ export class HuiCreateDialogCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _suggestCards(): void {
|
private _suggestCards(): void {
|
||||||
const cardConfig = computeCards(
|
const cardConfig = computeCards(this.hass, this._selectedEntities, {});
|
||||||
this.hass.states,
|
|
||||||
this._selectedEntities,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
let sectionOptions: Partial<LovelaceSectionConfig> = {};
|
let sectionOptions: Partial<LovelaceSectionConfig> = {};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import type { HomeAssistant } from "../../../../types";
|
|||||||
import { showSaveSuccessToast } from "../../../../util/toast-saved-success";
|
import { showSaveSuccessToast } from "../../../../util/toast-saved-success";
|
||||||
import "../../cards/hui-card";
|
import "../../cards/hui-card";
|
||||||
import "../../sections/hui-section";
|
import "../../sections/hui-section";
|
||||||
|
import { getViewType } from "../../views/get-view-type";
|
||||||
import { addCards, addSection } from "../config-util";
|
import { addCards, addSection } from "../config-util";
|
||||||
import type { LovelaceContainerPath } from "../lovelace-path";
|
import type { LovelaceContainerPath } from "../lovelace-path";
|
||||||
import { parseLovelaceContainerPath } from "../lovelace-path";
|
import { parseLovelaceContainerPath } from "../lovelace-path";
|
||||||
@@ -66,7 +67,9 @@ export class HuiDialogSuggestCard extends LitElement {
|
|||||||
const { viewIndex } = parseLovelaceContainerPath(this._params.path);
|
const { viewIndex } = parseLovelaceContainerPath(this._params.path);
|
||||||
const viewConfig = this._params!.lovelaceConfig.views[viewIndex];
|
const viewConfig = this._params!.lovelaceConfig.views[viewIndex];
|
||||||
|
|
||||||
return !isStrategyView(viewConfig) && viewConfig.type === "sections";
|
return (
|
||||||
|
!isStrategyView(viewConfig) && getViewType(viewConfig) === "sections"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderPreview() {
|
private _renderPreview() {
|
||||||
|
|||||||
@@ -46,20 +46,18 @@ export class HuiGenericEntityRowEditor
|
|||||||
return [
|
return [
|
||||||
{ name: "entity", required: true, selector: { entity: {} } },
|
{ name: "entity", required: true, selector: { entity: {} } },
|
||||||
{
|
{
|
||||||
type: "grid",
|
name: "name",
|
||||||
name: "",
|
selector: { entity_name: {} },
|
||||||
schema: [
|
context: { entity: "entity" },
|
||||||
{ name: "name", selector: { text: {} } },
|
},
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
icon: {},
|
icon: {},
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
icon_entity: "entity",
|
icon_entity: "entity",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secondary_info",
|
name: "secondary_info",
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import "../hui-sub-element-editor";
|
|
||||||
import type { EditDetailElementEvent, SubElementEditorConfig } from "../types";
|
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
import type { ConfigEntity, GlanceCardConfig } from "../../cards/types";
|
import type { ConfigEntity, GlanceCardConfig } from "../../cards/types";
|
||||||
import "../../components/hui-entity-editor";
|
import "../../components/hui-entity-editor";
|
||||||
|
import type { EntityConfig } from "../../entity-rows/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
|
import "../hui-sub-element-editor";
|
||||||
import { processEditorEntities } from "../process-editor-entities";
|
import { processEditorEntities } from "../process-editor-entities";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import { entitiesConfigStruct } from "../structs/entities-struct";
|
import { entitiesConfigStruct } from "../structs/entities-struct";
|
||||||
import type { EntityConfig } from "../../entity-rows/types";
|
import type { EditDetailElementEvent, SubElementEditorConfig } from "../types";
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
@@ -42,11 +42,17 @@ const cardConfigStruct = assign(
|
|||||||
|
|
||||||
const SUB_SCHEMA = [
|
const SUB_SCHEMA = [
|
||||||
{ name: "entity", selector: { entity: {} }, required: true },
|
{ name: "entity", selector: { entity: {} }, required: true },
|
||||||
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: {
|
||||||
|
entity: "entity",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "grid",
|
type: "grid",
|
||||||
name: "",
|
name: "",
|
||||||
schema: [
|
schema: [
|
||||||
{ name: "name", selector: { text: {} } },
|
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
|
|||||||
@@ -45,7 +45,13 @@ const cardConfigStruct = assign(
|
|||||||
|
|
||||||
const SUB_SCHEMA = [
|
const SUB_SCHEMA = [
|
||||||
{ name: "entity", selector: { entity: {} }, required: true },
|
{ name: "entity", selector: { entity: {} }, required: true },
|
||||||
{ name: "name", selector: { text: {} } },
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: {
|
||||||
|
entity: "entity",
|
||||||
|
},
|
||||||
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@customElement("hui-history-graph-card-editor")
|
@customElement("hui-history-graph-card-editor")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { html, LitElement, nothing } from "lit";
|
import type { HassServiceTarget } from "home-assistant-js-websocket";
|
||||||
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import {
|
import {
|
||||||
array,
|
array,
|
||||||
@@ -9,21 +10,20 @@ import {
|
|||||||
optional,
|
optional,
|
||||||
string,
|
string,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import type { HassServiceTarget } from "home-assistant-js-websocket";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/entity/ha-entities-picker";
|
import "../../../../components/entity/ha-entities-picker";
|
||||||
import "../../../../components/ha-target-picker";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
|
import "../../../../components/ha-target-picker";
|
||||||
|
import type { HaEntityPickerEntityFilterFunc } from "../../../../data/entity";
|
||||||
import { filterLogbookCompatibleEntities } from "../../../../data/logbook";
|
import { filterLogbookCompatibleEntities } from "../../../../data/logbook";
|
||||||
|
import { targetStruct } from "../../../../data/script";
|
||||||
|
import { getSensorNumericDeviceClasses } from "../../../../data/sensor";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-logbook-card";
|
||||||
import type { LogbookCardConfig } from "../../cards/types";
|
import type { LogbookCardConfig } from "../../cards/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-logbook-card";
|
|
||||||
import { targetStruct } from "../../../../data/script";
|
|
||||||
import { getSensorNumericDeviceClasses } from "../../../../data/sensor";
|
|
||||||
import type { HaEntityPickerEntityFilterFunc } from "../../../../data/entity";
|
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
@@ -116,7 +116,6 @@ export class HuiLogbookCardEditor
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.entityFilter=${this._filterFunc}
|
.entityFilter=${this._filterFunc}
|
||||||
.value=${this._targetPicker}
|
.value=${this._targetPicker}
|
||||||
add-on-top
|
|
||||||
@value-changed=${this._entitiesChanged}
|
@value-changed=${this._entitiesChanged}
|
||||||
></ha-target-picker>
|
></ha-target-picker>
|
||||||
`;
|
`;
|
||||||
@@ -148,6 +147,13 @@ export class HuiLogbookCardEditor
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
ha-target-picker {
|
||||||
|
display: block;
|
||||||
|
margin-top: var(--ha-space-4);
|
||||||
|
}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { mdiPalette } from "@mdi/js";
|
|||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import {
|
import {
|
||||||
array,
|
array,
|
||||||
assert,
|
assert,
|
||||||
@@ -13,19 +14,19 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import memoizeOne from "memoize-one";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { hasLocation } from "../../../../common/entity/has_location";
|
|
||||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||||
|
import { hasLocation } from "../../../../common/entity/has_location";
|
||||||
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { SelectSelector } from "../../../../data/selector";
|
|
||||||
import "../../../../components/ha-formfield";
|
import "../../../../components/ha-formfield";
|
||||||
import "../../../../components/ha-switch";
|
|
||||||
import "../../../../components/ha-selector/ha-selector-select";
|
import "../../../../components/ha-selector/ha-selector-select";
|
||||||
|
import "../../../../components/ha-switch";
|
||||||
|
import type { SelectSelector } from "../../../../data/selector";
|
||||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||||
import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
|
import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
|
||||||
import type { MapCardConfig } from "../../cards/types";
|
import type { MapCardConfig, MapEntityConfig } from "../../cards/types";
|
||||||
import "../../components/hui-entity-editor";
|
import "../../components/hui-entity-editor";
|
||||||
import type { EntityConfig } from "../../entity-rows/types";
|
import type { EntityConfig } from "../../entity-rows/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
@@ -33,7 +34,6 @@ import { processEditorEntities } from "../process-editor-entities";
|
|||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import type { EntitiesEditorEvent } from "../types";
|
import type { EntitiesEditorEvent } from "../types";
|
||||||
import { configElementStyle } from "./config-elements-style";
|
import { configElementStyle } from "./config-elements-style";
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
|
||||||
|
|
||||||
export const mapEntitiesConfigStruct = union([
|
export const mapEntitiesConfigStruct = union([
|
||||||
object({
|
object({
|
||||||
@@ -223,7 +223,9 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
private _entitiesValueChanged(ev: EntitiesEditorEvent): void {
|
private _entitiesValueChanged(
|
||||||
|
ev: EntitiesEditorEvent<MapEntityConfig>
|
||||||
|
): void {
|
||||||
if (ev.detail && ev.detail.entities) {
|
if (ev.detail && ev.detail.entities) {
|
||||||
this._config = { ...this._config!, entities: ev.detail.entities };
|
this._config = { ...this._config!, entities: ev.detail.entities };
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ import type { StatisticCardConfig } from "../../cards/types";
|
|||||||
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
|
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
object({
|
object({
|
||||||
entity: optional(string()),
|
entity: optional(string()),
|
||||||
name: optional(string()),
|
name: optional(entityNameStruct),
|
||||||
icon: optional(string()),
|
icon: optional(string()),
|
||||||
unit: optional(string()),
|
unit: optional(string()),
|
||||||
stat_type: optional(string()),
|
stat_type: optional(string()),
|
||||||
@@ -144,11 +145,15 @@ export class HuiStatisticCardEditor
|
|||||||
}
|
}
|
||||||
: { object: {} },
|
: { object: {} },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: { entity: "entity" },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "grid",
|
type: "grid",
|
||||||
name: "",
|
name: "",
|
||||||
schema: [
|
schema: [
|
||||||
{ name: "name", selector: { text: {} } },
|
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import {
|
|||||||
actionConfigStruct,
|
actionConfigStruct,
|
||||||
actionConfigStructConfirmation,
|
actionConfigStructConfirmation,
|
||||||
} from "./action-struct";
|
} from "./action-struct";
|
||||||
|
import { entityNameStruct } from "./entity-name-struct";
|
||||||
|
|
||||||
export const entitiesConfigStruct = union([
|
export const entitiesConfigStruct = union([
|
||||||
object({
|
object({
|
||||||
entity: string(),
|
entity: string(),
|
||||||
name: optional(string()),
|
name: optional(entityNameStruct),
|
||||||
icon: optional(string()),
|
icon: optional(string()),
|
||||||
image: optional(string()),
|
image: optional(string()),
|
||||||
secondary_info: optional(string()),
|
secondary_info: optional(string()),
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ export interface ConfigError {
|
|||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntitiesEditorEvent extends CustomEvent {
|
export interface EntitiesEditorEvent<T extends EntityConfig = EntityConfig>
|
||||||
|
extends CustomEvent {
|
||||||
detail: {
|
detail: {
|
||||||
entities?: EntityConfig[];
|
entities?: T[];
|
||||||
item?: any;
|
item?: any;
|
||||||
};
|
};
|
||||||
target: EventTarget | null;
|
target: EventTarget | null;
|
||||||
|
|||||||
@@ -111,11 +111,7 @@ export class HuiUnusedEntities extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _addToLovelaceView(): void {
|
private _addToLovelaceView(): void {
|
||||||
const cardConfig = computeCards(
|
const cardConfig = computeCards(this.hass, this._selectedEntities, {});
|
||||||
this.hass.states,
|
|
||||||
this._selectedEntities,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const sectionConfig = computeSection(this._selectedEntities, {});
|
const sectionConfig = computeSection(this._selectedEntities, {});
|
||||||
|
|
||||||
if (this.lovelace.config.views.length === 1) {
|
if (this.lovelace.config.views.length === 1) {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import { format } from "date-fns";
|
||||||
import type { PropertyValues, TemplateResult } from "lit";
|
import type { PropertyValues, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../components/ha-date-input";
|
import "../../../components/ha-date-input";
|
||||||
import { format } from "date-fns";
|
import "../../../components/ha-time-input";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
|
||||||
import { setDateTimeValue } from "../../../data/datetime";
|
import { setDateTimeValue } from "../../../data/datetime";
|
||||||
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { EntityConfig, LovelaceRow } from "./types";
|
import type { EntityConfig, LovelaceRow } from "./types";
|
||||||
import "../../../components/ha-time-input";
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
|
|
||||||
@customElement("hui-datetime-entity-row")
|
@customElement("hui-datetime-entity-row")
|
||||||
class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -53,6 +53,12 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
const time = dateObj ? format(dateObj, "HH:mm:ss") : undefined;
|
const time = dateObj ? format(dateObj, "HH:mm:ss") : undefined;
|
||||||
const date = dateObj ? format(dateObj, "yyyy-MM-dd") : undefined;
|
const date = dateObj ? format(dateObj, "yyyy-MM-dd") : undefined;
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -61,7 +67,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<ha-date-input
|
<ha-date-input
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.locale=${this.hass.locale}
|
.locale=${this.hass.locale}
|
||||||
.value=${date}
|
.value=${date}
|
||||||
.disabled=${unavailable}
|
.disabled=${unavailable}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-date-input";
|
import "../../../components/ha-date-input";
|
||||||
import "../../../components/ha-time-input";
|
import "../../../components/ha-time-input";
|
||||||
import { isUnavailableState, UNKNOWN } from "../../../data/entity";
|
import { isUnavailableState, UNKNOWN } from "../../../data/entity";
|
||||||
@@ -10,6 +9,7 @@ import {
|
|||||||
stateToIsoDateString,
|
stateToIsoDateString,
|
||||||
} from "../../../data/input_datetime";
|
} from "../../../data/input_datetime";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -47,7 +47,11 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = this._config.name || computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { PropertyValues } from "lit";
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-list-item";
|
||||||
import "../../../components/ha-select";
|
import "../../../components/ha-select";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
@@ -11,6 +10,7 @@ import type { InputSelectEntity } from "../../../data/input_select";
|
|||||||
import { setInputSelectOption } from "../../../data/input_select";
|
import { setInputSelectOption } from "../../../data/input_select";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -51,6 +51,12 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -58,7 +64,7 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.options=${stateObj.attributes.options}
|
.options=${stateObj.attributes.options}
|
||||||
.disabled=${
|
.disabled=${
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import { setValue } from "../../../data/input_text";
|
import { setValue } from "../../../data/input_text";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -43,6 +43,12 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -50,7 +56,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.minlength=${stateObj.attributes.min}
|
.minlength=${stateObj.attributes.min}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { PropertyValues } from "lit";
|
|||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-list-item";
|
||||||
import "../../../components/ha-select";
|
import "../../../components/ha-select";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
@@ -11,6 +10,7 @@ import type { SelectEntity } from "../../../data/select";
|
|||||||
import { setSelectOption } from "../../../data/select";
|
import { setSelectOption } from "../../../data/select";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -51,6 +51,12 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -58,7 +64,7 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.options=${stateObj.attributes.options}
|
.options=${stateObj.attributes.options}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import type { TextEntity } from "../../../data/text";
|
import type { TextEntity } from "../../../data/text";
|
||||||
@@ -11,6 +10,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { EntityConfig, LovelaceRow } from "./types";
|
import type { EntityConfig, LovelaceRow } from "./types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
|
|
||||||
@customElement("hui-text-entity-row")
|
@customElement("hui-text-entity-row")
|
||||||
class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -46,6 +46,12 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -53,7 +59,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.minlength=${stateObj.attributes.min}
|
.minlength=${stateObj.attributes.min}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { LitElement, css, html, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import { isUnavailableState } from "../../../data/entity";
|
import { isUnavailableState } from "../../../data/entity";
|
||||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||||
import type { ForecastEvent, WeatherEntity } from "../../../data/weather";
|
import type { ForecastEvent, WeatherEntity } from "../../../data/weather";
|
||||||
@@ -24,6 +23,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { LovelaceRow } from "./types";
|
import type { LovelaceRow } from "./types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
|
|
||||||
@customElement("hui-weather-entity-row")
|
@customElement("hui-weather-entity-row")
|
||||||
class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -119,6 +119,12 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
|||||||
const forecastData = getForecast(stateObj.attributes, this._forecastEvent);
|
const forecastData = getForecast(stateObj.attributes, this._forecastEvent);
|
||||||
const forecast = forecastData?.forecast;
|
const forecast = forecastData?.forecast;
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="icon-image ${classMap({
|
class="icon-image ${classMap({
|
||||||
@@ -155,7 +161,7 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${this._config.name || computeStateName(stateObj)}
|
${name}
|
||||||
${hasSecondary
|
${hasSecondary
|
||||||
? html`
|
? html`
|
||||||
<div class="secondary">
|
<div class="secondary">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { EntityNameItem } from "../../../common/entity/compute_entity_name_display";
|
||||||
import type {
|
import type {
|
||||||
ActionConfig,
|
ActionConfig,
|
||||||
ConfirmationRestrictionConfig,
|
ConfirmationRestrictionConfig,
|
||||||
@@ -10,7 +11,7 @@ import type { TimestampRenderingFormat } from "../components/types";
|
|||||||
export interface EntityConfig {
|
export interface EntityConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
name?: string;
|
name?: string | EntityNameItem | EntityNameItem[];
|
||||||
icon?: string;
|
icon?: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,16 +155,20 @@ export class HuiGraphHeaderFooter
|
|||||||
}
|
}
|
||||||
const width = this.clientWidth || this.offsetWidth;
|
const width = this.clientWidth || this.offsetWidth;
|
||||||
// sample to 1 point per hour or 1 point per 5 pixels
|
// sample to 1 point per hour or 1 point per 5 pixels
|
||||||
const maxDetails =
|
const maxDetails = Math.max(
|
||||||
|
10,
|
||||||
this._config.detail! > 1
|
this._config.detail! > 1
|
||||||
? Math.max(width / 5, this._config.hours_to_show!)
|
? Math.max(width / 5, this._config.hours_to_show!)
|
||||||
: this._config.hours_to_show!;
|
: this._config.hours_to_show!
|
||||||
|
);
|
||||||
|
const useMean = this._config.detail !== 2;
|
||||||
const { points } = coordinatesMinimalResponseCompressedState(
|
const { points } = coordinatesMinimalResponseCompressedState(
|
||||||
combinedHistory[this._config.entity],
|
combinedHistory[this._config.entity],
|
||||||
width,
|
width,
|
||||||
width / 5,
|
width / 5,
|
||||||
maxDetails,
|
maxDetails,
|
||||||
{ minY: this._config.limits?.min, maxY: this._config.limits?.max }
|
{ minY: this._config.limits?.min, maxY: this._config.limits?.max },
|
||||||
|
useMean
|
||||||
);
|
);
|
||||||
this._coordinates = points;
|
this._coordinates = points;
|
||||||
},
|
},
|
||||||
@@ -218,6 +222,9 @@ export class HuiGraphHeaderFooter
|
|||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
ha-spinner {
|
ha-spinner {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(50% - 14px);
|
top: calc(50% - 14px);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user