mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 18:39:40 +00:00
Compare commits
164 Commits
copilot/al
...
refactor-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c95409ebd | ||
|
|
01a86b313a | ||
|
|
b2ec4b7d2c | ||
|
|
b4c83d7877 | ||
|
|
22c53b6859 | ||
|
|
750b1e5e16 | ||
|
|
5801ce944c | ||
|
|
79ad9dbf44 | ||
|
|
9814533d47 | ||
|
|
bdb6c684c0 | ||
|
|
0046167f5c | ||
|
|
5266f0d761 | ||
|
|
cc5c0d04c4 | ||
|
|
7f3d5f557f | ||
|
|
9b48cd7737 | ||
|
|
11c6f6ec78 | ||
|
|
cb0f59b26d | ||
|
|
c89fc35578 | ||
|
|
f03cd9c239 | ||
|
|
19a4e37933 | ||
|
|
76514babd5 | ||
|
|
b6abbdafb8 | ||
|
|
d35e6c0092 | ||
|
|
5c2ee54dec | ||
|
|
1dfca76c81 | ||
|
|
fd7f028fbf | ||
|
|
3f7283b1af | ||
|
|
d35323ac52 | ||
|
|
06475382e8 | ||
|
|
b60dd7f15d | ||
|
|
b77e65fabd | ||
|
|
cea691a04e | ||
|
|
50df2a34cd | ||
|
|
e6c0a84994 | ||
|
|
b03fa4bdc5 | ||
|
|
058cecc124 | ||
|
|
a5f058a7eb | ||
|
|
655c2ff3c2 | ||
|
|
e1b0a3e737 | ||
|
|
d59d436080 | ||
|
|
0fe0bf12f2 | ||
|
|
f5a3877f47 | ||
|
|
31d04f5338 | ||
|
|
4f7d223aa7 | ||
|
|
484c60073d | ||
|
|
0e1ab1a60c | ||
|
|
cef11e0c18 | ||
|
|
55e75e80d2 | ||
|
|
126a78ec8a | ||
|
|
063af39f0f | ||
|
|
132c4c8201 | ||
|
|
4c08e960f1 | ||
|
|
a8020256de | ||
|
|
2ea57c33ae | ||
|
|
db1408666c | ||
|
|
260288a061 | ||
|
|
45fd685913 | ||
|
|
896d76b218 | ||
|
|
cec24117dc | ||
|
|
34006d268b | ||
|
|
54c03d91df | ||
|
|
52a56a1c4e | ||
|
|
e49feeb4aa | ||
|
|
a0c30e433a | ||
|
|
354ce027eb | ||
|
|
5c224a942d | ||
|
|
0efa4f81d4 | ||
|
|
3ad2f35f29 | ||
|
|
7a21d5f7bc | ||
|
|
33226587e6 | ||
|
|
bd2673f311 | ||
|
|
cecadde497 | ||
|
|
494b8811d0 | ||
|
|
4e0a49b3da | ||
|
|
3145fed5dc | ||
|
|
3dd040fdc7 | ||
|
|
e3abe9736c | ||
|
|
fe41e72774 | ||
|
|
7078ef52d4 | ||
|
|
f1c9802ee3 | ||
|
|
35697e3f94 | ||
|
|
8ea7ad3026 | ||
|
|
73747fbedc | ||
|
|
aaa92bd354 | ||
|
|
5f75fc5bcb | ||
|
|
5fa44548c3 | ||
|
|
1945c11621 | ||
|
|
930575d292 | ||
|
|
0147dbab00 | ||
|
|
13ace24b83 | ||
|
|
616333591a | ||
|
|
8f5875c30f | ||
|
|
517cd49f35 | ||
|
|
25d9fc94b2 | ||
|
|
7b188759e3 | ||
|
|
76772d1098 | ||
|
|
6052745ca0 | ||
|
|
89b9780345 | ||
|
|
a607edca96 | ||
|
|
52eb3d8063 | ||
|
|
3e749ec085 | ||
|
|
ee2ec00069 | ||
|
|
0aa2941868 | ||
|
|
46cd1d5156 | ||
|
|
07a5c41fd4 | ||
|
|
4ad3c553d5 | ||
|
|
d40cc448a5 | ||
|
|
e2f3f9d348 | ||
|
|
98d44950f8 | ||
|
|
8ae9edb1ef | ||
|
|
84c4396c13 | ||
|
|
2b937a30e3 | ||
|
|
b7815bfd86 | ||
|
|
d94fa03411 | ||
|
|
0a7007ef9e | ||
|
|
dd12136dee | ||
|
|
6e2f89fe3d | ||
|
|
092085b9af | ||
|
|
1c06eb8661 | ||
|
|
c7e87b06b5 | ||
|
|
38c738c199 | ||
|
|
e899587307 | ||
|
|
c9feb0b75f | ||
|
|
10718c35d1 | ||
|
|
4dc6a37bad | ||
|
|
ac49fc7aba | ||
|
|
e4f008800b | ||
|
|
0b0ffd7bab | ||
|
|
dfa77526a2 | ||
|
|
9a3bd6c613 | ||
|
|
1161de5746 | ||
|
|
9df8e20391 | ||
|
|
11047a9c95 | ||
|
|
18fa66f61c | ||
|
|
758a048f34 | ||
|
|
ee0fc360b0 | ||
|
|
4012f95ec1 | ||
|
|
0336ce4606 | ||
|
|
9ba36ab7e2 | ||
|
|
fe7a08a1b0 | ||
|
|
87a8f9cedc | ||
|
|
01df7e20ca | ||
|
|
d181219522 | ||
|
|
6ae24b8135 | ||
|
|
8e009f24f9 | ||
|
|
53031f44ac | ||
|
|
af5a988457 | ||
|
|
bab0391a19 | ||
|
|
444123c47e | ||
|
|
f123d34046 | ||
|
|
1b40f99f68 | ||
|
|
b314b3ed2b | ||
|
|
59b8932969 | ||
|
|
107af753ec | ||
|
|
1f0acb3046 | ||
|
|
431e533929 | ||
|
|
02c845cbc6 | ||
|
|
628111ed20 | ||
|
|
e825a9c02f | ||
|
|
7a35bddf36 | ||
|
|
ad69270af8 | ||
|
|
404edf9483 | ||
|
|
a166b4e9b6 | ||
|
|
7a285f11db |
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -36,14 +36,14 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
|
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
|
uses: github/codeql-action/autobuild@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -57,4 +57,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
|
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
41
package.json
41
package.json
@@ -52,7 +52,7 @@
|
|||||||
"@fullcalendar/list": "6.1.19",
|
"@fullcalendar/list": "6.1.19",
|
||||||
"@fullcalendar/luxon3": "6.1.19",
|
"@fullcalendar/luxon3": "6.1.19",
|
||||||
"@fullcalendar/timegrid": "6.1.19",
|
"@fullcalendar/timegrid": "6.1.19",
|
||||||
"@home-assistant/webawesome": "3.0.0-beta.6.ha.6",
|
"@home-assistant/webawesome": "3.0.0-beta.6.ha.7",
|
||||||
"@lezer/highlight": "1.2.3",
|
"@lezer/highlight": "1.2.3",
|
||||||
"@lit-labs/motion": "1.0.9",
|
"@lit-labs/motion": "1.0.9",
|
||||||
"@lit-labs/observers": "2.0.6",
|
"@lit-labs/observers": "2.0.6",
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
"@material/mwc-top-app-bar": "0.27.0",
|
"@material/mwc-top-app-bar": "0.27.0",
|
||||||
"@material/mwc-top-app-bar-fixed": "0.27.0",
|
"@material/mwc-top-app-bar-fixed": "0.27.0",
|
||||||
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
||||||
"@material/web": "2.4.0",
|
"@material/web": "2.4.1",
|
||||||
"@mdi/js": "7.4.47",
|
"@mdi/js": "7.4.47",
|
||||||
"@mdi/svg": "7.4.47",
|
"@mdi/svg": "7.4.47",
|
||||||
"@replit/codemirror-indentation-markers": "6.5.3",
|
"@replit/codemirror-indentation-markers": "6.5.3",
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
"@thomasloven/round-slider": "0.6.0",
|
"@thomasloven/round-slider": "0.6.0",
|
||||||
"@tsparticles/engine": "3.9.1",
|
"@tsparticles/engine": "3.9.1",
|
||||||
"@tsparticles/preset-links": "3.2.0",
|
"@tsparticles/preset-links": "3.2.0",
|
||||||
"@vaadin/combo-box": "24.9.2",
|
"@vaadin/combo-box": "24.9.4",
|
||||||
"@vaadin/vaadin-themable-mixin": "24.9.2",
|
"@vaadin/vaadin-themable-mixin": "24.9.4",
|
||||||
"@vibrant/color": "4.0.0",
|
"@vibrant/color": "4.0.0",
|
||||||
"@vue/web-component-wrapper": "1.3.0",
|
"@vue/web-component-wrapper": "1.3.0",
|
||||||
"@webcomponents/scoped-custom-element-registry": "0.0.10",
|
"@webcomponents/scoped-custom-element-registry": "0.0.10",
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
"fuse.js": "7.1.0",
|
"fuse.js": "7.1.0",
|
||||||
"google-timezones-json": "1.2.0",
|
"google-timezones-json": "1.2.0",
|
||||||
"gulp-zopfli-green": "6.0.2",
|
"gulp-zopfli-green": "6.0.2",
|
||||||
"hls.js": "1.6.13",
|
"hls.js": "1.6.14",
|
||||||
"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",
|
||||||
@@ -152,13 +152,13 @@
|
|||||||
"@babel/helper-define-polyfill-provider": "0.6.5",
|
"@babel/helper-define-polyfill-provider": "0.6.5",
|
||||||
"@babel/plugin-transform-runtime": "7.28.5",
|
"@babel/plugin-transform-runtime": "7.28.5",
|
||||||
"@babel/preset-env": "7.28.5",
|
"@babel/preset-env": "7.28.5",
|
||||||
"@bundle-stats/plugin-webpack-filter": "4.21.5",
|
"@bundle-stats/plugin-webpack-filter": "4.21.6",
|
||||||
"@lokalise/node-api": "15.3.1",
|
"@lokalise/node-api": "15.3.1",
|
||||||
"@octokit/auth-oauth-device": "8.0.2",
|
"@octokit/auth-oauth-device": "8.0.3",
|
||||||
"@octokit/plugin-retry": "8.0.2",
|
"@octokit/plugin-retry": "8.0.3",
|
||||||
"@octokit/rest": "22.0.0",
|
"@octokit/rest": "22.0.1",
|
||||||
"@rsdoctor/rspack-plugin": "1.3.4",
|
"@rsdoctor/rspack-plugin": "1.3.7",
|
||||||
"@rspack/core": "1.5.8",
|
"@rspack/core": "1.6.0",
|
||||||
"@rspack/dev-server": "1.1.4",
|
"@rspack/dev-server": "1.1.4",
|
||||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||||
"@types/chromecast-caf-receiver": "6.0.22",
|
"@types/chromecast-caf-receiver": "6.0.22",
|
||||||
@@ -178,12 +178,12 @@
|
|||||||
"@types/tar": "6.1.13",
|
"@types/tar": "6.1.13",
|
||||||
"@types/ua-parser-js": "0.7.39",
|
"@types/ua-parser-js": "0.7.39",
|
||||||
"@types/webspeechapi": "0.0.29",
|
"@types/webspeechapi": "0.0.29",
|
||||||
"@vitest/coverage-v8": "4.0.3",
|
"@vitest/coverage-v8": "4.0.6",
|
||||||
"babel-loader": "10.0.0",
|
"babel-loader": "10.0.0",
|
||||||
"babel-plugin-template-html-minifier": "4.1.0",
|
"babel-plugin-template-html-minifier": "4.1.0",
|
||||||
"browserslist-useragent-regexp": "4.1.3",
|
"browserslist-useragent-regexp": "4.1.3",
|
||||||
"del": "8.0.1",
|
"del": "8.0.1",
|
||||||
"eslint": "9.38.0",
|
"eslint": "9.39.1",
|
||||||
"eslint-config-airbnb-base": "15.0.0",
|
"eslint-config-airbnb-base": "15.0.0",
|
||||||
"eslint-config-prettier": "10.1.8",
|
"eslint-config-prettier": "10.1.8",
|
||||||
"eslint-import-resolver-webpack": "0.13.10",
|
"eslint-import-resolver-webpack": "0.13.10",
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
"gulp-rename": "2.1.0",
|
"gulp-rename": "2.1.0",
|
||||||
"html-minifier-terser": "7.2.0",
|
"html-minifier-terser": "7.2.0",
|
||||||
"husky": "9.1.7",
|
"husky": "9.1.7",
|
||||||
"jsdom": "27.0.1",
|
"jsdom": "27.1.0",
|
||||||
"jszip": "3.10.1",
|
"jszip": "3.10.1",
|
||||||
"lint-staged": "16.2.6",
|
"lint-staged": "16.2.6",
|
||||||
"lit-analyzer": "2.0.3",
|
"lit-analyzer": "2.0.3",
|
||||||
@@ -213,13 +213,13 @@
|
|||||||
"rspack-manifest-plugin": "5.1.0",
|
"rspack-manifest-plugin": "5.1.0",
|
||||||
"serve": "14.2.5",
|
"serve": "14.2.5",
|
||||||
"sinon": "21.0.0",
|
"sinon": "21.0.0",
|
||||||
"tar": "7.5.1",
|
"tar": "7.5.2",
|
||||||
"terser-webpack-plugin": "5.3.14",
|
"terser-webpack-plugin": "5.3.14",
|
||||||
"ts-lit-plugin": "2.0.2",
|
"ts-lit-plugin": "2.0.2",
|
||||||
"typescript": "5.9.3",
|
"typescript": "5.9.3",
|
||||||
"typescript-eslint": "8.46.2",
|
"typescript-eslint": "8.46.3",
|
||||||
"vite-tsconfig-paths": "5.1.4",
|
"vite-tsconfig-paths": "5.1.4",
|
||||||
"vitest": "4.0.3",
|
"vitest": "4.0.6",
|
||||||
"webpack-stats-plugin": "1.1.3",
|
"webpack-stats-plugin": "1.1.3",
|
||||||
"webpackbar": "7.0.0",
|
"webpackbar": "7.0.0",
|
||||||
"workbox-build": "patch:workbox-build@npm%3A7.1.1#~/.yarn/patches/workbox-build-npm-7.1.1-a854f3faae.patch"
|
"workbox-build": "patch:workbox-build@npm%3A7.1.1#~/.yarn/patches/workbox-build-npm-7.1.1-a854f3faae.patch"
|
||||||
@@ -231,9 +231,12 @@
|
|||||||
"clean-css": "5.3.3",
|
"clean-css": "5.3.3",
|
||||||
"@lit/reactive-element": "2.1.1",
|
"@lit/reactive-element": "2.1.1",
|
||||||
"@fullcalendar/daygrid": "6.1.19",
|
"@fullcalendar/daygrid": "6.1.19",
|
||||||
"globals": "16.4.0",
|
"globals": "16.5.0",
|
||||||
"tslib": "2.8.1",
|
"tslib": "2.8.1",
|
||||||
"@material/mwc-list@^0.27.0": "patch:@material/mwc-list@npm%3A0.27.0#~/.yarn/patches/@material-mwc-list-npm-0.27.0-5344fc9de4.patch"
|
"@material/mwc-list@^0.27.0": "patch:@material/mwc-list@npm%3A0.27.0#~/.yarn/patches/@material-mwc-list-npm-0.27.0-5344fc9de4.patch"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.10.3"
|
"packageManager": "yarn@4.10.3",
|
||||||
|
"volta": {
|
||||||
|
"node": "22.21.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20250924.0"
|
version = "20251029.0"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
license-files = ["LICENSE*"]
|
license-files = ["LICENSE*"]
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
|
|||||||
@@ -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>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/common/condition/extract.ts
Normal file
16
src/common/condition/extract.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import type { Condition } from "../../panels/lovelace/common/validate-condition";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract media queries from conditions recursively
|
||||||
|
*/
|
||||||
|
export function extractMediaQueries(conditions: Condition[]): string[] {
|
||||||
|
return conditions.reduce<string[]>((array, c) => {
|
||||||
|
if ("conditions" in c && c.conditions) {
|
||||||
|
array.push(...extractMediaQueries(c.conditions));
|
||||||
|
}
|
||||||
|
if (c.condition === "screen" && c.media_query) {
|
||||||
|
array.push(c.media_query);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
37
src/common/condition/listeners.ts
Normal file
37
src/common/condition/listeners.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { listenMediaQuery } from "../dom/media_query";
|
||||||
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import type { Condition } from "../../panels/lovelace/common/validate-condition";
|
||||||
|
import { checkConditionsMet } from "../../panels/lovelace/common/validate-condition";
|
||||||
|
import { extractMediaQueries } from "./extract";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to setup media query listeners for conditional visibility
|
||||||
|
*/
|
||||||
|
export function setupMediaQueryListeners(
|
||||||
|
conditions: Condition[],
|
||||||
|
hass: HomeAssistant,
|
||||||
|
addListener: (unsub: () => void) => void,
|
||||||
|
onUpdate: (conditionsMet: boolean) => void
|
||||||
|
): void {
|
||||||
|
const mediaQueries = extractMediaQueries(conditions);
|
||||||
|
|
||||||
|
if (mediaQueries.length === 0) return;
|
||||||
|
|
||||||
|
// Optimization for single media query
|
||||||
|
const hasOnlyMediaQuery =
|
||||||
|
conditions.length === 1 &&
|
||||||
|
conditions[0].condition === "screen" &&
|
||||||
|
!!conditions[0].media_query;
|
||||||
|
|
||||||
|
mediaQueries.forEach((mediaQuery) => {
|
||||||
|
const unsub = listenMediaQuery(mediaQuery, (matches) => {
|
||||||
|
if (hasOnlyMediaQuery) {
|
||||||
|
onUpdate(matches);
|
||||||
|
} else {
|
||||||
|
const conditionsMet = checkConditionsMet(conditions, hass);
|
||||||
|
onUpdate(conditionsMet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addListener(unsub);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -90,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: () => {
|
||||||
@@ -205,6 +207,16 @@ export class HaChartBase extends LitElement {
|
|||||||
}
|
}
|
||||||
if (changedProps.has("options")) {
|
if (changedProps.has("options")) {
|
||||||
chartOptions = { ...chartOptions, ...this._createOptions() };
|
chartOptions = { ...chartOptions, ...this._createOptions() };
|
||||||
|
if (
|
||||||
|
this._compareCustomLegendOptions(
|
||||||
|
changedProps.get("options"),
|
||||||
|
this.options
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// custom legend changes may require a resize to layout properly
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
@@ -296,7 +308,7 @@ export class HaChartBase extends LitElement {
|
|||||||
itemStyle = {
|
itemStyle = {
|
||||||
color: dataset?.color as string,
|
color: dataset?.color as string,
|
||||||
...(dataset?.itemStyle as { borderColor?: string }),
|
...(dataset?.itemStyle as { borderColor?: string }),
|
||||||
itemStyle,
|
...itemStyle,
|
||||||
};
|
};
|
||||||
const color = itemStyle?.color as string;
|
const color = itemStyle?.color as string;
|
||||||
const borderColor = itemStyle?.borderColor as string;
|
const borderColor = itemStyle?.borderColor as string;
|
||||||
@@ -508,6 +520,7 @@ export class HaChartBase extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.requestUpdate("_hiddenDatasets");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getDataZoomConfig(): DataZoomComponentOption | undefined {
|
private _getDataZoomConfig(): DataZoomComponentOption | undefined {
|
||||||
@@ -641,6 +654,13 @@ export class HaChartBase extends LitElement {
|
|||||||
textBorderWidth: 2,
|
textBorderWidth: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
pie: {
|
||||||
|
label: {
|
||||||
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
|
textBorderColor: style.getPropertyValue("--primary-background-color"),
|
||||||
|
textBorderWidth: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
sankey: {
|
sankey: {
|
||||||
label: {
|
label: {
|
||||||
color: style.getPropertyValue("--primary-text-color"),
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
@@ -958,11 +978,34 @@ export class HaChartBase extends LitElement {
|
|||||||
|
|
||||||
private _handleChartRenderFinished = () => {
|
private _handleChartRenderFinished = () => {
|
||||||
if (this._shouldResizeChart) {
|
if (this._shouldResizeChart) {
|
||||||
this.chart?.resize();
|
this.chart?.resize({
|
||||||
|
animation:
|
||||||
|
this._reducedMotion ||
|
||||||
|
typeof this._resizeAnimationDuration !== "number"
|
||||||
|
? undefined
|
||||||
|
: { duration: this._resizeAnimationDuration },
|
||||||
|
});
|
||||||
this._shouldResizeChart = false;
|
this._shouldResizeChart = false;
|
||||||
|
this._resizeAnimationDuration = undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _compareCustomLegendOptions(
|
||||||
|
oldOptions: ECOption | undefined,
|
||||||
|
newOptions: ECOption | undefined
|
||||||
|
): boolean {
|
||||||
|
const oldLegends = ensureArray(
|
||||||
|
oldOptions?.legend || []
|
||||||
|
) as LegendComponentOption[];
|
||||||
|
const newLegends = ensureArray(
|
||||||
|
newOptions?.legend || []
|
||||||
|
) as LegendComponentOption[];
|
||||||
|
return (
|
||||||
|
oldLegends.some((l) => l.show && l.type === "custom") !==
|
||||||
|
newLegends.some((l) => l.show && l.type === "custom")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import type { EChartsType } from "echarts/core";
|
|||||||
import type { GraphSeriesOption } from "echarts/charts";
|
import type { GraphSeriesOption } from "echarts/charts";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state, query } from "lit/decorators";
|
import { customElement, property, state, query } from "lit/decorators";
|
||||||
import type { TopLevelFormatterParams } from "echarts/types/dist/shared";
|
import type {
|
||||||
|
CallbackDataParams,
|
||||||
|
TopLevelFormatterParams,
|
||||||
|
} from "echarts/types/dist/shared";
|
||||||
import { mdiFormatTextVariant, mdiGoogleCirclesGroup } from "@mdi/js";
|
import { mdiFormatTextVariant, mdiGoogleCirclesGroup } from "@mdi/js";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { listenMediaQuery } from "../../common/dom/media_query";
|
import { listenMediaQuery } from "../../common/dom/media_query";
|
||||||
@@ -16,6 +19,7 @@ import { deepEqual } from "../../common/util/deep-equal";
|
|||||||
export interface NetworkNode {
|
export interface NetworkNode {
|
||||||
id: string;
|
id: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
context?: string;
|
||||||
category?: number;
|
category?: number;
|
||||||
value?: number;
|
value?: number;
|
||||||
symbolSize?: number;
|
symbolSize?: number;
|
||||||
@@ -188,6 +192,25 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
|||||||
label: {
|
label: {
|
||||||
show: showLabels,
|
show: showLabels,
|
||||||
position: "right",
|
position: "right",
|
||||||
|
formatter: (params: CallbackDataParams) => {
|
||||||
|
const node = params.data as NetworkNode;
|
||||||
|
if (node.context) {
|
||||||
|
return `{primary|${node.name ?? ""}}\n{secondary|${node.context}}`;
|
||||||
|
}
|
||||||
|
return node.name ?? "";
|
||||||
|
},
|
||||||
|
rich: {
|
||||||
|
primary: {
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: getComputedStyle(document.body).getPropertyValue(
|
||||||
|
"--secondary-text-color"
|
||||||
|
),
|
||||||
|
lineHeight: 16,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
emphasis: {
|
emphasis: {
|
||||||
focus: isMobile ? "none" : "adjacency",
|
focus: isMobile ? "none" : "adjacency",
|
||||||
@@ -225,6 +248,7 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
|||||||
({
|
({
|
||||||
id: node.id,
|
id: node.id,
|
||||||
name: node.name,
|
name: node.name,
|
||||||
|
context: node.context,
|
||||||
category: node.category,
|
category: node.category,
|
||||||
value: node.value,
|
value: node.value,
|
||||||
symbolSize: node.symbolSize || 30,
|
symbolSize: node.symbolSize || 30,
|
||||||
|
|||||||
@@ -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>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ export class HaEntityNamePicker extends LitElement {
|
|||||||
private _toValue = memoizeOne(
|
private _toValue = memoizeOne(
|
||||||
(items: EntityNameItem[]): typeof this.value => {
|
(items: EntityNameItem[]): typeof this.value => {
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
return "";
|
return undefined;
|
||||||
}
|
}
|
||||||
if (items.length === 1) {
|
if (items.length === 1) {
|
||||||
const item = items[0];
|
const item = items[0];
|
||||||
|
|||||||
@@ -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%;
|
||||||
|
|||||||
@@ -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 [
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import "@home-assistant/webawesome/dist/components/dialog/dialog";
|
import { css, html, LitElement } from "lit";
|
||||||
import { mdiClose } from "@mdi/js";
|
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
eventOptions,
|
eventOptions,
|
||||||
@@ -8,6 +6,9 @@ import {
|
|||||||
query,
|
query,
|
||||||
state,
|
state,
|
||||||
} from "lit/decorators";
|
} from "lit/decorators";
|
||||||
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
|
import { mdiClose } from "@mdi/js";
|
||||||
|
import "@home-assistant/webawesome/dist/components/dialog/dialog";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { haStyleScrollbar } from "../resources/styles";
|
import { haStyleScrollbar } from "../resources/styles";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
@@ -31,6 +32,8 @@ export type DialogWidth = "small" | "medium" | "large" | "full";
|
|||||||
*
|
*
|
||||||
* @slot header - Replace the entire header area.
|
* @slot header - Replace the entire header area.
|
||||||
* @slot headerNavigationIcon - Leading header action (e.g. close/back button).
|
* @slot headerNavigationIcon - Leading header action (e.g. close/back button).
|
||||||
|
* @slot headerTitle - Custom title content (used when header-title is not set).
|
||||||
|
* @slot headerSubtitle - Custom subtitle content (used when header-subtitle is not set).
|
||||||
* @slot headerActionItems - Trailing header actions (e.g. buttons, menus).
|
* @slot headerActionItems - Trailing header actions (e.g. buttons, menus).
|
||||||
* @slot - Dialog content body.
|
* @slot - Dialog content body.
|
||||||
* @slot footer - Dialog footer content.
|
* @slot footer - Dialog footer content.
|
||||||
@@ -52,8 +55,8 @@ export type DialogWidth = "small" | "medium" | "large" | "full";
|
|||||||
* @attr {boolean} open - Controls the dialog open state.
|
* @attr {boolean} open - Controls the dialog open state.
|
||||||
* @attr {("small"|"medium"|"large"|"full")} width - Preferred dialog width preset. Defaults to "medium".
|
* @attr {("small"|"medium"|"large"|"full")} width - Preferred dialog width preset. Defaults to "medium".
|
||||||
* @attr {boolean} prevent-scrim-close - Prevents closing the dialog by clicking the scrim/overlay. Defaults to false.
|
* @attr {boolean} prevent-scrim-close - Prevents closing the dialog by clicking the scrim/overlay. Defaults to false.
|
||||||
* @attr {string} header-title - Header title text when no custom title slot is provided.
|
* @attr {string} header-title - Header title text. If not set, the headerTitle slot is used.
|
||||||
* @attr {string} header-subtitle - Header subtitle text when no custom subtitle slot is provided.
|
* @attr {string} header-subtitle - Header subtitle text. If not set, the headerSubtitle slot is used.
|
||||||
* @attr {("above"|"below")} header-subtitle-position - Position of the subtitle relative to the title. Defaults to "below".
|
* @attr {("above"|"below")} header-subtitle-position - Position of the subtitle relative to the title. Defaults to "below".
|
||||||
* @attr {boolean} flexcontent - Makes the dialog body a flex container for flexible layouts.
|
* @attr {boolean} flexcontent - Makes the dialog body a flex container for flexible layouts.
|
||||||
*
|
*
|
||||||
@@ -72,6 +75,12 @@ export type DialogWidth = "small" | "medium" | "large" | "full";
|
|||||||
export class HaWaDialog extends LitElement {
|
export class HaWaDialog extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: "aria-labelledby" })
|
||||||
|
public ariaLabelledBy?: string;
|
||||||
|
|
||||||
|
@property({ attribute: "aria-describedby" })
|
||||||
|
public ariaDescribedBy?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true })
|
@property({ type: Boolean, reflect: true })
|
||||||
public open = false;
|
public open = false;
|
||||||
|
|
||||||
@@ -81,11 +90,11 @@ export class HaWaDialog extends LitElement {
|
|||||||
@property({ type: Boolean, reflect: true, attribute: "prevent-scrim-close" })
|
@property({ type: Boolean, reflect: true, attribute: "prevent-scrim-close" })
|
||||||
public preventScrimClose = false;
|
public preventScrimClose = false;
|
||||||
|
|
||||||
@property({ type: String, attribute: "header-title" })
|
@property({ attribute: "header-title" })
|
||||||
public headerTitle = "";
|
public headerTitle?: string;
|
||||||
|
|
||||||
@property({ type: String, attribute: "header-subtitle" })
|
@property({ attribute: "header-subtitle" })
|
||||||
public headerSubtitle = "";
|
public headerSubtitle?: string;
|
||||||
|
|
||||||
@property({ type: String, attribute: "header-subtitle-position" })
|
@property({ type: String, attribute: "header-subtitle-position" })
|
||||||
public headerSubtitlePosition: "above" | "below" = "below";
|
public headerSubtitlePosition: "above" | "below" = "below";
|
||||||
@@ -117,6 +126,11 @@ export class HaWaDialog extends LitElement {
|
|||||||
.open=${this._open}
|
.open=${this._open}
|
||||||
.lightDismiss=${!this.preventScrimClose}
|
.lightDismiss=${!this.preventScrimClose}
|
||||||
without-header
|
without-header
|
||||||
|
aria-labelledby=${ifDefined(
|
||||||
|
this.ariaLabelledBy ||
|
||||||
|
(this.headerTitle !== undefined ? "ha-wa-dialog-title" : undefined)
|
||||||
|
)}
|
||||||
|
aria-describedby=${ifDefined(this.ariaDescribedBy)}
|
||||||
@wa-show=${this._handleShow}
|
@wa-show=${this._handleShow}
|
||||||
@wa-after-show=${this._handleAfterShow}
|
@wa-after-show=${this._handleAfterShow}
|
||||||
@wa-after-hide=${this._handleAfterHide}
|
@wa-after-hide=${this._handleAfterHide}
|
||||||
@@ -133,14 +147,14 @@ export class HaWaDialog extends LitElement {
|
|||||||
.path=${mdiClose}
|
.path=${mdiClose}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
</slot>
|
</slot>
|
||||||
${this.headerTitle
|
${this.headerTitle !== undefined
|
||||||
? html`<span slot="title" class="title">
|
? html`<span slot="title" class="title" id="ha-wa-dialog-title">
|
||||||
${this.headerTitle}
|
${this.headerTitle}
|
||||||
</span>`
|
</span>`
|
||||||
: nothing}
|
: html`<slot name="headerTitle" slot="title"></slot>`}
|
||||||
${this.headerSubtitle
|
${this.headerSubtitle !== undefined
|
||||||
? html`<span slot="subtitle">${this.headerSubtitle}</span>`
|
? html`<span slot="subtitle">${this.headerSubtitle}</span>`
|
||||||
: nothing}
|
: html`<slot name="headerSubtitle" slot="subtitle"></slot>`}
|
||||||
<slot name="headerActionItems" slot="actionItems"></slot>
|
<slot name="headerActionItems" slot="actionItems"></slot>
|
||||||
</ha-dialog-header>
|
</ha-dialog-header>
|
||||||
</slot>
|
</slot>
|
||||||
|
|||||||
@@ -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",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
||||||
|
|||||||
152
src/dialogs/more-info/ha-more-info-add-to.ts
Normal file
152
src/dialogs/more-info/ha-more-info-add-to.ts
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import "../../components/ha-alert";
|
||||||
|
import "../../components/ha-icon";
|
||||||
|
import "../../components/ha-list-item";
|
||||||
|
import "../../components/ha-spinner";
|
||||||
|
import type {
|
||||||
|
ExternalEntityAddToActions,
|
||||||
|
ExternalEntityAddToAction,
|
||||||
|
} from "../../external_app/external_messaging";
|
||||||
|
import { showToast } from "../../util/toast";
|
||||||
|
|
||||||
|
import type { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
|
@customElement("ha-more-info-add-to")
|
||||||
|
export class HaMoreInfoAddTo extends LitElement {
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public entityId!: string;
|
||||||
|
|
||||||
|
@state() private _externalActions?: ExternalEntityAddToActions = {
|
||||||
|
actions: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
@state() private _loading = true;
|
||||||
|
|
||||||
|
private async _loadExternalActions() {
|
||||||
|
if (this.hass.auth.external?.config.hasEntityAddTo) {
|
||||||
|
this._externalActions =
|
||||||
|
await this.hass.auth.external?.sendMessage<"entity/add_to/get_actions">(
|
||||||
|
{
|
||||||
|
type: "entity/add_to/get_actions",
|
||||||
|
payload: { entity_id: this.entityId },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _actionSelected(ev: CustomEvent) {
|
||||||
|
const action = (ev.currentTarget as any)
|
||||||
|
.action as ExternalEntityAddToAction;
|
||||||
|
if (!action.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.hass.auth.external!.fireMessage({
|
||||||
|
type: "entity/add_to",
|
||||||
|
payload: {
|
||||||
|
entity_id: this.entityId,
|
||||||
|
app_payload: action.app_payload,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
showToast(this, {
|
||||||
|
message: this.hass.localize(
|
||||||
|
"ui.dialogs.more_info_control.add_to.action_failed",
|
||||||
|
{
|
||||||
|
error: err.message || err,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async firstUpdated() {
|
||||||
|
await this._loadExternalActions();
|
||||||
|
this._loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
if (this._loading) {
|
||||||
|
return html`
|
||||||
|
<div class="loading">
|
||||||
|
<ha-spinner></ha-spinner>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._externalActions?.actions.length) {
|
||||||
|
return html`
|
||||||
|
<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.dialogs.more_info_control.add_to.no_actions"
|
||||||
|
)}
|
||||||
|
</ha-alert>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div class="actions-list">
|
||||||
|
${this._externalActions.actions.map(
|
||||||
|
(action) => html`
|
||||||
|
<ha-list-item
|
||||||
|
graphic="icon"
|
||||||
|
.disabled=${!action.enabled}
|
||||||
|
.action=${action}
|
||||||
|
.twoline=${!!action.details}
|
||||||
|
@click=${this._actionSelected}
|
||||||
|
>
|
||||||
|
<span>${action.name}</span>
|
||||||
|
${action.details
|
||||||
|
? html`<span slot="secondary">${action.details}</span>`
|
||||||
|
: nothing}
|
||||||
|
<ha-icon slot="graphic" .icon=${action.mdi_icon}></ha-icon>
|
||||||
|
</ha-list-item>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
padding: var(--ha-space-2) var(--ha-space-6) var(--ha-space-6)
|
||||||
|
var(--ha-space-6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: var(--ha-space-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
ha-list-item {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ha-list-item[disabled] {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
ha-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-more-info-add-to": HaMoreInfoAddTo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
mdiPencil,
|
mdiPencil,
|
||||||
mdiPencilOff,
|
mdiPencilOff,
|
||||||
mdiPencilOutline,
|
mdiPencilOutline,
|
||||||
|
mdiPlusBoxMultipleOutline,
|
||||||
mdiTransitConnectionVariant,
|
mdiTransitConnectionVariant,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
@@ -60,6 +61,7 @@ import {
|
|||||||
computeShowLogBookComponent,
|
computeShowLogBookComponent,
|
||||||
} from "./const";
|
} from "./const";
|
||||||
import "./controls/more-info-default";
|
import "./controls/more-info-default";
|
||||||
|
import "./ha-more-info-add-to";
|
||||||
import "./ha-more-info-history-and-logbook";
|
import "./ha-more-info-history-and-logbook";
|
||||||
import "./ha-more-info-info";
|
import "./ha-more-info-info";
|
||||||
import "./ha-more-info-settings";
|
import "./ha-more-info-settings";
|
||||||
@@ -73,7 +75,7 @@ export interface MoreInfoDialogParams {
|
|||||||
data?: Record<string, any>;
|
data?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type View = "info" | "history" | "settings" | "related";
|
type View = "info" | "history" | "settings" | "related" | "add_to";
|
||||||
|
|
||||||
interface ChildView {
|
interface ChildView {
|
||||||
viewTag: string;
|
viewTag: string;
|
||||||
@@ -194,6 +196,10 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _shouldShowAddEntityTo(): boolean {
|
||||||
|
return !!this.hass.auth.external?.config.hasEntityAddTo;
|
||||||
|
}
|
||||||
|
|
||||||
private _getDeviceId(): string | null {
|
private _getDeviceId(): string | null {
|
||||||
const entity = this.hass.entities[this._entityId!] as
|
const entity = this.hass.entities[this._entityId!] as
|
||||||
| EntityRegistryEntry
|
| EntityRegistryEntry
|
||||||
@@ -295,6 +301,11 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
this._setView("related");
|
this._setView("related");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _goToAddEntityTo(ev) {
|
||||||
|
if (!shouldHandleRequestSelectedEvent(ev)) return;
|
||||||
|
this._setView("add_to");
|
||||||
|
}
|
||||||
|
|
||||||
private _breadcrumbClick(ev: Event) {
|
private _breadcrumbClick(ev: Event) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this._setView("related");
|
this._setView("related");
|
||||||
@@ -521,6 +532,22 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
.path=${mdiInformationOutline}
|
.path=${mdiInformationOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
|
${this._shouldShowAddEntityTo()
|
||||||
|
? html`
|
||||||
|
<ha-list-item
|
||||||
|
graphic="icon"
|
||||||
|
@request-selected=${this._goToAddEntityTo}
|
||||||
|
>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.dialogs.more_info_control.add_entity_to"
|
||||||
|
)}
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="graphic"
|
||||||
|
.path=${mdiPlusBoxMultipleOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-list-item>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
@@ -613,7 +640,14 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
: "entity"}
|
: "entity"}
|
||||||
></ha-related-items>
|
></ha-related-items>
|
||||||
`
|
`
|
||||||
: nothing
|
: this._currView === "add_to"
|
||||||
|
? html`
|
||||||
|
<ha-more-info-add-to
|
||||||
|
.hass=${this.hass}
|
||||||
|
.entityId=${entityId}
|
||||||
|
></ha-more-info-add-to>
|
||||||
|
`
|
||||||
|
: nothing
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -152,10 +152,18 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setRedrawTimer() {
|
private _setUpdateTimer() {
|
||||||
// redraw the graph every minute to update the time axis
|
|
||||||
clearInterval(this._interval);
|
clearInterval(this._interval);
|
||||||
this._interval = window.setInterval(() => this._redrawGraph(), 1000 * 60);
|
this._interval = window.setInterval(() => {
|
||||||
|
// If using statistics, refresh the data
|
||||||
|
if (this._statistics) {
|
||||||
|
this._fetchStatistics();
|
||||||
|
}
|
||||||
|
// If using history, redraw the graph to update the time axis
|
||||||
|
if (this._stateHistory) {
|
||||||
|
this._redrawGraph();
|
||||||
|
}
|
||||||
|
}, 1000 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _getStatisticsMetaData(statisticIds: string[] | undefined) {
|
private async _getStatisticsMetaData(statisticIds: string[] | undefined) {
|
||||||
@@ -170,6 +178,30 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
return statisticsMetaData;
|
return statisticsMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _fetchStatistics(): Promise<boolean> {
|
||||||
|
// Fire off the metadata and fetch at the same time
|
||||||
|
// to avoid waiting in sequence so the UI responds
|
||||||
|
// faster.
|
||||||
|
const _metadata = this._getStatisticsMetaData([this.entityId]);
|
||||||
|
const _statistics = fetchStatistics(
|
||||||
|
this.hass!,
|
||||||
|
subHours(new Date(), 24),
|
||||||
|
undefined,
|
||||||
|
[this.entityId],
|
||||||
|
"5minute",
|
||||||
|
undefined,
|
||||||
|
statTypes
|
||||||
|
);
|
||||||
|
const [metadata, statistics] = await Promise.all([_metadata, _statistics]);
|
||||||
|
if (metadata && Object.keys(metadata).length) {
|
||||||
|
this._metadata = metadata;
|
||||||
|
this._statistics = statistics;
|
||||||
|
this._statNames = { [this.entityId]: "" };
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private async _getStateHistory(): Promise<void> {
|
private async _getStateHistory(): Promise<void> {
|
||||||
if (
|
if (
|
||||||
isComponentLoaded(this.hass, "recorder") &&
|
isComponentLoaded(this.hass, "recorder") &&
|
||||||
@@ -180,27 +212,10 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
// has not opted into statistics so there is no need to check as it
|
// has not opted into statistics so there is no need to check as it
|
||||||
// requires another round-trip to the server.
|
// requires another round-trip to the server.
|
||||||
if (stateObj && stateObj.attributes.state_class) {
|
if (stateObj && stateObj.attributes.state_class) {
|
||||||
// Fire off the metadata and fetch at the same time
|
const hasStatistics = await this._fetchStatistics();
|
||||||
// to avoid waiting in sequence so the UI responds
|
if (hasStatistics) {
|
||||||
// faster.
|
// Using statistics, set up refresh timer
|
||||||
const _metadata = this._getStatisticsMetaData([this.entityId]);
|
this._setUpdateTimer();
|
||||||
const _statistics = fetchStatistics(
|
|
||||||
this.hass!,
|
|
||||||
subHours(new Date(), 24),
|
|
||||||
undefined,
|
|
||||||
[this.entityId],
|
|
||||||
"5minute",
|
|
||||||
undefined,
|
|
||||||
statTypes
|
|
||||||
);
|
|
||||||
const [metadata, statistics] = await Promise.all([
|
|
||||||
_metadata,
|
|
||||||
_statistics,
|
|
||||||
]);
|
|
||||||
if (metadata && Object.keys(metadata).length) {
|
|
||||||
this._metadata = metadata;
|
|
||||||
this._statistics = statistics;
|
|
||||||
this._statNames = { [this.entityId]: "" };
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,7 +253,7 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
this._error = err;
|
this._error = err;
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
this._setRedrawTimer();
|
this._setUpdateTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = [
|
static styles = [
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ interface EMOutgoingMessageConfigGet extends EMMessage {
|
|||||||
type: "config/get";
|
type: "config/get";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EMOutgoingMessageEntityAddToGetActions extends EMMessage {
|
||||||
|
type: "entity/add_to/get_actions";
|
||||||
|
payload: {
|
||||||
|
entity_id: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface EMOutgoingMessageBarCodeScan extends EMMessage {
|
interface EMOutgoingMessageBarCodeScan extends EMMessage {
|
||||||
type: "bar_code/scan";
|
type: "bar_code/scan";
|
||||||
payload: {
|
payload: {
|
||||||
@@ -75,6 +82,10 @@ interface EMOutgoingMessageWithAnswer {
|
|||||||
request: EMOutgoingMessageConfigGet;
|
request: EMOutgoingMessageConfigGet;
|
||||||
response: ExternalConfig;
|
response: ExternalConfig;
|
||||||
};
|
};
|
||||||
|
"entity/add_to/get_actions": {
|
||||||
|
request: EMOutgoingMessageEntityAddToGetActions;
|
||||||
|
response: ExternalEntityAddToActions;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EMOutgoingMessageExoplayerPlayHLS extends EMMessage {
|
interface EMOutgoingMessageExoplayerPlayHLS extends EMMessage {
|
||||||
@@ -157,6 +168,14 @@ interface EMOutgoingMessageThreadStoreInPlatformKeychain extends EMMessage {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EMOutgoingMessageAddEntityTo extends EMMessage {
|
||||||
|
type: "entity/add_to";
|
||||||
|
payload: {
|
||||||
|
entity_id: string;
|
||||||
|
app_payload: string; // Opaque string received from get_actions
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type EMOutgoingMessageWithoutAnswer =
|
type EMOutgoingMessageWithoutAnswer =
|
||||||
| EMMessageResultError
|
| EMMessageResultError
|
||||||
| EMMessageResultSuccess
|
| EMMessageResultSuccess
|
||||||
@@ -177,7 +196,8 @@ type EMOutgoingMessageWithoutAnswer =
|
|||||||
| EMOutgoingMessageThemeUpdate
|
| EMOutgoingMessageThemeUpdate
|
||||||
| EMOutgoingMessageThreadStoreInPlatformKeychain
|
| EMOutgoingMessageThreadStoreInPlatformKeychain
|
||||||
| EMOutgoingMessageImprovScan
|
| EMOutgoingMessageImprovScan
|
||||||
| EMOutgoingMessageImprovConfigureDevice;
|
| EMOutgoingMessageImprovConfigureDevice
|
||||||
|
| EMOutgoingMessageAddEntityTo;
|
||||||
|
|
||||||
export interface EMIncomingMessageRestart {
|
export interface EMIncomingMessageRestart {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -293,18 +313,31 @@ type EMIncomingMessage =
|
|||||||
type EMIncomingMessageHandler = (msg: EMIncomingMessageCommands) => boolean;
|
type EMIncomingMessageHandler = (msg: EMIncomingMessageCommands) => boolean;
|
||||||
|
|
||||||
export interface ExternalConfig {
|
export interface ExternalConfig {
|
||||||
hasSettingsScreen: boolean;
|
hasSettingsScreen?: boolean;
|
||||||
hasSidebar: boolean;
|
hasSidebar?: boolean;
|
||||||
canWriteTag: boolean;
|
canWriteTag?: boolean;
|
||||||
hasExoPlayer: boolean;
|
hasExoPlayer?: boolean;
|
||||||
canCommissionMatter: boolean;
|
canCommissionMatter?: boolean;
|
||||||
canImportThreadCredentials: boolean;
|
canImportThreadCredentials?: boolean;
|
||||||
canTransferThreadCredentialsToKeychain: boolean;
|
canTransferThreadCredentialsToKeychain?: boolean;
|
||||||
hasAssist: boolean;
|
hasAssist?: boolean;
|
||||||
hasBarCodeScanner: number;
|
hasBarCodeScanner?: number;
|
||||||
canSetupImprov: boolean;
|
canSetupImprov?: boolean;
|
||||||
downloadFileSupported: boolean;
|
downloadFileSupported?: boolean;
|
||||||
appVersion: string;
|
appVersion?: string;
|
||||||
|
hasEntityAddTo?: boolean; // Supports "Add to" from more-info dialog, with action coming from external app
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExternalEntityAddToAction {
|
||||||
|
enabled: boolean;
|
||||||
|
name: string; // Translated name of the action to be displayed in the UI
|
||||||
|
details?: string; // Optional translated details of the action to be displayed in the UI
|
||||||
|
mdi_icon: string; // MDI icon name to be displayed in the UI (e.g., "mdi:car")
|
||||||
|
app_payload: string; // Opaque string to be sent back when the action is selected
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExternalEntityAddToActions {
|
||||||
|
actions: ExternalEntityAddToAction[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExternalMessaging {
|
export class ExternalMessaging {
|
||||||
|
|||||||
@@ -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"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
95
src/mixins/conditional-listener-mixin.ts
Normal file
95
src/mixins/conditional-listener-mixin.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import type { ReactiveElement } from "lit";
|
||||||
|
import type { HomeAssistant } from "../types";
|
||||||
|
import { setupMediaQueryListeners } from "../common/condition/listeners";
|
||||||
|
|
||||||
|
type Constructor<T> = abstract new (...args: any[]) => T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mixin to handle conditional listeners for visibility control
|
||||||
|
*
|
||||||
|
* Provides lifecycle management for listeners that control conditional
|
||||||
|
* visibility of components.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* 1. Extend your component with ConditionalListenerMixin(ReactiveElement)
|
||||||
|
* 2. Ensure component has config.visibility or _config.visibility property with conditions
|
||||||
|
* 3. Ensure component has _updateVisibility() or _updateElement() method
|
||||||
|
* 4. Override setupConditionalListeners() if custom behavior needed (e.g., filter conditions)
|
||||||
|
*
|
||||||
|
* The mixin automatically:
|
||||||
|
* - Sets up listeners when component connects to DOM
|
||||||
|
* - Cleans up listeners when component disconnects from DOM
|
||||||
|
* - Handles conditional visibility based on defined conditions
|
||||||
|
*/
|
||||||
|
export const ConditionalListenerMixin = <
|
||||||
|
T extends Constructor<ReactiveElement>,
|
||||||
|
>(
|
||||||
|
superClass: T
|
||||||
|
) => {
|
||||||
|
abstract class ConditionalListenerClass extends superClass {
|
||||||
|
private __listeners: (() => void)[] = [];
|
||||||
|
|
||||||
|
// Type hint for hass property (should be provided by subclass)
|
||||||
|
abstract hass?: HomeAssistant;
|
||||||
|
|
||||||
|
public connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
this.setupConditionalListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this.clearConditionalListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected clearConditionalListeners(): void {
|
||||||
|
this.__listeners.forEach((unsub) => unsub());
|
||||||
|
this.__listeners = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected addConditionalListener(unsubscribe: () => void): void {
|
||||||
|
this.__listeners.push(unsubscribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup conditional listeners for visibility control
|
||||||
|
*
|
||||||
|
* Default implementation:
|
||||||
|
* - Checks config.visibility or _config.visibility for conditions (if not provided)
|
||||||
|
* - Sets up appropriate listeners based on condition types
|
||||||
|
* - Calls _updateVisibility() or _updateElement() when conditions change
|
||||||
|
*
|
||||||
|
* Override this method to customize behavior (e.g., filter conditions first)
|
||||||
|
* and call super.setupConditionalListeners(customConditions) to reuse the base implementation
|
||||||
|
*
|
||||||
|
* @param conditions - Optional conditions array. If not provided, will check config.visibility or _config.visibility
|
||||||
|
*/
|
||||||
|
protected setupConditionalListeners(conditions?: any[]): void {
|
||||||
|
const component = this as any;
|
||||||
|
const finalConditions =
|
||||||
|
conditions ||
|
||||||
|
component.config?.visibility ||
|
||||||
|
component._config?.visibility;
|
||||||
|
|
||||||
|
if (!finalConditions || !this.hass) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onUpdate = (conditionsMet: boolean) => {
|
||||||
|
if (component._updateVisibility) {
|
||||||
|
component._updateVisibility(conditionsMet);
|
||||||
|
} else if (component._updateElement) {
|
||||||
|
component._updateElement(conditionsMet);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setupMediaQueryListeners(
|
||||||
|
finalConditions,
|
||||||
|
this.hass,
|
||||||
|
(unsub) => this.addConditionalListener(unsub),
|
||||||
|
onUpdate
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ConditionalListenerClass;
|
||||||
|
};
|
||||||
@@ -332,6 +332,15 @@ class DialogCalendarEventEditor extends LitElement {
|
|||||||
|
|
||||||
private _allDayToggleChanged(ev) {
|
private _allDayToggleChanged(ev) {
|
||||||
this._allDay = ev.target.checked;
|
this._allDay = ev.target.checked;
|
||||||
|
// When switching to all-day mode, normalize dates to midnight so time portions don't interfere with date comparisons
|
||||||
|
if (this._allDay && this._dtstart && this._dtend) {
|
||||||
|
this._dtstart = new Date(
|
||||||
|
formatDate(this._dtstart, this._timeZone!) + "T00:00:00"
|
||||||
|
);
|
||||||
|
this._dtend = new Date(
|
||||||
|
formatDate(this._dtend, this._timeZone!) + "T00:00:00"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _startDateChanged(ev: CustomEvent) {
|
private _startDateChanged(ev: CustomEvent) {
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
getFloors,
|
getFloors,
|
||||||
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
||||||
|
import { floorDefaultIcon } from "../../../components/ha-floor-icon";
|
||||||
|
|
||||||
export interface ClimateViewStrategyConfig {
|
export interface ClimateViewStrategyConfig {
|
||||||
type: "climate";
|
type: "climate";
|
||||||
@@ -114,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(
|
||||||
@@ -152,6 +171,7 @@ export class ClimateViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -188,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 {
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import "../../../../components/ha-md-divider";
|
|||||||
import "../../../../components/ha-md-menu-item";
|
import "../../../../components/ha-md-menu-item";
|
||||||
import { ACTION_BUILDING_BLOCKS } from "../../../../data/action";
|
import { ACTION_BUILDING_BLOCKS } from "../../../../data/action";
|
||||||
import type { ActionSidebarConfig } from "../../../../data/automation";
|
import type { ActionSidebarConfig } from "../../../../data/automation";
|
||||||
import type { RepeatAction } from "../../../../data/script";
|
import { domainToName } from "../../../../data/integration";
|
||||||
|
import type { RepeatAction, ServiceAction } from "../../../../data/script";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
import { isMac } from "../../../../util/is_mac";
|
import { isMac } from "../../../../util/is_mac";
|
||||||
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
import type HaAutomationConditionEditor from "../action/ha-automation-action-editor";
|
||||||
@@ -83,11 +84,23 @@ export default class HaAutomationSidebarAction extends LitElement {
|
|||||||
"ui.panel.config.automation.editor.actions.action"
|
"ui.panel.config.automation.editor.actions.action"
|
||||||
);
|
);
|
||||||
|
|
||||||
const title =
|
let title =
|
||||||
this.hass.localize(
|
this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.actions.type.${type}.label` as LocalizeKeys
|
`ui.panel.config.automation.editor.actions.type.${type}.label` as LocalizeKeys
|
||||||
) || type;
|
) || type;
|
||||||
|
|
||||||
|
if (type === "service" && (actionConfig as ServiceAction).action) {
|
||||||
|
const [domain, service] = (actionConfig as ServiceAction).action!.split(
|
||||||
|
".",
|
||||||
|
2
|
||||||
|
);
|
||||||
|
title = `${domainToName(this.hass.localize, domain)}: ${
|
||||||
|
this.hass.localize(`component.${domain}.services.${service}.name`) ||
|
||||||
|
this.hass.services[domain][service]?.name ||
|
||||||
|
title
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
|
||||||
const description = isBuildingBlock
|
const description = isBuildingBlock
|
||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.actions.type.${type}.description.picker` as LocalizeKeys
|
`ui.panel.config.automation.editor.actions.type.${type}.description.picker` as LocalizeKeys
|
||||||
|
|||||||
@@ -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();
|
||||||
};
|
};
|
||||||
@@ -572,15 +569,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 +595,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 +609,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, {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { subscribeEntityRegistry } from "../../../data/entity_registry";
|
|||||||
import type { UpdateEntity } from "../../../data/update";
|
import type { UpdateEntity } from "../../../data/update";
|
||||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import "../../../components/ha-progress-ring";
|
||||||
|
|
||||||
@customElement("ha-config-updates")
|
@customElement("ha-config-updates")
|
||||||
class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||||
@@ -56,6 +57,29 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
|||||||
this._entities?.find((entity) => entity.entity_id === entityId)
|
this._entities?.find((entity) => entity.entity_id === entityId)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private _renderUpdateProgress(entity: UpdateEntity) {
|
||||||
|
if (entity.attributes.update_percentage != null) {
|
||||||
|
return html`<ha-progress-ring
|
||||||
|
size="small"
|
||||||
|
.value=${entity.attributes.update_percentage}
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.updates.update_in_progress"
|
||||||
|
)}
|
||||||
|
></ha-progress-ring>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.attributes.in_progress) {
|
||||||
|
return html`<ha-spinner
|
||||||
|
size="small"
|
||||||
|
.ariaLabel=${this.hass.localize(
|
||||||
|
"ui.panel.config.updates.update_in_progress"
|
||||||
|
)}
|
||||||
|
></ha-spinner>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`<ha-icon-next></ha-icon-next>`;
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.updateEntities?.length) {
|
if (!this.updateEntities?.length) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@@ -106,13 +130,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
|||||||
)}
|
)}
|
||||||
></state-badge>
|
></state-badge>
|
||||||
${this.narrow && entity.attributes.in_progress
|
${this.narrow && entity.attributes.in_progress
|
||||||
? html`<ha-spinner
|
? html`<div class="absolute">
|
||||||
class="absolute"
|
${this._renderUpdateProgress(entity)}
|
||||||
size="small"
|
</div>`
|
||||||
.ariaLabel=${this.hass.localize(
|
|
||||||
"ui.panel.config.updates.update_in_progress"
|
|
||||||
)}
|
|
||||||
></ha-spinner>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
<span slot="headline"
|
<span slot="headline"
|
||||||
@@ -128,16 +148,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</span>
|
</span>
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
? entity.attributes.in_progress
|
? html`<div slot="end">
|
||||||
? html`<div slot="end">
|
${this._renderUpdateProgress(entity)}
|
||||||
<ha-spinner
|
</div>`
|
||||||
size="small"
|
|
||||||
.ariaLabel=${this.hass.localize(
|
|
||||||
"ui.panel.config.updates.update_in_progress"
|
|
||||||
)}
|
|
||||||
></ha-spinner>
|
|
||||||
</div>`
|
|
||||||
: html`<ha-icon-next slot="end"></ha-icon-next>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
`;
|
`;
|
||||||
@@ -193,13 +206,13 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
|||||||
div[slot="start"] {
|
div[slot="start"] {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
ha-spinner.absolute {
|
div.absolute {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 6px;
|
left: 6px;
|
||||||
top: 6px;
|
top: 6px;
|
||||||
}
|
}
|
||||||
state-badge.updating {
|
state-badge.updating {
|
||||||
opacity: 0.5;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -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>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import "../../../../components/ha-dialog";
|
|||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-formfield";
|
import "../../../../components/ha-formfield";
|
||||||
import "../../../../components/ha-radio";
|
import "../../../../components/ha-radio";
|
||||||
|
import "../../../../components/ha-markdown";
|
||||||
import type { HaRadio } from "../../../../components/ha-radio";
|
import type { HaRadio } from "../../../../components/ha-radio";
|
||||||
import type {
|
import type {
|
||||||
FlowFromGridSourceEnergyPreference,
|
FlowFromGridSourceEnergyPreference,
|
||||||
@@ -19,11 +20,7 @@ import {
|
|||||||
emptyFlowToGridSourceEnergyPreference,
|
emptyFlowToGridSourceEnergyPreference,
|
||||||
energyStatisticHelpUrl,
|
energyStatisticHelpUrl,
|
||||||
} from "../../../../data/energy";
|
} from "../../../../data/energy";
|
||||||
import {
|
import { isExternalStatistic } from "../../../../data/recorder";
|
||||||
getDisplayUnit,
|
|
||||||
getStatisticMetadata,
|
|
||||||
isExternalStatistic,
|
|
||||||
} from "../../../../data/recorder";
|
|
||||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||||
import { haStyleDialog } from "../../../../resources/styles";
|
import { haStyleDialog } from "../../../../resources/styles";
|
||||||
@@ -47,8 +44,6 @@ export class DialogEnergyGridFlowSettings
|
|||||||
|
|
||||||
@state() private _costs?: "no-costs" | "number" | "entity" | "statistic";
|
@state() private _costs?: "no-costs" | "number" | "entity" | "statistic";
|
||||||
|
|
||||||
@state() private _pickedDisplayUnit?: string | null;
|
|
||||||
|
|
||||||
@state() private _energy_units?: string[];
|
@state() private _energy_units?: string[];
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
@@ -81,11 +76,6 @@ export class DialogEnergyGridFlowSettings
|
|||||||
: "stat_energy_to"
|
: "stat_energy_to"
|
||||||
];
|
];
|
||||||
|
|
||||||
this._pickedDisplayUnit = getDisplayUnit(
|
|
||||||
this.hass,
|
|
||||||
initialSourceId,
|
|
||||||
params.metadata
|
|
||||||
);
|
|
||||||
this._energy_units = (
|
this._energy_units = (
|
||||||
await getSensorDeviceClassConvertibleUnits(this.hass, "energy")
|
await getSensorDeviceClassConvertibleUnits(this.hass, "energy")
|
||||||
).units;
|
).units;
|
||||||
@@ -103,7 +93,6 @@ export class DialogEnergyGridFlowSettings
|
|||||||
public closeDialog() {
|
public closeDialog() {
|
||||||
this._params = undefined;
|
this._params = undefined;
|
||||||
this._source = undefined;
|
this._source = undefined;
|
||||||
this._pickedDisplayUnit = undefined;
|
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._excludeList = undefined;
|
this._excludeList = undefined;
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
@@ -117,10 +106,6 @@ export class DialogEnergyGridFlowSettings
|
|||||||
|
|
||||||
const pickableUnit = this._energy_units?.join(", ") || "";
|
const pickableUnit = this._energy_units?.join(", ") || "";
|
||||||
|
|
||||||
const unitPriceSensor = this._pickedDisplayUnit
|
|
||||||
? `${this.hass.config.currency}/${this._pickedDisplayUnit}`
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const unitPriceFixed = `${this.hass.config.currency}/kWh`;
|
const unitPriceFixed = `${this.hass.config.currency}/kWh`;
|
||||||
|
|
||||||
const externalSource =
|
const externalSource =
|
||||||
@@ -246,9 +231,15 @@ export class DialogEnergyGridFlowSettings
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
include-domains='["sensor", "input_number"]'
|
include-domains='["sensor", "input_number"]'
|
||||||
.value=${this._source.entity_energy_price}
|
.value=${this._source.entity_energy_price}
|
||||||
.label=${`${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
`ui.panel.config.energy.grid.flow_dialog.${this._params.direction}.cost_entity_input`
|
`ui.panel.config.energy.grid.flow_dialog.${this._params.direction}.cost_entity_input`
|
||||||
)} ${unitPriceSensor ? ` (${unitPriceSensor})` : ""}`}
|
)}
|
||||||
|
.helper=${html`<ha-markdown
|
||||||
|
.content=${this.hass.localize(
|
||||||
|
"ui.panel.config.energy.grid.flow_dialog.cost_entity_helper",
|
||||||
|
{ currency: this.hass.config.currency }
|
||||||
|
)}
|
||||||
|
></ha-markdown>`}
|
||||||
@value-changed=${this._priceEntityChanged}
|
@value-changed=${this._priceEntityChanged}
|
||||||
></ha-entity-picker>`
|
></ha-entity-picker>`
|
||||||
: ""}
|
: ""}
|
||||||
@@ -341,16 +332,6 @@ export class DialogEnergyGridFlowSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||||
if (ev.detail.value) {
|
|
||||||
const metadata = await getStatisticMetadata(this.hass, [ev.detail.value]);
|
|
||||||
this._pickedDisplayUnit = getDisplayUnit(
|
|
||||||
this.hass,
|
|
||||||
ev.detail.value,
|
|
||||||
metadata[0]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this._pickedDisplayUnit = undefined;
|
|
||||||
}
|
|
||||||
this._source = {
|
this._source = {
|
||||||
...this._source!,
|
...this._source!,
|
||||||
[this._params!.direction === "from"
|
[this._params!.direction === "from"
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { css, html, LitElement } 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 { relativeTime } from "../../../../../common/datetime/relative_time";
|
import { relativeTime } from "../../../../../common/datetime/relative_time";
|
||||||
|
import { getDeviceContext } from "../../../../../common/entity/context/get_device_context";
|
||||||
import { navigate } from "../../../../../common/navigate";
|
import { navigate } from "../../../../../common/navigate";
|
||||||
import { throttle } from "../../../../../common/util/throttle";
|
import { throttle } from "../../../../../common/util/throttle";
|
||||||
import "../../../../../components/chart/ha-network-graph";
|
import "../../../../../components/chart/ha-network-graph";
|
||||||
@@ -194,11 +195,17 @@ export class BluetoothNetworkVisualization extends LitElement {
|
|||||||
];
|
];
|
||||||
const links: NetworkLink[] = [];
|
const links: NetworkLink[] = [];
|
||||||
Object.values(scanners).forEach((scanner) => {
|
Object.values(scanners).forEach((scanner) => {
|
||||||
const scannerDevice = this._sourceDevices[scanner.source];
|
const scannerDevice = this._sourceDevices[scanner.source] as
|
||||||
|
| DeviceRegistryEntry
|
||||||
|
| undefined;
|
||||||
|
const area = scannerDevice
|
||||||
|
? getDeviceContext(scannerDevice, this.hass).area
|
||||||
|
: undefined;
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: scanner.source,
|
id: scanner.source,
|
||||||
name:
|
name:
|
||||||
scannerDevice?.name_by_user || scannerDevice?.name || scanner.name,
|
scannerDevice?.name_by_user || scannerDevice?.name || scanner.name,
|
||||||
|
context: area?.name,
|
||||||
category: 1,
|
category: 1,
|
||||||
value: 5,
|
value: 5,
|
||||||
symbol: "circle",
|
symbol: "circle",
|
||||||
@@ -231,10 +238,16 @@ export class BluetoothNetworkVisualization extends LitElement {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const device = this._sourceDevices[node.address];
|
const device = this._sourceDevices[node.address] as
|
||||||
|
| DeviceRegistryEntry
|
||||||
|
| undefined;
|
||||||
|
const area = device
|
||||||
|
? getDeviceContext(device, this.hass).area
|
||||||
|
: undefined;
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: node.address,
|
id: node.address,
|
||||||
name: this._getBluetoothDeviceName(node.address),
|
name: this._getBluetoothDeviceName(node.address),
|
||||||
|
context: area?.name,
|
||||||
value: device ? 1 : 0,
|
value: device ? 1 : 0,
|
||||||
category: device ? 2 : 3,
|
category: device ? 2 : 3,
|
||||||
symbolSize: 20,
|
symbolSize: 20,
|
||||||
@@ -294,15 +307,20 @@ export class BluetoothNetworkVisualization extends LitElement {
|
|||||||
const btDevice = this._data.find((d) => d.address === address);
|
const btDevice = this._data.find((d) => d.address === address);
|
||||||
if (btDevice) {
|
if (btDevice) {
|
||||||
tooltipText = `<b>${name}</b><br><b>${this.hass.localize("ui.panel.config.bluetooth.address")}:</b> ${address}<br><b>${this.hass.localize("ui.panel.config.bluetooth.rssi")}:</b> ${btDevice.rssi}<br><b>${this.hass.localize("ui.panel.config.bluetooth.source")}:</b> ${btDevice.source}<br><b>${this.hass.localize("ui.panel.config.bluetooth.updated")}:</b> ${relativeTime(new Date(btDevice.time * 1000), this.hass.locale)}`;
|
tooltipText = `<b>${name}</b><br><b>${this.hass.localize("ui.panel.config.bluetooth.address")}:</b> ${address}<br><b>${this.hass.localize("ui.panel.config.bluetooth.rssi")}:</b> ${btDevice.rssi}<br><b>${this.hass.localize("ui.panel.config.bluetooth.source")}:</b> ${btDevice.source}<br><b>${this.hass.localize("ui.panel.config.bluetooth.updated")}:</b> ${relativeTime(new Date(btDevice.time * 1000), this.hass.locale)}`;
|
||||||
|
const device = this._sourceDevices[address];
|
||||||
|
if (device) {
|
||||||
|
const area = getDeviceContext(device, this.hass).area;
|
||||||
|
if (area) {
|
||||||
|
tooltipText += `<br><b>${this.hass.localize("ui.panel.config.bluetooth.area")}: </b>${area.name}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const device = this._sourceDevices[address];
|
const device = this._sourceDevices[address];
|
||||||
if (device) {
|
if (device) {
|
||||||
tooltipText = `<b>${name}</b><br><b>${this.hass.localize("ui.panel.config.bluetooth.address")}:</b> ${address}`;
|
tooltipText = `<b>${name}</b><br><b>${this.hass.localize("ui.panel.config.bluetooth.address")}:</b> ${address}`;
|
||||||
if (device.area_id) {
|
const area = getDeviceContext(device, this.hass).area;
|
||||||
const area = this.hass.areas[device.area_id];
|
if (area) {
|
||||||
if (area) {
|
tooltipText += `<br><b>${this.hass.localize("ui.panel.config.bluetooth.area")}: </b>${area.name}`;
|
||||||
tooltipText += `<br><b>${this.hass.localize("ui.panel.config.bluetooth.area")}: </b>${area.name}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import "../../../../../layouts/hass-tabs-subpage";
|
|||||||
import type { HomeAssistant, Route } from "../../../../../types";
|
import type { HomeAssistant, Route } from "../../../../../types";
|
||||||
import { formatAsPaddedHex } from "./functions";
|
import { formatAsPaddedHex } from "./functions";
|
||||||
import { zhaTabs } from "./zha-config-dashboard";
|
import { zhaTabs } from "./zha-config-dashboard";
|
||||||
|
import type { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||||
|
import { getDeviceContext } from "../../../../../common/entity/context/get_device_context";
|
||||||
|
|
||||||
@customElement("zha-network-visualization-page")
|
@customElement("zha-network-visualization-page")
|
||||||
export class ZHANetworkVisualizationPage extends LitElement {
|
export class ZHANetworkVisualizationPage extends LitElement {
|
||||||
@@ -117,8 +119,11 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device_not_in_db")}</b>`;
|
label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device_not_in_db")}</b>`;
|
||||||
}
|
}
|
||||||
if (device.area_id) {
|
const haDevice = this.hass.devices[device.device_reg_id] as
|
||||||
const area = this.hass.areas[device.area_id];
|
| DeviceRegistryEntry
|
||||||
|
| undefined;
|
||||||
|
if (haDevice) {
|
||||||
|
const area = getDeviceContext(haDevice, this.hass).area;
|
||||||
if (area) {
|
if (area) {
|
||||||
label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.area")}: </b>${area.name}`;
|
label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.area")}: </b>${area.name}`;
|
||||||
}
|
}
|
||||||
@@ -204,10 +209,17 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
|||||||
category = 2; // End Device
|
category = 2; // End Device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const haDevice = this.hass.devices[device.device_reg_id] as
|
||||||
|
| DeviceRegistryEntry
|
||||||
|
| undefined;
|
||||||
|
const area = haDevice
|
||||||
|
? getDeviceContext(haDevice, this.hass).area
|
||||||
|
: undefined;
|
||||||
// Create node
|
// Create node
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: device.ieee,
|
id: device.ieee,
|
||||||
name: device.user_given_name || device.name || device.ieee,
|
name: device.user_given_name || device.name || device.ieee,
|
||||||
|
context: area?.name,
|
||||||
category,
|
category,
|
||||||
value: isCoordinator ? 3 : device.device_type === "Router" ? 2 : 1,
|
value: isCoordinator ? 3 : device.device_type === "Router" ? 2 : 1,
|
||||||
symbolSize: isCoordinator
|
symbolSize: isCoordinator
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement } 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 { getDeviceContext } from "../../../../../common/entity/context/get_device_context";
|
||||||
import { navigate } from "../../../../../common/navigate";
|
import { navigate } from "../../../../../common/navigate";
|
||||||
import { debounce } from "../../../../../common/util/debounce";
|
import { debounce } from "../../../../../common/util/debounce";
|
||||||
import "../../../../../components/chart/ha-network-graph";
|
import "../../../../../components/chart/ha-network-graph";
|
||||||
@@ -124,7 +125,7 @@ export class ZWaveJSNetworkVisualization extends SubscribeMixin(LitElement) {
|
|||||||
return tip;
|
return tip;
|
||||||
}
|
}
|
||||||
const { id, name } = data as any;
|
const { id, name } = data as any;
|
||||||
const device = this._devices[id];
|
const device = this._devices[id] as DeviceRegistryEntry | undefined;
|
||||||
const nodeStatus = this._nodeStatuses[id];
|
const nodeStatus = this._nodeStatuses[id];
|
||||||
let tip = `${(params as any).marker} ${name}`;
|
let tip = `${(params as any).marker} ${name}`;
|
||||||
tip += `<br><b>${this.hass.localize("ui.panel.config.zwave_js.visualization.node_id")}:</b> ${id}`;
|
tip += `<br><b>${this.hass.localize("ui.panel.config.zwave_js.visualization.node_id")}:</b> ${id}`;
|
||||||
@@ -138,6 +139,12 @@ export class ZWaveJSNetworkVisualization extends SubscribeMixin(LitElement) {
|
|||||||
tip += `<br><b>Z-Wave Plus:</b> ${this.hass.localize("ui.panel.config.zwave_js.visualization.version")} ${nodeStatus.zwave_plus_version}`;
|
tip += `<br><b>Z-Wave Plus:</b> ${this.hass.localize("ui.panel.config.zwave_js.visualization.version")} ${nodeStatus.zwave_plus_version}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (device) {
|
||||||
|
const area = getDeviceContext(device, this.hass).area;
|
||||||
|
if (area) {
|
||||||
|
tip += `<br><b>${this.hass.localize("ui.panel.config.zwave_js.visualization.area")}:</b> ${area.name}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
return tip;
|
return tip;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -197,10 +204,16 @@ export class ZWaveJSNetworkVisualization extends SubscribeMixin(LitElement) {
|
|||||||
if (node.is_controller_node) {
|
if (node.is_controller_node) {
|
||||||
controllerNode = node.node_id;
|
controllerNode = node.node_id;
|
||||||
}
|
}
|
||||||
const device = this._devices[node.node_id];
|
const device = this._devices[node.node_id] as
|
||||||
|
| DeviceRegistryEntry
|
||||||
|
| undefined;
|
||||||
|
const area = device
|
||||||
|
? getDeviceContext(device, this.hass).area
|
||||||
|
: undefined;
|
||||||
nodes.push({
|
nodes.push({
|
||||||
id: String(node.node_id),
|
id: String(node.node_id),
|
||||||
name: device?.name_by_user ?? device?.name ?? String(node.node_id),
|
name: device?.name_by_user ?? device?.name ?? String(node.node_id),
|
||||||
|
context: area?.name,
|
||||||
value: node.is_controller_node ? 3 : node.is_routing ? 2 : 1,
|
value: node.is_controller_node ? 3 : node.is_routing ? 2 : 1,
|
||||||
category:
|
category:
|
||||||
node.status === NodeStatus.Dead
|
node.status === NodeStatus.Dead
|
||||||
|
|||||||
@@ -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) => {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class DialogRepairsIssueSubtitle extends LitElement {
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: var(--ha-font-size-m);
|
font-size: var(--ha-font-size-m);
|
||||||
margin-bottom: 8px;
|
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { mdiClose, mdiOpenInNew } from "@mdi/js";
|
import { mdiOpenInNew } 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, query } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { isNavigationClick } from "../../../common/dom/is-navigation-click";
|
import { isNavigationClick } from "../../../common/dom/is-navigation-click";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-md-dialog";
|
import "../../../components/ha-wa-dialog";
|
||||||
import type { HaMdDialog } from "../../../components/ha-md-dialog";
|
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-dialog-header";
|
import "../../../components/ha-dialog-footer";
|
||||||
import "./dialog-repairs-issue-subtitle";
|
import "./dialog-repairs-issue-subtitle";
|
||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
import type { RepairsIssue } from "../../../data/repairs";
|
import type { RepairsIssue } from "../../../data/repairs";
|
||||||
@@ -26,11 +25,12 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
|
|
||||||
@state() private _params?: RepairsIssueDialogParams;
|
@state() private _params?: RepairsIssueDialogParams;
|
||||||
|
|
||||||
@query("ha-md-dialog") private _dialog?: HaMdDialog;
|
@state() private _open = false;
|
||||||
|
|
||||||
public showDialog(params: RepairsIssueDialogParams): void {
|
public showDialog(params: RepairsIssueDialogParams): void {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
this._issue = this._params.issue;
|
this._issue = this._params.issue;
|
||||||
|
this._open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dialogClosed() {
|
private _dialogClosed() {
|
||||||
@@ -44,7 +44,7 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog() {
|
public closeDialog() {
|
||||||
this._dialog?.close();
|
this._open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -62,32 +62,19 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
) || this.hass!.localize("ui.panel.config.repairs.dialog.title");
|
) || this.hass!.localize("ui.panel.config.repairs.dialog.title");
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-md-dialog
|
<ha-wa-dialog
|
||||||
open
|
.hass=${this.hass}
|
||||||
@closed=${this._dialogClosed}
|
.open=${this._open}
|
||||||
aria-labelledby="dialog-repairs-issue-title"
|
header-title=${dialogTitle}
|
||||||
aria-describedby="dialog-repairs-issue-description"
|
aria-describedby="dialog-repairs-issue-description"
|
||||||
|
@closed=${this._dialogClosed}
|
||||||
>
|
>
|
||||||
<ha-dialog-header slot="headline">
|
<dialog-repairs-issue-subtitle
|
||||||
<ha-icon-button
|
slot="headerSubtitle"
|
||||||
slot="navigationIcon"
|
.hass=${this.hass}
|
||||||
.label=${this.hass.localize("ui.common.close") ?? "Close"}
|
.issue=${this._issue}
|
||||||
.path=${mdiClose}
|
></dialog-repairs-issue-subtitle>
|
||||||
@click=${this.closeDialog}
|
<div class="dialog-content">
|
||||||
></ha-icon-button>
|
|
||||||
<span
|
|
||||||
slot="title"
|
|
||||||
id="dialog-repairs-issue-title"
|
|
||||||
.title=${dialogTitle}
|
|
||||||
>${dialogTitle}</span
|
|
||||||
>
|
|
||||||
<dialog-repairs-issue-subtitle
|
|
||||||
slot="subtitle"
|
|
||||||
.hass=${this.hass}
|
|
||||||
.issue=${this._issue}
|
|
||||||
></dialog-repairs-issue-subtitle>
|
|
||||||
</ha-dialog-header>
|
|
||||||
<div slot="content" class="dialog-content">
|
|
||||||
${this._issue.breaks_in_ha_version
|
${this._issue.breaks_in_ha_version
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="warning">
|
<ha-alert alert-type="warning">
|
||||||
@@ -122,8 +109,12 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div slot="actions">
|
<ha-dialog-footer slot="footer">
|
||||||
<ha-button appearance="plain" @click=${this._ignoreIssue}>
|
<ha-button
|
||||||
|
slot="secondaryAction"
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._ignoreIssue}
|
||||||
|
>
|
||||||
${this._issue!.ignored
|
${this._issue!.ignored
|
||||||
? this.hass!.localize("ui.panel.config.repairs.dialog.unignore")
|
? this.hass!.localize("ui.panel.config.repairs.dialog.unignore")
|
||||||
: this.hass!.localize("ui.panel.config.repairs.dialog.ignore")}
|
: this.hass!.localize("ui.panel.config.repairs.dialog.ignore")}
|
||||||
@@ -131,6 +122,7 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
${this._issue.learn_more_url
|
${this._issue.learn_more_url
|
||||||
? html`
|
? html`
|
||||||
<ha-button
|
<ha-button
|
||||||
|
slot="primaryAction"
|
||||||
appearance="filled"
|
appearance="filled"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
href=${learnMoreUrlIsHomeAssistant
|
href=${learnMoreUrlIsHomeAssistant
|
||||||
@@ -149,8 +141,8 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
</ha-button>
|
</ha-button>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</ha-dialog-footer>
|
||||||
</ha-md-dialog>
|
</ha-wa-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +164,7 @@ class DialogRepairsIssue extends LitElement {
|
|||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
ha-alert {
|
ha-alert {
|
||||||
margin-bottom: 16px;
|
margin-bottom: var(--ha-space-4);
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.dismissed {
|
.dismissed {
|
||||||
|
|||||||
@@ -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`
|
||||||
|
|||||||
@@ -148,7 +148,9 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
).pipeline_runs.reverse();
|
).pipeline_runs.reverse();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Failed to fetch pipeline runs",
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.fetch_runs"
|
||||||
|
),
|
||||||
text: e.message,
|
text: e.message,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -176,7 +178,9 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
).events;
|
).events;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Failed to fetch events",
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.fetch_events"
|
||||||
|
),
|
||||||
text: e.message,
|
text: e.message,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,16 +30,26 @@ export class AssistPipelineEvents extends LitElement {
|
|||||||
const run = this._processEvents(this.events);
|
const run = this._processEvents(this.events);
|
||||||
if (!run) {
|
if (!run) {
|
||||||
if (this.events.length) {
|
if (this.events.length) {
|
||||||
return html`<ha-alert alert-type="error">Error showing run</ha-alert>
|
return html`<ha-alert alert-type="error"
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.showing_run"
|
||||||
|
)}</ha-alert
|
||||||
|
>
|
||||||
<ha-card>
|
<ha-card>
|
||||||
<ha-expansion-panel>
|
<ha-expansion-panel>
|
||||||
<span slot="header">Raw</span>
|
<span slot="header"
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.raw"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
<pre>${JSON.stringify(this.events, null, 2)}</pre>
|
<pre>${JSON.stringify(this.events, null, 2)}</pre>
|
||||||
</ha-expansion-panel>
|
</ha-expansion-panel>
|
||||||
</ha-card>`;
|
</ha-card>`;
|
||||||
}
|
}
|
||||||
return html`<ha-alert alert-type="warning"
|
return html`<ha-alert alert-type="warning"
|
||||||
>There were no events in this run.</ha-alert
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.no_events"
|
||||||
|
)}</ha-alert
|
||||||
>`;
|
>`;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
|
|||||||
@@ -11,31 +11,16 @@ import type { HomeAssistant } from "../../../../types";
|
|||||||
import { formatNumber } from "../../../../common/number/format_number";
|
import { formatNumber } from "../../../../common/number/format_number";
|
||||||
import "../../../../components/ha-yaml-editor";
|
import "../../../../components/ha-yaml-editor";
|
||||||
import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box";
|
import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||||
|
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||||
|
|
||||||
const RUN_DATA = {
|
const RUN_DATA = ["pipeline", "language"];
|
||||||
pipeline: "Pipeline",
|
const WAKE_WORD_DATA = ["engine"];
|
||||||
language: "Language",
|
|
||||||
};
|
|
||||||
const WAKE_WORD_DATA = {
|
|
||||||
engine: "Engine",
|
|
||||||
};
|
|
||||||
|
|
||||||
const STT_DATA = {
|
const STT_DATA = ["engine"];
|
||||||
engine: "Engine",
|
|
||||||
};
|
|
||||||
|
|
||||||
const INTENT_DATA = {
|
const INTENT_DATA = ["engine", "language", "intent_input"];
|
||||||
engine: "Engine",
|
|
||||||
language: "Language",
|
|
||||||
intent_input: "Input",
|
|
||||||
};
|
|
||||||
|
|
||||||
const TTS_DATA = {
|
const TTS_DATA = ["engine", "language", "voice", "tts_input"];
|
||||||
engine: "Engine",
|
|
||||||
language: "Language",
|
|
||||||
voice: "Voice",
|
|
||||||
tts_input: "Input",
|
|
||||||
};
|
|
||||||
|
|
||||||
const STAGES: Record<PipelineRun["stage"], number> = {
|
const STAGES: Record<PipelineRun["stage"], number> = {
|
||||||
ready: 0,
|
ready: 0,
|
||||||
@@ -102,24 +87,32 @@ const renderProgress = (
|
|||||||
return html`${durationString}s ✅`;
|
return html`${durationString}s ✅`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderData = (data: Record<string, any>, keys: Record<string, string>) =>
|
const renderData = (
|
||||||
Object.entries(keys).map(
|
hass: HomeAssistant,
|
||||||
([key, label]) => html`
|
data: Record<string, any>,
|
||||||
|
keys: string[]
|
||||||
|
) =>
|
||||||
|
keys.map((key) => {
|
||||||
|
const label = hass.localize(
|
||||||
|
`ui.panel.config.voice_assistants.debug.stages.${key}` as LocalizeKeys
|
||||||
|
);
|
||||||
|
return html`
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>${label}</div>
|
<div>${label}</div>
|
||||||
<div>${data[key]}</div>
|
<div>${data[key]}</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`;
|
||||||
);
|
});
|
||||||
|
|
||||||
const dataMinusKeysRender = (
|
const dataMinusKeysRender = (
|
||||||
|
hass: HomeAssistant,
|
||||||
data: Record<string, any>,
|
data: Record<string, any>,
|
||||||
keys: Record<string, string>
|
keys: string[]
|
||||||
) => {
|
) => {
|
||||||
const result = {};
|
const result = {};
|
||||||
let render = false;
|
let render = false;
|
||||||
for (const key in data) {
|
for (const key in data) {
|
||||||
if (key in keys || key === "done") {
|
if (keys.includes(key) || key === "done") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
render = true;
|
render = true;
|
||||||
@@ -127,7 +120,9 @@ const dataMinusKeysRender = (
|
|||||||
}
|
}
|
||||||
return render
|
return render
|
||||||
? html`<ha-expansion-panel>
|
? html`<ha-expansion-panel>
|
||||||
<span slot="header">Raw</span>
|
<span slot="header"
|
||||||
|
>${hass.localize("ui.panel.config.voice_assistants.debug.raw")}</span
|
||||||
|
>
|
||||||
<ha-yaml-editor readOnly autoUpdate .value=${result}></ha-yaml-editor>
|
<ha-yaml-editor readOnly autoUpdate .value=${result}></ha-yaml-editor>
|
||||||
</ha-expansion-panel>`
|
</ha-expansion-panel>`
|
||||||
: "";
|
: "";
|
||||||
@@ -139,6 +134,12 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public pipelineRun!: PipelineRun;
|
@property({ attribute: false }) public pipelineRun!: PipelineRun;
|
||||||
|
|
||||||
|
private _audioElement?: HTMLAudioElement;
|
||||||
|
|
||||||
|
private get _isPlaying(): boolean {
|
||||||
|
return this._audioElement != null && !this._audioElement.paused;
|
||||||
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const lastRunStage: string = this.pipelineRun
|
const lastRunStage: string = this.pipelineRun
|
||||||
? ["tts", "intent", "stt", "wake_word"].find(
|
? ["tts", "intent", "stt", "wake_word"].find(
|
||||||
@@ -177,11 +178,15 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row heading">
|
<div class="row heading">
|
||||||
<div>Run</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.run"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>${this.pipelineRun.stage}</div>
|
<div>${this.pipelineRun.stage}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${renderData(this.pipelineRun.run, RUN_DATA)}
|
${renderData(this.hass, this.pipelineRun.run, RUN_DATA)}
|
||||||
${messages.length > 0
|
${messages.length > 0
|
||||||
? html`
|
? html`
|
||||||
<div class="messages">
|
<div class="messages">
|
||||||
@@ -203,23 +208,39 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row heading">
|
<div class="row heading">
|
||||||
<span>Wake word</span>
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.wake_word"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
${renderProgress(this.hass, this.pipelineRun, "wake_word")}
|
${renderProgress(this.hass, this.pipelineRun, "wake_word")}
|
||||||
</div>
|
</div>
|
||||||
${this.pipelineRun.wake_word
|
${this.pipelineRun.wake_word
|
||||||
? html`
|
? html`
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${renderData(this.pipelineRun.wake_word, STT_DATA)}
|
${renderData(
|
||||||
|
this.hass,
|
||||||
|
this.pipelineRun.wake_word,
|
||||||
|
WAKE_WORD_DATA
|
||||||
|
)}
|
||||||
${this.pipelineRun.wake_word.wake_word_output
|
${this.pipelineRun.wake_word.wake_word_output
|
||||||
? html`<div class="row">
|
? html`<div class="row">
|
||||||
<div>Model</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.model"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.wake_word.wake_word_output
|
${this.pipelineRun.wake_word.wake_word_output
|
||||||
.ww_id}
|
.ww_id}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>Timestamp</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.timestamp"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.wake_word.wake_word_output
|
${this.pipelineRun.wake_word.wake_word_output
|
||||||
.timestamp}
|
.timestamp}
|
||||||
@@ -227,6 +248,7 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
</div>`
|
</div>`
|
||||||
: ""}
|
: ""}
|
||||||
${dataMinusKeysRender(
|
${dataMinusKeysRender(
|
||||||
|
this.hass,
|
||||||
this.pipelineRun.wake_word,
|
this.pipelineRun.wake_word,
|
||||||
WAKE_WORD_DATA
|
WAKE_WORD_DATA
|
||||||
)}
|
)}
|
||||||
@@ -243,7 +265,11 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row heading">
|
<div class="row heading">
|
||||||
<span>Speech-to-text</span>
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.speech_to_text"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
${renderProgress(
|
${renderProgress(
|
||||||
this.hass,
|
this.hass,
|
||||||
this.pipelineRun,
|
this.pipelineRun,
|
||||||
@@ -254,18 +280,30 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
${this.pipelineRun.stt
|
${this.pipelineRun.stt
|
||||||
? html`
|
? html`
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${renderData(this.pipelineRun.stt, STT_DATA)}
|
${renderData(this.hass, this.pipelineRun.stt, STT_DATA)}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>Language</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.language"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>${this.pipelineRun.stt.metadata.language}</div>
|
<div>${this.pipelineRun.stt.metadata.language}</div>
|
||||||
</div>
|
</div>
|
||||||
${this.pipelineRun.stt.stt_output
|
${this.pipelineRun.stt.stt_output
|
||||||
? html`<div class="row">
|
? html`<div class="row">
|
||||||
<div>Output</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.output"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>${this.pipelineRun.stt.stt_output.text}</div>
|
<div>${this.pipelineRun.stt.stt_output.text}</div>
|
||||||
</div>`
|
</div>`
|
||||||
: ""}
|
: ""}
|
||||||
${dataMinusKeysRender(this.pipelineRun.stt, STT_DATA)}
|
${dataMinusKeysRender(
|
||||||
|
this.hass,
|
||||||
|
this.pipelineRun.stt,
|
||||||
|
STT_DATA
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@@ -279,16 +317,28 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row heading">
|
<div class="row heading">
|
||||||
<span>Natural Language Processing</span>
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.natural_language_processing"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
${renderProgress(this.hass, this.pipelineRun, "intent")}
|
${renderProgress(this.hass, this.pipelineRun, "intent")}
|
||||||
</div>
|
</div>
|
||||||
${this.pipelineRun.intent
|
${this.pipelineRun.intent
|
||||||
? html`
|
? html`
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${renderData(this.pipelineRun.intent, INTENT_DATA)}
|
${renderData(
|
||||||
|
this.hass,
|
||||||
|
this.pipelineRun.intent,
|
||||||
|
INTENT_DATA
|
||||||
|
)}
|
||||||
${this.pipelineRun.intent.intent_output
|
${this.pipelineRun.intent.intent_output
|
||||||
? html`<div class="row">
|
? html`<div class="row">
|
||||||
<div>Response type</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.response_type"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.intent.intent_output
|
${this.pipelineRun.intent.intent_output
|
||||||
.response.response_type}
|
.response.response_type}
|
||||||
@@ -297,7 +347,11 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
${this.pipelineRun.intent.intent_output.response
|
${this.pipelineRun.intent.intent_output.response
|
||||||
.response_type === "error"
|
.response_type === "error"
|
||||||
? html`<div class="row">
|
? html`<div class="row">
|
||||||
<div>Error code</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.code"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.intent.intent_output
|
${this.pipelineRun.intent.intent_output
|
||||||
.response.data.code}
|
.response.data.code}
|
||||||
@@ -306,18 +360,27 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
: ""}`
|
: ""}`
|
||||||
: ""}
|
: ""}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>Prefer handling locally</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.prefer_local"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.intent.prefer_local_intents}
|
${this.pipelineRun.intent.prefer_local_intents}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>Processed locally</div>
|
<div>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.processed_locally"
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
${this.pipelineRun.intent.processed_locally}
|
${this.pipelineRun.intent.processed_locally}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${dataMinusKeysRender(
|
${dataMinusKeysRender(
|
||||||
|
this.hass,
|
||||||
this.pipelineRun.intent,
|
this.pipelineRun.intent,
|
||||||
INTENT_DATA
|
INTENT_DATA
|
||||||
)}
|
)}
|
||||||
@@ -334,14 +397,22 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="row heading">
|
<div class="row heading">
|
||||||
<span>Text-to-speech</span>
|
<span
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stages.text_to_speech"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
${renderProgress(this.hass, this.pipelineRun, "tts")}
|
${renderProgress(this.hass, this.pipelineRun, "tts")}
|
||||||
</div>
|
</div>
|
||||||
${this.pipelineRun.tts
|
${this.pipelineRun.tts
|
||||||
? html`
|
? html`
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${renderData(this.pipelineRun.tts, TTS_DATA)}
|
${renderData(this.hass, this.pipelineRun.tts, TTS_DATA)}
|
||||||
${dataMinusKeysRender(this.pipelineRun.tts, TTS_DATA)}
|
${dataMinusKeysRender(
|
||||||
|
this.hass,
|
||||||
|
this.pipelineRun.tts,
|
||||||
|
TTS_DATA
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@@ -349,8 +420,19 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
${this.pipelineRun?.tts?.tts_output
|
${this.pipelineRun?.tts?.tts_output
|
||||||
? html`
|
? html`
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-button @click=${this._playTTS}>
|
<ha-button
|
||||||
Play Audio
|
.variant=${this._isPlaying ? "danger" : "brand"}
|
||||||
|
@click=${this._isPlaying
|
||||||
|
? this._stopTTS
|
||||||
|
: this._playTTS}
|
||||||
|
>
|
||||||
|
${this._isPlaying
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.stop_audio"
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.play_audio"
|
||||||
|
)}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -361,7 +443,11 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
${maybeRenderError(this.pipelineRun, "tts", lastRunStage)}
|
${maybeRenderError(this.pipelineRun, "tts", lastRunStage)}
|
||||||
<ha-card>
|
<ha-card>
|
||||||
<ha-expansion-panel>
|
<ha-expansion-panel>
|
||||||
<span slot="header">Raw</span>
|
<span slot="header"
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.raw"
|
||||||
|
)}</span
|
||||||
|
>
|
||||||
<ha-yaml-editor
|
<ha-yaml-editor
|
||||||
read-only
|
read-only
|
||||||
auto-update
|
auto-update
|
||||||
@@ -373,14 +459,48 @@ export class AssistPipelineDebug extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _playTTS(): void {
|
private _playTTS(): void {
|
||||||
|
// Stop any existing audio first
|
||||||
|
this._stopTTS();
|
||||||
|
|
||||||
const url = this.pipelineRun!.tts!.tts_output!.url;
|
const url = this.pipelineRun!.tts!.tts_output!.url;
|
||||||
const audio = new Audio(url);
|
this._audioElement = new Audio(url);
|
||||||
audio.addEventListener("error", () => {
|
|
||||||
showAlertDialog(this, { title: "Error", text: "Error playing audio" });
|
this._audioElement.addEventListener("error", () => {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.title"
|
||||||
|
),
|
||||||
|
text: this.hass.localize(
|
||||||
|
"ui.panel.config.voice_assistants.debug.error.playing_audio"
|
||||||
|
),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
audio.addEventListener("canplaythrough", () => {
|
|
||||||
audio.play();
|
this._audioElement.addEventListener("play", () => {
|
||||||
|
this.requestUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._audioElement.addEventListener("ended", () => {
|
||||||
|
this.requestUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
|
this._audioElement.addEventListener("canplaythrough", () => {
|
||||||
|
this._audioElement!.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private _stopTTS(): void {
|
||||||
|
if (this._audioElement) {
|
||||||
|
this._audioElement.pause();
|
||||||
|
this._audioElement.currentTime = 0;
|
||||||
|
this._audioElement = undefined;
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback(): void {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._stopTTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
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",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
generateEntityFilter,
|
generateEntityFilter,
|
||||||
type EntityFilter,
|
type EntityFilter,
|
||||||
} from "../../../common/entity/entity_filter";
|
} from "../../../common/entity/entity_filter";
|
||||||
|
import { floorDefaultIcon } from "../../../components/ha-floor-icon";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||||
@@ -60,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(
|
||||||
@@ -98,6 +117,7 @@ export class LightViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -134,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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export class HaLogbook extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public deviceIds?: string[];
|
@property({ attribute: false }) public deviceIds?: string[];
|
||||||
|
|
||||||
|
@property({ attribute: false }) public stateFilter?: string[];
|
||||||
|
|
||||||
@property({ type: Boolean }) public narrow = false;
|
@property({ type: Boolean }) public narrow = false;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public virtualize = false;
|
@property({ type: Boolean, reflect: true }) public virtualize = false;
|
||||||
@@ -165,7 +167,7 @@ export class HaLogbook extends LitElement {
|
|||||||
protected willUpdate(changedProps: PropertyValues): void {
|
protected willUpdate(changedProps: PropertyValues): void {
|
||||||
let changed = changedProps.has("time");
|
let changed = changedProps.has("time");
|
||||||
|
|
||||||
for (const key of ["entityIds", "deviceIds"]) {
|
for (const key of ["entityIds", "deviceIds", "stateFilter"]) {
|
||||||
if (!changedProps.has(key)) {
|
if (!changedProps.has(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -352,9 +354,19 @@ export class HaLogbook extends LitElement {
|
|||||||
"recent" in this.time
|
"recent" in this.time
|
||||||
? findStartOfRecentTime(new Date(), this.time.recent)
|
? findStartOfRecentTime(new Date(), this.time.recent)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
let eventsFiltered: LogbookEntry[] | undefined;
|
||||||
|
if (this.stateFilter && this.stateFilter.length > 0) {
|
||||||
|
eventsFiltered = streamMessage.events.filter(
|
||||||
|
(e) => e.state && this.stateFilter?.includes(e.state)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
eventsFiltered = [...streamMessage.events];
|
||||||
|
}
|
||||||
|
|
||||||
// Put newest ones on top. Reverse works in-place so
|
// Put newest ones on top. Reverse works in-place so
|
||||||
// make a copy first.
|
// make a copy first.
|
||||||
const newEntries = [...streamMessage.events].reverse();
|
const newEntries = eventsFiltered.reverse();
|
||||||
if (!this._logbookEntries || !this._logbookEntries.length) {
|
if (!this._logbookEntries || !this._logbookEntries.length) {
|
||||||
this._logbookEntries = newEntries;
|
this._logbookEntries = newEntries;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,14 +2,11 @@ import type { PropertyValues } from "lit";
|
|||||||
import { ReactiveElement } from "lit";
|
import { ReactiveElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import {
|
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||||
attachConditionMediaQueriesListeners,
|
import { checkConditionsMet } from "../common/validate-condition";
|
||||||
checkConditionsMet,
|
|
||||||
} from "../common/validate-condition";
|
|
||||||
import { createBadgeElement } from "../create-element/create-badge-element";
|
import { createBadgeElement } from "../create-element/create-badge-element";
|
||||||
import { createErrorBadgeConfig } from "../create-element/create-element-base";
|
import { createErrorBadgeConfig } from "../create-element/create-element-base";
|
||||||
import type { LovelaceBadge } from "../types";
|
import type { LovelaceBadge } from "../types";
|
||||||
@@ -22,7 +19,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@customElement("hui-badge")
|
@customElement("hui-badge")
|
||||||
export class HuiBadge extends ReactiveElement {
|
export class HuiBadge extends ConditionalListenerMixin(ReactiveElement) {
|
||||||
@property({ type: Boolean }) public preview = false;
|
@property({ type: Boolean }) public preview = false;
|
||||||
|
|
||||||
@property({ attribute: false }) public config?: LovelaceBadgeConfig;
|
@property({ attribute: false }) public config?: LovelaceBadgeConfig;
|
||||||
@@ -40,20 +37,16 @@ export class HuiBadge extends ReactiveElement {
|
|||||||
|
|
||||||
private _element?: LovelaceBadge;
|
private _element?: LovelaceBadge;
|
||||||
|
|
||||||
private _listeners: MediaQueriesListener[] = [];
|
|
||||||
|
|
||||||
protected createRenderRoot() {
|
protected createRenderRoot() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._clearMediaQueries();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._listenMediaQueries();
|
|
||||||
this._updateVisibility();
|
this._updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,30 +130,6 @@ export class HuiBadge extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearMediaQueries() {
|
|
||||||
this._listeners.forEach((unsub) => unsub());
|
|
||||||
this._listeners = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private _listenMediaQueries() {
|
|
||||||
this._clearMediaQueries();
|
|
||||||
if (!this.config?.visibility) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const conditions = this.config.visibility;
|
|
||||||
const hasOnlyMediaQuery =
|
|
||||||
conditions.length === 1 &&
|
|
||||||
conditions[0].condition === "screen" &&
|
|
||||||
!!conditions[0].media_query;
|
|
||||||
|
|
||||||
this._listeners = attachConditionMediaQueriesListeners(
|
|
||||||
this.config.visibility,
|
|
||||||
(matches) => {
|
|
||||||
this._updateVisibility(hasOnlyMediaQuery && matches);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _updateVisibility(ignoreConditions?: boolean) {
|
private _updateVisibility(ignoreConditions?: boolean) {
|
||||||
if (!this._element || !this.hass) {
|
if (!this._element || !this.hass) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -80,41 +80,44 @@ export class HuiEnergyCompareCard
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-alert dismissable @alert-dismissed-clicked=${this._stopCompare}>
|
<ha-alert dismissable @alert-dismissed-clicked=${this._stopCompare}>
|
||||||
${this.hass.localize("ui.panel.energy.compare.info", {
|
${this.hass.localize(
|
||||||
start: html`<b
|
"ui.panel.lovelace.cards.energy.energy_compare.info",
|
||||||
>${formatDate(
|
{
|
||||||
this._start!,
|
start: html`<b
|
||||||
this.hass.locale,
|
>${formatDate(
|
||||||
this.hass.config
|
this._start!,
|
||||||
)}${dayDifference > 0
|
this.hass.locale,
|
||||||
? ` -
|
this.hass.config
|
||||||
|
)}${dayDifference > 0
|
||||||
|
? ` -
|
||||||
${formatDate(
|
${formatDate(
|
||||||
this._end || endOfDay(new Date()),
|
this._end || endOfDay(new Date()),
|
||||||
this.hass.locale,
|
this.hass.locale,
|
||||||
this.hass.config
|
this.hass.config
|
||||||
)}`
|
)}`
|
||||||
: ""}</b
|
|
||||||
>`,
|
|
||||||
end: html`<b
|
|
||||||
>${formatDate(
|
|
||||||
this._startCompare,
|
|
||||||
this.hass.locale,
|
|
||||||
this.hass.config
|
|
||||||
)}${dayDifference > 0
|
|
||||||
? ` -
|
|
||||||
${formatDate(this._endCompare, this.hass.locale, this.hass.config)}`
|
|
||||||
: ""}</b
|
: ""}</b
|
||||||
>
|
>`,
|
||||||
<button class="link" @click=${this._changeCompareMode}>
|
end: html`<b
|
||||||
(${this._compareMode === CompareMode.PREVIOUS
|
>${formatDate(
|
||||||
? this.hass.localize(
|
this._startCompare,
|
||||||
"ui.panel.energy.compare.compare_previous_year"
|
this.hass.locale,
|
||||||
)
|
this.hass.config
|
||||||
: this.hass.localize(
|
)}${dayDifference > 0
|
||||||
"ui.panel.energy.compare.compare_previous_period"
|
? ` -
|
||||||
)})
|
${formatDate(this._endCompare, this.hass.locale, this.hass.config)}`
|
||||||
</button>`,
|
: ""}</b
|
||||||
})}
|
>
|
||||||
|
<button class="link" @click=${this._changeCompareMode}>
|
||||||
|
(${this._compareMode === CompareMode.PREVIOUS
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_compare.compare_previous_year"
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_compare.compare_previous_period"
|
||||||
|
)})
|
||||||
|
</button>`,
|
||||||
|
}
|
||||||
|
)}
|
||||||
</ha-alert>
|
</ha-alert>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import { measureTextWidth } from "../../../../util/text";
|
|||||||
import "../../../../components/ha-icon-button";
|
import "../../../../components/ha-icon-button";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
||||||
|
import { getEnergyColor } from "./common/color";
|
||||||
|
import type { CustomLegendOption } from "../../../../components/chart/ha-chart-base";
|
||||||
|
|
||||||
@customElement("hui-energy-devices-graph-card")
|
@customElement("hui-energy-devices-graph-card")
|
||||||
export class HuiEnergyDevicesGraphCard
|
export class HuiEnergyDevicesGraphCard
|
||||||
@@ -49,6 +51,8 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
|
@state() private _legendData: NonNullable<CustomLegendOption["data"]> = [];
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@storage({
|
@storage({
|
||||||
key: "energy-devices-graph-chart-type",
|
key: "energy-devices-graph-chart-type",
|
||||||
@@ -57,6 +61,14 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
})
|
})
|
||||||
private _chartType: "bar" | "pie" = "bar";
|
private _chartType: "bar" | "pie" = "bar";
|
||||||
|
|
||||||
|
@state()
|
||||||
|
@storage({
|
||||||
|
key: "energy-devices-pie-hidden-stats",
|
||||||
|
state: true,
|
||||||
|
subscribe: false,
|
||||||
|
})
|
||||||
|
private _hiddenStats: string[] = [];
|
||||||
|
|
||||||
@state() private _isMobile = false;
|
@state() private _isMobile = false;
|
||||||
|
|
||||||
private _compoundStats: string[] = [];
|
private _compoundStats: string[] = [];
|
||||||
@@ -121,10 +133,16 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.data=${this._chartData}
|
.data=${this._chartData}
|
||||||
.options=${this._createOptions(this._chartData, this._chartType)}
|
.options=${this._createOptions(
|
||||||
.height=${`${Math.max(300, (this._chartData[0]?.data?.length || 0) * 28 + 50)}px`}
|
this._chartData,
|
||||||
@chart-click=${this._handleChartClick}
|
this._chartType,
|
||||||
|
this._legendData
|
||||||
|
)}
|
||||||
|
.height=${`${Math.max(300, (this._legendData?.length || 0) * 28 + 50)}px`}
|
||||||
.extraComponents=${[PieChart]}
|
.extraComponents=${[PieChart]}
|
||||||
|
@chart-click=${this._handleChartClick}
|
||||||
|
@dataset-hidden=${this._datasetHidden}
|
||||||
|
@dataset-unhidden=${this._datasetUnhidden}
|
||||||
></ha-chart-base>
|
></ha-chart-base>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
@@ -145,7 +163,8 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
private _createOptions = memoizeOne(
|
private _createOptions = memoizeOne(
|
||||||
(
|
(
|
||||||
data: (BarSeriesOption | PieSeriesOption)[],
|
data: (BarSeriesOption | PieSeriesOption)[],
|
||||||
chartType: "bar" | "pie"
|
chartType: "bar" | "pie",
|
||||||
|
legendData: typeof this._legendData
|
||||||
): ECOption => {
|
): ECOption => {
|
||||||
const options: ECOption = {
|
const options: ECOption = {
|
||||||
grid: {
|
grid: {
|
||||||
@@ -161,6 +180,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
},
|
},
|
||||||
xAxis: { show: false },
|
xAxis: { show: false },
|
||||||
yAxis: { show: false },
|
yAxis: { show: false },
|
||||||
|
legend: { type: "custom", show: false },
|
||||||
};
|
};
|
||||||
if (chartType === "bar") {
|
if (chartType === "bar") {
|
||||||
options.xAxis = {
|
options.xAxis = {
|
||||||
@@ -191,6 +211,18 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
options.legend = {
|
||||||
|
type: "custom",
|
||||||
|
show: true,
|
||||||
|
data: legendData,
|
||||||
|
selected: legendData
|
||||||
|
.filter((d) => d.id && this._hiddenStats.includes(d.id))
|
||||||
|
.reduce((acc, d) => {
|
||||||
|
acc[d.id!] = false;
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@@ -354,23 +386,12 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chartData.sort((a: any, b: any) => b.value[0] - a.value[0]);
|
|
||||||
if (compareData) {
|
|
||||||
datasets[1].data = chartData.map((d) =>
|
|
||||||
chartDataCompare.find((d2) => (d2 as any).id === d.id)
|
|
||||||
) as typeof chartDataCompare;
|
|
||||||
}
|
|
||||||
|
|
||||||
datasets.forEach((dataset) => {
|
|
||||||
dataset.data!.length = Math.min(
|
|
||||||
this._config?.max_devices || Infinity,
|
|
||||||
dataset.data!.length
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this._chartType === "pie") {
|
if (this._chartType === "pie") {
|
||||||
const { summedData } = getSummedData(energyData);
|
const { summedData, compareSummedData } = getSummedData(energyData);
|
||||||
const { consumption } = computeConsumptionData(summedData);
|
const { consumption, compareConsumption } = computeConsumptionData(
|
||||||
|
summedData,
|
||||||
|
compareSummedData
|
||||||
|
);
|
||||||
const totalUsed = consumption.total.used_total;
|
const totalUsed = consumption.total.used_total;
|
||||||
const showUntracked =
|
const showUntracked =
|
||||||
"from_grid" in summedData ||
|
"from_grid" in summedData ||
|
||||||
@@ -380,6 +401,47 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
? totalUsed -
|
? totalUsed -
|
||||||
chartData.reduce((acc: number, d: any) => acc + d.value[0], 0)
|
chartData.reduce((acc: number, d: any) => acc + d.value[0], 0)
|
||||||
: 0;
|
: 0;
|
||||||
|
if (untracked > 0) {
|
||||||
|
const color = getEnergyColor(
|
||||||
|
computedStyle,
|
||||||
|
this.hass.themes.darkMode,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
"--history-unknown-color"
|
||||||
|
);
|
||||||
|
chartData.push({
|
||||||
|
id: "untracked",
|
||||||
|
value: [untracked, "untracked"] as any,
|
||||||
|
name: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_devices_graph.untracked_consumption"
|
||||||
|
),
|
||||||
|
itemStyle: {
|
||||||
|
color: color + "7F",
|
||||||
|
borderColor: color,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (compareData) {
|
||||||
|
const compareUntracked =
|
||||||
|
compareConsumption!.total.used_total -
|
||||||
|
chartDataCompare.reduce(
|
||||||
|
(acc: number, d: any) => acc + d.value[0],
|
||||||
|
0
|
||||||
|
);
|
||||||
|
if (compareUntracked > 0) {
|
||||||
|
chartDataCompare.push({
|
||||||
|
id: "untracked",
|
||||||
|
value: [compareUntracked, "untracked"] as any,
|
||||||
|
name: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_devices_graph.untracked_consumption"
|
||||||
|
),
|
||||||
|
itemStyle: {
|
||||||
|
color: color + "32",
|
||||||
|
borderColor: color + "7F",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
datasets.push({
|
datasets.push({
|
||||||
type: "pie",
|
type: "pie",
|
||||||
radius: ["0%", compareData ? "30%" : "40%"],
|
radius: ["0%", compareData ? "30%" : "40%"],
|
||||||
@@ -401,17 +463,36 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
color: "rgba(0, 0, 0, 0)",
|
color: "rgba(0, 0, 0, 0)",
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: () =>
|
show: false,
|
||||||
untracked > 0
|
|
||||||
? this.hass.localize(
|
|
||||||
"ui.panel.lovelace.cards.energy.energy_devices_graph.includes_untracked",
|
|
||||||
{ num: formatNumber(untracked, this.hass.locale) }
|
|
||||||
)
|
|
||||||
: "",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chartData.sort((a: any, b: any) => b.value[0] - a.value[0]);
|
||||||
|
if (
|
||||||
|
this._config?.max_devices &&
|
||||||
|
chartData.length > this._config.max_devices
|
||||||
|
) {
|
||||||
|
chartData.splice(this._config.max_devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._legendData = chartData.map((d) => ({
|
||||||
|
...d,
|
||||||
|
name: this._getDeviceName(d.name),
|
||||||
|
}));
|
||||||
|
// filter out hidden stats in place
|
||||||
|
for (let i = chartData.length - 1; i >= 0; i--) {
|
||||||
|
if (this._hiddenStats.includes((chartData[i] as any).id)) {
|
||||||
|
chartData.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compareData) {
|
||||||
|
datasets[1].data = chartData.map((d) =>
|
||||||
|
chartDataCompare.find((d2) => (d2 as any).id === d.id)
|
||||||
|
) as typeof chartDataCompare;
|
||||||
|
}
|
||||||
|
|
||||||
this._chartData = datasets;
|
this._chartData = datasets;
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
@@ -440,6 +521,18 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
this._getStatistics(this._data!);
|
this._getStatistics(this._data!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _datasetHidden(ev: CustomEvent<{ id: string }>) {
|
||||||
|
this._hiddenStats = [...this._hiddenStats, ev.detail.id];
|
||||||
|
this._getStatistics(this._data!);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _datasetUnhidden(ev: CustomEvent<{ id: string }>) {
|
||||||
|
this._hiddenStats = this._hiddenStats.filter(
|
||||||
|
(stat) => stat !== ev.detail.id
|
||||||
|
);
|
||||||
|
this._getStatistics(this._data!);
|
||||||
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
@state() private _calendars: Calendar[] = [];
|
@state() private _calendars: Calendar[] = [];
|
||||||
|
|
||||||
@state() private _eventDisplay = "list-item";
|
|
||||||
|
|
||||||
@state() private _narrow = false;
|
@state() private _narrow = false;
|
||||||
|
|
||||||
@state() private _error?: string = undefined;
|
@state() private _error?: string = undefined;
|
||||||
@@ -137,13 +135,13 @@ 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}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.views=${views}
|
.views=${views}
|
||||||
.initialView=${this._config.initial_view!}
|
.initialView=${this._config.initial_view!}
|
||||||
.eventDisplay=${this._eventDisplay}
|
|
||||||
.error=${this._error}
|
.error=${this._error}
|
||||||
@view-changed=${this._handleViewChanged}
|
@view-changed=${this._handleViewChanged}
|
||||||
></ha-full-calendar>
|
></ha-full-calendar>
|
||||||
@@ -173,8 +171,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _handleViewChanged(ev: HASSDomEvent<CalendarViewChanged>): void {
|
private _handleViewChanged(ev: HASSDomEvent<CalendarViewChanged>): void {
|
||||||
this._eventDisplay =
|
|
||||||
ev.detail.view === "dayGridMonth" ? "list-item" : "auto";
|
|
||||||
this._startDate = ev.detail.start;
|
this._startDate = ev.detail.start;
|
||||||
this._endDate = ev.detail.end;
|
this._endDate = ev.detail.end;
|
||||||
this._fetchCalendarEvents();
|
this._fetchCalendarEvents();
|
||||||
@@ -229,6 +225,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 +236,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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,13 @@ import type { PropertyValues } from "lit";
|
|||||||
import { ReactiveElement } from "lit";
|
import { ReactiveElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||||
import { migrateLayoutToGridOptions } from "../common/compute-card-grid-size";
|
import { migrateLayoutToGridOptions } from "../common/compute-card-grid-size";
|
||||||
import { computeCardSize } from "../common/compute-card-size";
|
import { computeCardSize } from "../common/compute-card-size";
|
||||||
import {
|
import { checkConditionsMet } from "../common/validate-condition";
|
||||||
attachConditionMediaQueriesListeners,
|
|
||||||
checkConditionsMet,
|
|
||||||
} from "../common/validate-condition";
|
|
||||||
import { tryCreateCardElement } from "../create-element/create-card-element";
|
import { tryCreateCardElement } from "../create-element/create-card-element";
|
||||||
import { createErrorCardElement } from "../create-element/create-element-base";
|
import { createErrorCardElement } from "../create-element/create-element-base";
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
@@ -24,7 +21,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@customElement("hui-card")
|
@customElement("hui-card")
|
||||||
export class HuiCard extends ReactiveElement {
|
export class HuiCard extends ConditionalListenerMixin(ReactiveElement) {
|
||||||
@property({ type: Boolean }) public preview = false;
|
@property({ type: Boolean }) public preview = false;
|
||||||
|
|
||||||
@property({ attribute: false }) public config?: LovelaceCardConfig;
|
@property({ attribute: false }) public config?: LovelaceCardConfig;
|
||||||
@@ -44,20 +41,16 @@ export class HuiCard extends ReactiveElement {
|
|||||||
|
|
||||||
private _element?: LovelaceCard;
|
private _element?: LovelaceCard;
|
||||||
|
|
||||||
private _listeners: MediaQueriesListener[] = [];
|
|
||||||
|
|
||||||
protected createRenderRoot() {
|
protected createRenderRoot() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
this._clearMediaQueries();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._listenMediaQueries();
|
|
||||||
this._updateVisibility();
|
this._updateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,30 +244,6 @@ export class HuiCard extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearMediaQueries() {
|
|
||||||
this._listeners.forEach((unsub) => unsub());
|
|
||||||
this._listeners = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private _listenMediaQueries() {
|
|
||||||
this._clearMediaQueries();
|
|
||||||
if (!this.config?.visibility) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const conditions = this.config.visibility;
|
|
||||||
const hasOnlyMediaQuery =
|
|
||||||
conditions.length === 1 &&
|
|
||||||
conditions[0].condition === "screen" &&
|
|
||||||
!!conditions[0].media_query;
|
|
||||||
|
|
||||||
this._listeners = attachConditionMediaQueriesListeners(
|
|
||||||
this.config.visibility,
|
|
||||||
(matches) => {
|
|
||||||
this._updateVisibility(hasOnlyMediaQuery && matches);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _updateVisibility(ignoreConditions?: boolean) {
|
private _updateVisibility(ignoreConditions?: boolean) {
|
||||||
if (!this._element || !this.hass) {
|
if (!this._element || !this.hass) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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 { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
||||||
@@ -97,7 +98,10 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
: `${sandbox_user_params} ${IFRAME_SANDBOX}`;
|
: `${sandbox_user_params} ${IFRAME_SANDBOX}`;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card .header=${this._config.title}>
|
<ha-card
|
||||||
|
class=${classMap({ "hide-background": this._config.hide_background })}
|
||||||
|
.header=${this._config.title}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
id="root"
|
id="root"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
@@ -133,6 +137,12 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ha-card.hide-background {
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
@state() private _targetPickerValue: HassServiceTarget = {};
|
@state() private _targetPickerValue: HassServiceTarget = {};
|
||||||
|
|
||||||
|
@state() private _stateFilter?: string[];
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return 9 + (this._config?.title ? 1 : 0);
|
return 9 + (this._config?.title ? 1 : 0);
|
||||||
}
|
}
|
||||||
@@ -129,6 +131,8 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._targetPickerValue = target;
|
this._targetPickerValue = target;
|
||||||
|
|
||||||
|
this._stateFilter = ensureArray(config.state_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getEntityIds(): string[] | undefined {
|
private _getEntityIds(): string[] | undefined {
|
||||||
@@ -209,6 +213,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.time=${this._time}
|
.time=${this._time}
|
||||||
.entityIds=${this._getEntityIds()}
|
.entityIds=${this._getEntityIds()}
|
||||||
|
.stateFilter=${this._stateFilter}
|
||||||
narrow
|
narrow
|
||||||
relative-time
|
relative-time
|
||||||
virtualize
|
virtualize
|
||||||
|
|||||||
@@ -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] = stateObj
|
||||||
|
? 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"
|
||||||
@@ -323,6 +323,7 @@ export interface IframeCardConfig extends LovelaceCardConfig {
|
|||||||
title?: string;
|
title?: string;
|
||||||
allow?: string;
|
allow?: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
hide_background?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LightCardConfig extends LovelaceCardConfig {
|
export interface LightCardConfig extends LovelaceCardConfig {
|
||||||
@@ -345,9 +346,18 @@ export interface LogbookCardConfig extends LovelaceCardConfig {
|
|||||||
title?: string;
|
title?: string;
|
||||||
hours_to_show?: number;
|
hours_to_show?: number;
|
||||||
theme?: string;
|
theme?: string;
|
||||||
|
state_filter?: 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 +372,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 +444,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,28 +1,29 @@
|
|||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import {
|
|
||||||
DEFAULT_ENTITY_NAME,
|
|
||||||
type EntityNameItem,
|
|
||||||
} from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { HomeAssistant } from "../../../../types";
|
|
||||||
import { ensureArray } from "../../../../common/array/ensure-array";
|
import { ensureArray } from "../../../../common/array/ensure-array";
|
||||||
|
import type { EntityNameItem } from "../../../../common/entity/compute_entity_name_display";
|
||||||
|
import { computeStateName } from "../../../../common/entity/compute_state_name";
|
||||||
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the display name for an entity in Lovelace (cards and badges).
|
* Computes the display name for an entity in Lovelace (cards and badges).
|
||||||
*
|
*
|
||||||
* @param hass - The Home Assistant instance
|
* @param hass - The Home Assistant instance
|
||||||
* @param stateObj - The entity state object
|
* @param stateObj - The entity state object
|
||||||
* @param nameConfig - The name configuration (string for override, or EntityNameItem[] for structured naming)
|
* @param config - The name configuration (string for override, or EntityNameItem[] for structured naming)
|
||||||
* @returns The computed entity name
|
* @returns The computed entity name
|
||||||
*/
|
*/
|
||||||
export const computeLovelaceEntityName = (
|
export const computeLovelaceEntityName = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
stateObj: HassEntity | undefined,
|
stateObj: HassEntity | undefined,
|
||||||
nameConfig: string | EntityNameItem | EntityNameItem[] | undefined
|
config: string | EntityNameItem | EntityNameItem[] | undefined
|
||||||
): string => {
|
): string => {
|
||||||
if (typeof nameConfig === "string") {
|
// If no config is provided, fall back to the default state name
|
||||||
return nameConfig;
|
if (!config) {
|
||||||
|
return stateObj ? computeStateName(stateObj) : "";
|
||||||
|
}
|
||||||
|
if (typeof config === "string") {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
const config = nameConfig || DEFAULT_ENTITY_NAME;
|
|
||||||
if (stateObj) {
|
if (stateObj) {
|
||||||
return hass.formatEntityName(stateObj, config);
|
return hass.formatEntityName(stateObj, config);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user