mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-07 18:09:47 +00:00
Compare commits
91 Commits
20251104.0
...
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 |
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.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
|
||||
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
# 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)
|
||||
- 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.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -57,4 +57,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- 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 = () => [];
|
||||
|
||||
// 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/font-icons.js"),
|
||||
// Icons in supervisor conflict with icons in HA so we don't load.
|
||||
isHassioBuild &&
|
||||
(isHassioBuild || isLandingPageBuild) &&
|
||||
require.resolve(
|
||||
path.resolve(paths.root_dir, "src/components/ha-icon.ts")
|
||||
),
|
||||
isHassioBuild &&
|
||||
(isHassioBuild || isLandingPageBuild) &&
|
||||
require.resolve(
|
||||
path.resolve(paths.root_dir, "src/components/ha-icon-picker.ts")
|
||||
),
|
||||
@@ -337,6 +337,7 @@ module.exports.config = {
|
||||
publicPath: publicPath(latestBuild),
|
||||
isProdBuild,
|
||||
latestBuild,
|
||||
isLandingPageBuild: true,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@ const createRspackConfig = ({
|
||||
isStatsBuild,
|
||||
isTestBuild,
|
||||
isHassioBuild,
|
||||
isLandingPageBuild,
|
||||
dontHash,
|
||||
}) => {
|
||||
if (!dontHash) {
|
||||
@@ -168,7 +169,9 @@ const createRspackConfig = ({
|
||||
},
|
||||
}),
|
||||
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")
|
||||
),
|
||||
!isProdBuild && new LogStartCompilePlugin(),
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
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 { extractSearchParam } from "../../src/common/url/search-params";
|
||||
import "../../src/components/ha-alert";
|
||||
import "../../src/components/ha-button";
|
||||
import "../../src/components/ha-fade-in";
|
||||
import "../../src/components/ha-spinner";
|
||||
import { haStyle } from "../../src/resources/styles";
|
||||
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 "../../src/components/ha-svg-icon";
|
||||
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 {
|
||||
getSupervisorNetworkInfo,
|
||||
pingSupervisor,
|
||||
type NetworkInfo,
|
||||
} from "./data/supervisor";
|
||||
import { LandingPageBaseElement } from "./landing-page-base-element";
|
||||
|
||||
export const ASSUME_CORE_START_SECONDS = 60;
|
||||
const SCHEDULE_CORE_CHECK_SECONDS = 1;
|
||||
@@ -94,16 +97,21 @@ class HaLandingPage extends LandingPageBaseElement {
|
||||
<ha-language-picker
|
||||
.value=${this.language}
|
||||
.label=${""}
|
||||
button-style
|
||||
native-name
|
||||
@value-changed=${this._languageChanged}
|
||||
inline-arrow
|
||||
></ha-language-picker>
|
||||
<a
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
variant="neutral"
|
||||
href="https://www.home-assistant.io/getting-started/onboarding/"
|
||||
target="_blank"
|
||||
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>
|
||||
`;
|
||||
}
|
||||
@@ -218,26 +226,8 @@ class HaLandingPage extends LandingPageBaseElement {
|
||||
ha-alert p {
|
||||
text-align: unset;
|
||||
}
|
||||
ha-language-picker {
|
||||
display: block;
|
||||
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;
|
||||
.footer ha-svg-icon {
|
||||
--mdc-icon-size: var(--ha-space-5);
|
||||
}
|
||||
ha-fade-in {
|
||||
min-height: calc(100vh - 64px - 88px);
|
||||
|
||||
36
package.json
36
package.json
@@ -52,7 +52,7 @@
|
||||
"@fullcalendar/list": "6.1.19",
|
||||
"@fullcalendar/luxon3": "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",
|
||||
"@lit-labs/motion": "1.0.9",
|
||||
"@lit-labs/observers": "2.0.6",
|
||||
@@ -81,7 +81,7 @@
|
||||
"@material/mwc-top-app-bar": "0.27.0",
|
||||
"@material/mwc-top-app-bar-fixed": "0.27.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/svg": "7.4.47",
|
||||
"@replit/codemirror-indentation-markers": "6.5.3",
|
||||
@@ -89,8 +89,8 @@
|
||||
"@thomasloven/round-slider": "0.6.0",
|
||||
"@tsparticles/engine": "3.9.1",
|
||||
"@tsparticles/preset-links": "3.2.0",
|
||||
"@vaadin/combo-box": "24.9.2",
|
||||
"@vaadin/vaadin-themable-mixin": "24.9.2",
|
||||
"@vaadin/combo-box": "24.9.4",
|
||||
"@vaadin/vaadin-themable-mixin": "24.9.4",
|
||||
"@vibrant/color": "4.0.0",
|
||||
"@vue/web-component-wrapper": "1.3.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.10",
|
||||
@@ -111,7 +111,7 @@
|
||||
"fuse.js": "7.1.0",
|
||||
"google-timezones-json": "1.2.0",
|
||||
"gulp-zopfli-green": "6.0.2",
|
||||
"hls.js": "1.6.13",
|
||||
"hls.js": "1.6.14",
|
||||
"home-assistant-js-websocket": "9.5.0",
|
||||
"idb-keyval": "6.2.2",
|
||||
"intl-messageformat": "10.7.18",
|
||||
@@ -152,13 +152,13 @@
|
||||
"@babel/helper-define-polyfill-provider": "0.6.5",
|
||||
"@babel/plugin-transform-runtime": "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",
|
||||
"@octokit/auth-oauth-device": "8.0.2",
|
||||
"@octokit/plugin-retry": "8.0.2",
|
||||
"@octokit/rest": "22.0.0",
|
||||
"@rsdoctor/rspack-plugin": "1.3.4",
|
||||
"@rspack/core": "1.5.8",
|
||||
"@octokit/auth-oauth-device": "8.0.3",
|
||||
"@octokit/plugin-retry": "8.0.3",
|
||||
"@octokit/rest": "22.0.1",
|
||||
"@rsdoctor/rspack-plugin": "1.3.7",
|
||||
"@rspack/core": "1.6.0",
|
||||
"@rspack/dev-server": "1.1.4",
|
||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||
"@types/chromecast-caf-receiver": "6.0.22",
|
||||
@@ -178,12 +178,12 @@
|
||||
"@types/tar": "6.1.13",
|
||||
"@types/ua-parser-js": "0.7.39",
|
||||
"@types/webspeechapi": "0.0.29",
|
||||
"@vitest/coverage-v8": "4.0.3",
|
||||
"@vitest/coverage-v8": "4.0.6",
|
||||
"babel-loader": "10.0.0",
|
||||
"babel-plugin-template-html-minifier": "4.1.0",
|
||||
"browserslist-useragent-regexp": "4.1.3",
|
||||
"del": "8.0.1",
|
||||
"eslint": "9.38.0",
|
||||
"eslint": "9.39.1",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-import-resolver-webpack": "0.13.10",
|
||||
@@ -201,7 +201,7 @@
|
||||
"gulp-rename": "2.1.0",
|
||||
"html-minifier-terser": "7.2.0",
|
||||
"husky": "9.1.7",
|
||||
"jsdom": "27.0.1",
|
||||
"jsdom": "27.1.0",
|
||||
"jszip": "3.10.1",
|
||||
"lint-staged": "16.2.6",
|
||||
"lit-analyzer": "2.0.3",
|
||||
@@ -213,13 +213,13 @@
|
||||
"rspack-manifest-plugin": "5.1.0",
|
||||
"serve": "14.2.5",
|
||||
"sinon": "21.0.0",
|
||||
"tar": "7.5.1",
|
||||
"tar": "7.5.2",
|
||||
"terser-webpack-plugin": "5.3.14",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "5.9.3",
|
||||
"typescript-eslint": "8.46.2",
|
||||
"typescript-eslint": "8.46.3",
|
||||
"vite-tsconfig-paths": "5.1.4",
|
||||
"vitest": "4.0.3",
|
||||
"vitest": "4.0.6",
|
||||
"webpack-stats-plugin": "1.1.3",
|
||||
"webpackbar": "7.0.0",
|
||||
"workbox-build": "patch:workbox-build@npm%3A7.1.1#~/.yarn/patches/workbox-build-npm-7.1.1-a854f3faae.patch"
|
||||
@@ -231,7 +231,7 @@
|
||||
"clean-css": "5.3.3",
|
||||
"@lit/reactive-element": "2.1.1",
|
||||
"@fullcalendar/daygrid": "6.1.19",
|
||||
"globals": "16.4.0",
|
||||
"globals": "16.5.0",
|
||||
"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"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "home-assistant-frontend"
|
||||
version = "20251104.0"
|
||||
version = "20251029.0"
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE*"]
|
||||
description = "The Home Assistant frontend"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable lit/prefer-static-styles */
|
||||
import { mdiOpenInNew } from "@mdi/js";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
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 { extractSearchParamsObject } from "../common/url/search-params";
|
||||
import "../components/ha-alert";
|
||||
import "../components/ha-button";
|
||||
import "../components/ha-svg-icon";
|
||||
import type { AuthProvider, AuthUrlSearchParams } from "../data/auth";
|
||||
import { fetchAuthProviders } from "../data/auth";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
@@ -133,25 +136,8 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
ha-language-picker {
|
||||
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;
|
||||
}
|
||||
.footer a {
|
||||
text-decoration: none;
|
||||
color: var(--primary-text-color);
|
||||
margin-right: 16px;
|
||||
margin-inline-end: 16px;
|
||||
margin-inline-start: initial;
|
||||
.footer ha-svg-icon {
|
||||
--mdc-icon-size: var(--ha-space-5);
|
||||
}
|
||||
h1 {
|
||||
font-size: var(--ha-font-size-3xl);
|
||||
@@ -205,16 +191,21 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
||||
<ha-language-picker
|
||||
.value=${this.language}
|
||||
.label=${""}
|
||||
button-style
|
||||
native-name
|
||||
@value-changed=${this._languageChanged}
|
||||
inline-arrow
|
||||
></ha-language-picker>
|
||||
<a
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
variant="neutral"
|
||||
href="https://www.home-assistant.io/docs/authentication/"
|
||||
target="_blank"
|
||||
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>
|
||||
`;
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
@@ -35,7 +35,6 @@ export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
|
||||
const LEGEND_OVERFLOW_LIMIT = 10;
|
||||
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
|
||||
const DOUBLE_TAP_TIME = 300;
|
||||
const RESIZE_ANIMATION_DURATION = 250;
|
||||
|
||||
export type CustomLegendOption = ECOption["legend"] & {
|
||||
type: "custom";
|
||||
@@ -91,6 +90,8 @@ export class HaChartBase extends LitElement {
|
||||
|
||||
private _shouldResizeChart = false;
|
||||
|
||||
private _resizeAnimationDuration?: number;
|
||||
|
||||
// @ts-ignore
|
||||
private _resizeController = new ResizeController(this, {
|
||||
callback: () => {
|
||||
@@ -214,6 +215,7 @@ export class HaChartBase extends LitElement {
|
||||
) {
|
||||
// custom legend changes may require a resize to layout properly
|
||||
this._shouldResizeChart = true;
|
||||
this._resizeAnimationDuration = 250;
|
||||
}
|
||||
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
|
||||
chartOptions.dataZoom = this._getDataZoomConfig();
|
||||
@@ -977,11 +979,14 @@ export class HaChartBase extends LitElement {
|
||||
private _handleChartRenderFinished = () => {
|
||||
if (this._shouldResizeChart) {
|
||||
this.chart?.resize({
|
||||
animation: this._reducedMotion
|
||||
? undefined
|
||||
: { duration: RESIZE_ANIMATION_DURATION },
|
||||
animation:
|
||||
this._reducedMotion ||
|
||||
typeof this._resizeAnimationDuration !== "number"
|
||||
? undefined
|
||||
: { duration: this._resizeAnimationDuration },
|
||||
});
|
||||
this._shouldResizeChart = false;
|
||||
this._resizeAnimationDuration = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ import type { EChartsType } from "echarts/core";
|
||||
import type { GraphSeriesOption } from "echarts/charts";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
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 memoizeOne from "memoize-one";
|
||||
import { listenMediaQuery } from "../../common/dom/media_query";
|
||||
@@ -16,6 +19,7 @@ import { deepEqual } from "../../common/util/deep-equal";
|
||||
export interface NetworkNode {
|
||||
id: string;
|
||||
name?: string;
|
||||
context?: string;
|
||||
category?: number;
|
||||
value?: number;
|
||||
symbolSize?: number;
|
||||
@@ -188,6 +192,25 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
||||
label: {
|
||||
show: showLabels,
|
||||
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: {
|
||||
focus: isMobile ? "none" : "adjacency",
|
||||
@@ -225,6 +248,7 @@ export class HaNetworkGraph extends SubscribeMixin(LitElement) {
|
||||
({
|
||||
id: node.id,
|
||||
name: node.name,
|
||||
context: node.context,
|
||||
category: node.category,
|
||||
value: node.value,
|
||||
symbolSize: node.symbolSize || 30,
|
||||
|
||||
@@ -87,6 +87,8 @@ export class HaAreaPicker extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public required = false;
|
||||
|
||||
@property({ attribute: "add-button-label" }) public addButtonLabel?: string;
|
||||
|
||||
@query("ha-generic-picker") private _picker?: HaGenericPicker;
|
||||
|
||||
public async open() {
|
||||
@@ -375,6 +377,7 @@ export class HaAreaPicker extends LitElement {
|
||||
.getItems=${this._getItems}
|
||||
.getAdditionalItems=${this._getAdditionalItems}
|
||||
.valueRenderer=${valueRenderer}
|
||||
.addButtonLabel=${this.addButtonLabel}
|
||||
@value-changed=${this._valueChanged}
|
||||
>
|
||||
</ha-generic-picker>
|
||||
|
||||
@@ -10,7 +10,6 @@ import type { HomeAssistant } from "../types";
|
||||
import "./ha-bottom-sheet";
|
||||
import "./ha-button";
|
||||
import "./ha-combo-box-item";
|
||||
import "./ha-icon-button";
|
||||
import "./ha-input-helper-text";
|
||||
import "./ha-picker-combo-box";
|
||||
import type {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { mdiMenuDown } from "@mdi/js";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { formatLanguageCode } from "../common/language/format_language";
|
||||
@@ -8,10 +9,10 @@ import { caseInsensitiveStringCompare } from "../common/string/compare";
|
||||
import type { FrontendLocaleData } from "../data/translation";
|
||||
import { translationMetadata } from "../resources/translations-metadata";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
||||
import "./ha-button";
|
||||
import "./ha-generic-picker";
|
||||
import "./ha-list-item";
|
||||
import type { HaGenericPicker } from "./ha-generic-picker";
|
||||
import type { PickerComboBoxItem } from "./ha-picker-combo-box";
|
||||
import "./ha-select";
|
||||
|
||||
export const getLanguageOptions = (
|
||||
languages: string[],
|
||||
@@ -75,6 +76,9 @@ export class HaLanguagePicker extends LitElement {
|
||||
@property({ attribute: "native-name", type: Boolean })
|
||||
public nativeName = false;
|
||||
|
||||
@property({ type: Boolean, attribute: "button-style" })
|
||||
public buttonStyle = false;
|
||||
|
||||
@property({ attribute: "no-sort", type: Boolean }) public noSort = false;
|
||||
|
||||
@property({ attribute: "inline-arrow", type: Boolean })
|
||||
@@ -82,6 +86,8 @@ export class HaLanguagePicker extends LitElement {
|
||||
|
||||
@state() _defaultLanguages: string[] = [];
|
||||
|
||||
@query("ha-generic-picker", true) public genericPicker!: HaGenericPicker;
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.firstUpdated(changedProps);
|
||||
this._computeDefaultLanguageOptions();
|
||||
@@ -101,12 +107,13 @@ export class HaLanguagePicker extends LitElement {
|
||||
this.hass?.locale
|
||||
);
|
||||
|
||||
private _valueRenderer = (value) => {
|
||||
const language = this._getItems().find(
|
||||
(lang) => lang.id === value
|
||||
)?.primary;
|
||||
return html`<span slot="headline">${language ?? value}</span> `;
|
||||
};
|
||||
private _getLanguageName = (lang?: string) =>
|
||||
this._getItems().find((language) => language.id === lang)?.primary;
|
||||
|
||||
private _valueRenderer = (value) =>
|
||||
html`<span slot="headline"
|
||||
>${this._getLanguageName(value) ?? value}</span
|
||||
> `;
|
||||
|
||||
protected render() {
|
||||
const value =
|
||||
@@ -130,10 +137,28 @@ export class HaLanguagePicker extends LitElement {
|
||||
.getItems=${this._getItems}
|
||||
@value-changed=${this._changed}
|
||||
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`
|
||||
ha-generic-picker {
|
||||
width: 100%;
|
||||
|
||||
@@ -87,166 +87,208 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
|
||||
protected render() {
|
||||
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() {
|
||||
return html`<div class="mdc-chip-set items">
|
||||
${this.value?.floor_id
|
||||
? ensureArray(this.value.floor_id).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}
|
||||
${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>`;
|
||||
}
|
||||
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)
|
||||
: [];
|
||||
|
||||
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 (
|
||||
!this.value?.floor_id &&
|
||||
!this.value?.area_id &&
|
||||
!this.value?.device_id &&
|
||||
!this.value?.entity_id &&
|
||||
!this.value?.label_id
|
||||
!entityIds.length &&
|
||||
!deviceIds.length &&
|
||||
!areaIds.length &&
|
||||
!floorIds.length &&
|
||||
!labelIds.length
|
||||
) {
|
||||
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`
|
||||
${this.compact ? this._renderValueChips() : this._renderValueGroups()}
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderChips() {
|
||||
private _renderPicker() {
|
||||
return html`
|
||||
<div class="add-target-wrapper">
|
||||
<ha-button
|
||||
@@ -347,7 +389,8 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
this._pickerFilter = filter;
|
||||
};
|
||||
|
||||
private _hidePicker() {
|
||||
private _hidePicker(ev) {
|
||||
ev.stopPropagation();
|
||||
this._open = false;
|
||||
this._pickerWrapperOpen = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import "@home-assistant/webawesome/dist/components/dialog/dialog";
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
@@ -8,6 +6,9 @@ import {
|
||||
query,
|
||||
state,
|
||||
} 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 { haStyleScrollbar } from "../resources/styles";
|
||||
import type { HomeAssistant } from "../types";
|
||||
@@ -31,6 +32,8 @@ export type DialogWidth = "small" | "medium" | "large" | "full";
|
||||
*
|
||||
* @slot header - Replace the entire header area.
|
||||
* @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 - Dialog content body.
|
||||
* @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 {("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 {string} header-title - Header title text when no custom title slot is provided.
|
||||
* @attr {string} header-subtitle - Header subtitle text when no custom subtitle 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. 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 {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 {
|
||||
@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 })
|
||||
public open = false;
|
||||
|
||||
@@ -81,11 +90,11 @@ export class HaWaDialog extends LitElement {
|
||||
@property({ type: Boolean, reflect: true, attribute: "prevent-scrim-close" })
|
||||
public preventScrimClose = false;
|
||||
|
||||
@property({ type: String, attribute: "header-title" })
|
||||
public headerTitle = "";
|
||||
@property({ attribute: "header-title" })
|
||||
public headerTitle?: string;
|
||||
|
||||
@property({ type: String, attribute: "header-subtitle" })
|
||||
public headerSubtitle = "";
|
||||
@property({ attribute: "header-subtitle" })
|
||||
public headerSubtitle?: string;
|
||||
|
||||
@property({ type: String, attribute: "header-subtitle-position" })
|
||||
public headerSubtitlePosition: "above" | "below" = "below";
|
||||
@@ -117,6 +126,11 @@ export class HaWaDialog extends LitElement {
|
||||
.open=${this._open}
|
||||
.lightDismiss=${!this.preventScrimClose}
|
||||
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-after-show=${this._handleAfterShow}
|
||||
@wa-after-hide=${this._handleAfterHide}
|
||||
@@ -133,14 +147,14 @@ export class HaWaDialog extends LitElement {
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
</slot>
|
||||
${this.headerTitle
|
||||
? html`<span slot="title" class="title">
|
||||
${this.headerTitle !== undefined
|
||||
? html`<span slot="title" class="title" id="ha-wa-dialog-title">
|
||||
${this.headerTitle}
|
||||
</span>`
|
||||
: nothing}
|
||||
${this.headerSubtitle
|
||||
: html`<slot name="headerTitle" slot="title"></slot>`}
|
||||
${this.headerSubtitle !== undefined
|
||||
? html`<span slot="subtitle">${this.headerSubtitle}</span>`
|
||||
: nothing}
|
||||
: html`<slot name="headerSubtitle" slot="subtitle"></slot>`}
|
||||
<slot name="headerActionItems" slot="actionItems"></slot>
|
||||
</ha-dialog-header>
|
||||
</slot>
|
||||
|
||||
@@ -545,7 +545,7 @@ export class HaTargetPickerItemRow extends LitElement {
|
||||
name: entityName || deviceName || item,
|
||||
context,
|
||||
stateObject,
|
||||
notFound: !stateObject,
|
||||
notFound: !stateObject && item !== "all",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -638,6 +638,7 @@ export class HaTargetPickerItemRow extends LitElement {
|
||||
img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
z-index: 1;
|
||||
}
|
||||
ha-icon-button {
|
||||
--mdc-icon-button-size: 32px;
|
||||
|
||||
@@ -705,7 +705,7 @@ export class HaTargetPickerSelector extends LitElement {
|
||||
) as EntityComboBoxItem[];
|
||||
}
|
||||
|
||||
if (!filterType) {
|
||||
if (!filterType && entities.length) {
|
||||
// show group title
|
||||
items.push(
|
||||
this.hass.localize("ui.components.target-picker.type.entities")
|
||||
@@ -733,7 +733,7 @@ export class HaTargetPickerSelector extends LitElement {
|
||||
devices = this._filterGroup("device", devices);
|
||||
}
|
||||
|
||||
if (!filterType) {
|
||||
if (!filterType && devices.length) {
|
||||
// show group title
|
||||
items.push(
|
||||
this.hass.localize("ui.components.target-picker.type.devices")
|
||||
@@ -769,7 +769,7 @@ export class HaTargetPickerSelector extends LitElement {
|
||||
) as FloorComboBoxItem[];
|
||||
}
|
||||
|
||||
if (!filterType) {
|
||||
if (!filterType && areasAndFloors.length) {
|
||||
// show group title
|
||||
items.push(
|
||||
this.hass.localize("ui.components.target-picker.type.areas")
|
||||
@@ -811,7 +811,7 @@ export class HaTargetPickerSelector extends LitElement {
|
||||
labels = this._filterGroup("label", labels);
|
||||
}
|
||||
|
||||
if (!filterType) {
|
||||
if (!filterType && labels.length) {
|
||||
// show group title
|
||||
items.push(
|
||||
this.hass.localize("ui.components.target-picker.type.labels")
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
mdiChatSleep,
|
||||
mdiClipboardList,
|
||||
mdiClock,
|
||||
mdiCodeBraces,
|
||||
mdiCog,
|
||||
mdiCommentAlert,
|
||||
mdiCounter,
|
||||
@@ -113,6 +114,7 @@ export const FALLBACK_DOMAIN_ICONS = {
|
||||
text: mdiFormTextbox,
|
||||
time: mdiClock,
|
||||
timer: mdiTimerOutline,
|
||||
template: mdiCodeBraces,
|
||||
todo: mdiClipboardList,
|
||||
tts: mdiSpeakerMessage,
|
||||
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,
|
||||
mdiPencilOff,
|
||||
mdiPencilOutline,
|
||||
mdiPlusBoxMultipleOutline,
|
||||
mdiTransitConnectionVariant,
|
||||
} from "@mdi/js";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
@@ -60,6 +61,7 @@ import {
|
||||
computeShowLogBookComponent,
|
||||
} from "./const";
|
||||
import "./controls/more-info-default";
|
||||
import "./ha-more-info-add-to";
|
||||
import "./ha-more-info-history-and-logbook";
|
||||
import "./ha-more-info-info";
|
||||
import "./ha-more-info-settings";
|
||||
@@ -73,7 +75,7 @@ export interface MoreInfoDialogParams {
|
||||
data?: Record<string, any>;
|
||||
}
|
||||
|
||||
type View = "info" | "history" | "settings" | "related";
|
||||
type View = "info" | "history" | "settings" | "related" | "add_to";
|
||||
|
||||
interface ChildView {
|
||||
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 {
|
||||
const entity = this.hass.entities[this._entityId!] as
|
||||
| EntityRegistryEntry
|
||||
@@ -295,6 +301,11 @@ export class MoreInfoDialog extends LitElement {
|
||||
this._setView("related");
|
||||
}
|
||||
|
||||
private _goToAddEntityTo(ev) {
|
||||
if (!shouldHandleRequestSelectedEvent(ev)) return;
|
||||
this._setView("add_to");
|
||||
}
|
||||
|
||||
private _breadcrumbClick(ev: Event) {
|
||||
ev.stopPropagation();
|
||||
this._setView("related");
|
||||
@@ -521,6 +532,22 @@ export class MoreInfoDialog extends LitElement {
|
||||
.path=${mdiInformationOutline}
|
||||
></ha-svg-icon>
|
||||
</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>
|
||||
`
|
||||
: nothing}
|
||||
@@ -613,7 +640,14 @@ export class MoreInfoDialog extends LitElement {
|
||||
: "entity"}
|
||||
></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>
|
||||
`
|
||||
|
||||
@@ -152,10 +152,18 @@ export class MoreInfoHistory extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _setRedrawTimer() {
|
||||
// redraw the graph every minute to update the time axis
|
||||
private _setUpdateTimer() {
|
||||
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) {
|
||||
@@ -170,6 +178,30 @@ export class MoreInfoHistory extends LitElement {
|
||||
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> {
|
||||
if (
|
||||
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
|
||||
// requires another round-trip to the server.
|
||||
if (stateObj && stateObj.attributes.state_class) {
|
||||
// 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]: "" };
|
||||
const hasStatistics = await this._fetchStatistics();
|
||||
if (hasStatistics) {
|
||||
// Using statistics, set up refresh timer
|
||||
this._setUpdateTimer();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -238,7 +253,7 @@ export class MoreInfoHistory extends LitElement {
|
||||
this._error = err;
|
||||
return undefined;
|
||||
});
|
||||
this._setRedrawTimer();
|
||||
this._setUpdateTimer();
|
||||
}
|
||||
|
||||
static styles = [
|
||||
|
||||
@@ -36,6 +36,13 @@ interface EMOutgoingMessageConfigGet extends EMMessage {
|
||||
type: "config/get";
|
||||
}
|
||||
|
||||
interface EMOutgoingMessageEntityAddToGetActions extends EMMessage {
|
||||
type: "entity/add_to/get_actions";
|
||||
payload: {
|
||||
entity_id: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface EMOutgoingMessageBarCodeScan extends EMMessage {
|
||||
type: "bar_code/scan";
|
||||
payload: {
|
||||
@@ -75,6 +82,10 @@ interface EMOutgoingMessageWithAnswer {
|
||||
request: EMOutgoingMessageConfigGet;
|
||||
response: ExternalConfig;
|
||||
};
|
||||
"entity/add_to/get_actions": {
|
||||
request: EMOutgoingMessageEntityAddToGetActions;
|
||||
response: ExternalEntityAddToActions;
|
||||
};
|
||||
}
|
||||
|
||||
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 =
|
||||
| EMMessageResultError
|
||||
| EMMessageResultSuccess
|
||||
@@ -177,7 +196,8 @@ type EMOutgoingMessageWithoutAnswer =
|
||||
| EMOutgoingMessageThemeUpdate
|
||||
| EMOutgoingMessageThreadStoreInPlatformKeychain
|
||||
| EMOutgoingMessageImprovScan
|
||||
| EMOutgoingMessageImprovConfigureDevice;
|
||||
| EMOutgoingMessageImprovConfigureDevice
|
||||
| EMOutgoingMessageAddEntityTo;
|
||||
|
||||
export interface EMIncomingMessageRestart {
|
||||
id: number;
|
||||
@@ -293,18 +313,31 @@ type EMIncomingMessage =
|
||||
type EMIncomingMessageHandler = (msg: EMIncomingMessageCommands) => boolean;
|
||||
|
||||
export interface ExternalConfig {
|
||||
hasSettingsScreen: boolean;
|
||||
hasSidebar: boolean;
|
||||
canWriteTag: boolean;
|
||||
hasExoPlayer: boolean;
|
||||
canCommissionMatter: boolean;
|
||||
canImportThreadCredentials: boolean;
|
||||
canTransferThreadCredentialsToKeychain: boolean;
|
||||
hasAssist: boolean;
|
||||
hasBarCodeScanner: number;
|
||||
canSetupImprov: boolean;
|
||||
downloadFileSupported: boolean;
|
||||
appVersion: string;
|
||||
hasSettingsScreen?: boolean;
|
||||
hasSidebar?: boolean;
|
||||
canWriteTag?: boolean;
|
||||
hasExoPlayer?: boolean;
|
||||
canCommissionMatter?: boolean;
|
||||
canImportThreadCredentials?: boolean;
|
||||
canTransferThreadCredentialsToKeychain?: boolean;
|
||||
hasAssist?: boolean;
|
||||
hasBarCodeScanner?: number;
|
||||
canSetupImprov?: boolean;
|
||||
downloadFileSupported?: boolean;
|
||||
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 {
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
||||
@@ -8,24 +8,24 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import "../../../components/chips/ha-chip-set";
|
||||
import "../../../components/chips/ha-input-chip";
|
||||
import "../../../components/ha-alert";
|
||||
import "../../../components/ha-button";
|
||||
import "../../../components/ha-aliases-editor";
|
||||
import "../../../components/ha-area-picker";
|
||||
import "../../../components/ha-button";
|
||||
import { createCloseHeading } from "../../../components/ha-dialog";
|
||||
import "../../../components/ha-icon-picker";
|
||||
import "../../../components/ha-picture-upload";
|
||||
import "../../../components/ha-settings-row";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/ha-textfield";
|
||||
import "../../../components/ha-area-picker";
|
||||
import { updateAreaRegistryEntry } from "../../../data/area_registry";
|
||||
import type {
|
||||
FloorRegistryEntry,
|
||||
FloorRegistryEntryMutableParams,
|
||||
} from "../../../data/floor_registry";
|
||||
import { haStyle, haStyleDialog } from "../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { FloorRegistryDetailDialogParams } from "./show-dialog-floor-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 {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@@ -168,11 +168,6 @@ class DialogFloorDetail extends LitElement {
|
||||
)}
|
||||
</h3>
|
||||
|
||||
<p class="description">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.floors.editor.areas_description"
|
||||
)}
|
||||
</p>
|
||||
${areas.length
|
||||
? html`<ha-chip-set>
|
||||
${repeat(
|
||||
@@ -197,13 +192,17 @@ class DialogFloorDetail extends LitElement {
|
||||
</ha-input-chip>`
|
||||
)}
|
||||
</ha-chip-set>`
|
||||
: nothing}
|
||||
: html`<p class="description">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.floors.editor.areas_description"
|
||||
)}
|
||||
</p>`}
|
||||
<ha-area-picker
|
||||
no-add
|
||||
.hass=${this.hass}
|
||||
@value-changed=${this._addArea}
|
||||
.excludeAreas=${areas.map((a) => a.area_id)}
|
||||
.label=${this.hass.localize(
|
||||
.addButtonLabel=${this.hass.localize(
|
||||
"ui.panel.config.floors.editor.add_area"
|
||||
)}
|
||||
></ha-area-picker>
|
||||
|
||||
@@ -257,7 +257,7 @@ class DialogAddAutomationElement
|
||||
|
||||
const results = fuse.multiTermsSearch(filter);
|
||||
if (results) {
|
||||
return results.map((result) => result.item);
|
||||
return results.map((result) => result.item).filter((item) => item.name);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ class DialogAddAutomationElement
|
||||
|
||||
const results = fuse.multiTermsSearch(filter);
|
||||
if (results) {
|
||||
return results.map((result) => result.item);
|
||||
return results.map((result) => result.item).filter((item) => item.name);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@@ -383,9 +383,16 @@ class DialogAddAutomationElement
|
||||
|
||||
generatedCollections.push({
|
||||
titleKey: collection.titleKey,
|
||||
groups: groups.sort((a, b) =>
|
||||
stringCompare(a.name, b.name, this.hass.locale.language)
|
||||
),
|
||||
groups: groups.sort((a, b) => {
|
||||
// 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;
|
||||
@@ -678,7 +685,7 @@ class DialogAddAutomationElement
|
||||
);
|
||||
|
||||
const typeTitle = this.hass.localize(
|
||||
`ui.panel.config.automation.editor.${automationElementType}s.header`
|
||||
`ui.panel.config.automation.editor.${automationElementType}s.add`
|
||||
);
|
||||
|
||||
const tabButtons = [
|
||||
@@ -895,7 +902,9 @@ class DialogAddAutomationElement
|
||||
|
||||
return html`
|
||||
<div class="items-title ${this._itemsScrolled ? "scrolled" : ""}">
|
||||
${title}
|
||||
${this._tab === "blocks" && !this._filter
|
||||
? this.hass.localize("ui.panel.config.automation.editor.blocks")
|
||||
: title}
|
||||
</div>
|
||||
<ha-md-list
|
||||
dialogInitialFocus=${ifDefined(this._fullScreen ? "" : undefined)}
|
||||
@@ -1045,6 +1054,7 @@ class DialogAddAutomationElement
|
||||
private _onSearchFocus(ev) {
|
||||
this._removeKeyboardShortcuts = tinykeys(ev.target, {
|
||||
ArrowDown: this._focusSearchList,
|
||||
Enter: this._pickSingleItem,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1061,6 +1071,39 @@ class DialogAddAutomationElement
|
||||
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 {
|
||||
return [
|
||||
css`
|
||||
|
||||
@@ -20,7 +20,8 @@ import "../../../../components/ha-md-divider";
|
||||
import "../../../../components/ha-md-menu-item";
|
||||
import { ACTION_BUILDING_BLOCKS } from "../../../../data/action";
|
||||
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 { isMac } from "../../../../util/is_mac";
|
||||
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"
|
||||
);
|
||||
|
||||
const title =
|
||||
let title =
|
||||
this.hass.localize(
|
||||
`ui.panel.config.automation.editor.actions.type.${type}.label` as LocalizeKeys
|
||||
) || 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
|
||||
? this.hass.localize(
|
||||
`ui.panel.config.automation.editor.actions.type.${type}.description.picker` as LocalizeKeys
|
||||
|
||||
@@ -569,15 +569,15 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
||||
navigate(`/config/backup/details/${id}`);
|
||||
}
|
||||
|
||||
private async _downloadBackup(ev): Promise<void> {
|
||||
private _downloadBackup = async (ev): Promise<void> => {
|
||||
const backup = ev.parentElement.anchorElement.backup;
|
||||
if (!backup) {
|
||||
return;
|
||||
}
|
||||
downloadBackup(this.hass, this, backup, this.config);
|
||||
}
|
||||
};
|
||||
|
||||
private async _deleteBackup(ev): Promise<void> {
|
||||
private _deleteBackup = async (ev): Promise<void> => {
|
||||
const backup = ev.parentElement.anchorElement.backup;
|
||||
if (!backup) {
|
||||
return;
|
||||
@@ -609,7 +609,7 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
fireEvent(this, "ha-refresh-backup-info");
|
||||
}
|
||||
};
|
||||
|
||||
private async _deleteSelected() {
|
||||
const confirm = await showConfirmationDialog(this, {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { subscribeEntityRegistry } from "../../../data/entity_registry";
|
||||
import type { UpdateEntity } from "../../../data/update";
|
||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import "../../../components/ha-progress-ring";
|
||||
|
||||
@customElement("ha-config-updates")
|
||||
class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||
@@ -56,6 +57,29 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||
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() {
|
||||
if (!this.updateEntities?.length) {
|
||||
return nothing;
|
||||
@@ -106,13 +130,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||
)}
|
||||
></state-badge>
|
||||
${this.narrow && entity.attributes.in_progress
|
||||
? html`<ha-spinner
|
||||
class="absolute"
|
||||
size="small"
|
||||
.ariaLabel=${this.hass.localize(
|
||||
"ui.panel.config.updates.update_in_progress"
|
||||
)}
|
||||
></ha-spinner>`
|
||||
? html`<div class="absolute">
|
||||
${this._renderUpdateProgress(entity)}
|
||||
</div>`
|
||||
: nothing}
|
||||
</div>
|
||||
<span slot="headline"
|
||||
@@ -128,16 +148,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||
: nothing}
|
||||
</span>
|
||||
${!this.narrow
|
||||
? entity.attributes.in_progress
|
||||
? html`<div slot="end">
|
||||
<ha-spinner
|
||||
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>`
|
||||
? html`<div slot="end">
|
||||
${this._renderUpdateProgress(entity)}
|
||||
</div>`
|
||||
: nothing}
|
||||
</ha-md-list-item>
|
||||
`;
|
||||
@@ -193,13 +206,13 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
|
||||
div[slot="start"] {
|
||||
position: relative;
|
||||
}
|
||||
ha-spinner.absolute {
|
||||
div.absolute {
|
||||
position: absolute;
|
||||
left: 6px;
|
||||
top: 6px;
|
||||
}
|
||||
state-badge.updating {
|
||||
opacity: 0.5;
|
||||
opacity: 0.2;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -9,6 +9,7 @@ import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-formfield";
|
||||
import "../../../../components/ha-radio";
|
||||
import "../../../../components/ha-markdown";
|
||||
import type { HaRadio } from "../../../../components/ha-radio";
|
||||
import type {
|
||||
FlowFromGridSourceEnergyPreference,
|
||||
@@ -19,11 +20,7 @@ import {
|
||||
emptyFlowToGridSourceEnergyPreference,
|
||||
energyStatisticHelpUrl,
|
||||
} from "../../../../data/energy";
|
||||
import {
|
||||
getDisplayUnit,
|
||||
getStatisticMetadata,
|
||||
isExternalStatistic,
|
||||
} from "../../../../data/recorder";
|
||||
import { isExternalStatistic } from "../../../../data/recorder";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
@@ -47,8 +44,6 @@ export class DialogEnergyGridFlowSettings
|
||||
|
||||
@state() private _costs?: "no-costs" | "number" | "entity" | "statistic";
|
||||
|
||||
@state() private _pickedDisplayUnit?: string | null;
|
||||
|
||||
@state() private _energy_units?: string[];
|
||||
|
||||
@state() private _error?: string;
|
||||
@@ -81,11 +76,6 @@ export class DialogEnergyGridFlowSettings
|
||||
: "stat_energy_to"
|
||||
];
|
||||
|
||||
this._pickedDisplayUnit = getDisplayUnit(
|
||||
this.hass,
|
||||
initialSourceId,
|
||||
params.metadata
|
||||
);
|
||||
this._energy_units = (
|
||||
await getSensorDeviceClassConvertibleUnits(this.hass, "energy")
|
||||
).units;
|
||||
@@ -103,7 +93,6 @@ export class DialogEnergyGridFlowSettings
|
||||
public closeDialog() {
|
||||
this._params = undefined;
|
||||
this._source = undefined;
|
||||
this._pickedDisplayUnit = undefined;
|
||||
this._error = undefined;
|
||||
this._excludeList = undefined;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
@@ -117,10 +106,6 @@ export class DialogEnergyGridFlowSettings
|
||||
|
||||
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 externalSource =
|
||||
@@ -246,9 +231,15 @@ export class DialogEnergyGridFlowSettings
|
||||
.hass=${this.hass}
|
||||
include-domains='["sensor", "input_number"]'
|
||||
.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`
|
||||
)} ${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}
|
||||
></ha-entity-picker>`
|
||||
: ""}
|
||||
@@ -341,16 +332,6 @@ export class DialogEnergyGridFlowSettings
|
||||
}
|
||||
|
||||
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._params!.direction === "from"
|
||||
|
||||
@@ -107,6 +107,8 @@ class HaConfigInfo extends LitElement {
|
||||
const customUiList: { name: string; url: string; version: string }[] =
|
||||
(window as any).CUSTOM_UI_LIST || [];
|
||||
|
||||
const isDark = this.hass.themes?.darkMode || false;
|
||||
|
||||
return html`
|
||||
<hass-subpage
|
||||
.hass=${this.hass}
|
||||
@@ -186,7 +188,7 @@ class HaConfigInfo extends LitElement {
|
||||
: nothing}
|
||||
</ul>
|
||||
</ha-card>
|
||||
<ha-card outlined class="ohf">
|
||||
<ha-card outlined class="ohf ${isDark ? "dark" : ""}">
|
||||
<div>
|
||||
${this.hass.localize("ui.panel.config.info.proud_part_of")}
|
||||
</div>
|
||||
@@ -346,6 +348,10 @@ class HaConfigInfo extends LitElement {
|
||||
max-width: 250px;
|
||||
}
|
||||
|
||||
.ohf.dark img {
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
.versions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { relativeTime } from "../../../../../common/datetime/relative_time";
|
||||
import { getDeviceContext } from "../../../../../common/entity/context/get_device_context";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import { throttle } from "../../../../../common/util/throttle";
|
||||
import "../../../../../components/chart/ha-network-graph";
|
||||
@@ -194,11 +195,17 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||
];
|
||||
const links: NetworkLink[] = [];
|
||||
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({
|
||||
id: scanner.source,
|
||||
name:
|
||||
scannerDevice?.name_by_user || scannerDevice?.name || scanner.name,
|
||||
context: area?.name,
|
||||
category: 1,
|
||||
value: 5,
|
||||
symbol: "circle",
|
||||
@@ -231,10 +238,16 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||
});
|
||||
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({
|
||||
id: node.address,
|
||||
name: this._getBluetoothDeviceName(node.address),
|
||||
context: area?.name,
|
||||
value: device ? 1 : 0,
|
||||
category: device ? 2 : 3,
|
||||
symbolSize: 20,
|
||||
@@ -294,15 +307,20 @@ export class BluetoothNetworkVisualization extends LitElement {
|
||||
const btDevice = this._data.find((d) => d.address === address);
|
||||
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)}`;
|
||||
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 {
|
||||
const device = this._sourceDevices[address];
|
||||
if (device) {
|
||||
tooltipText = `<b>${name}</b><br><b>${this.hass.localize("ui.panel.config.bluetooth.address")}:</b> ${address}`;
|
||||
if (device.area_id) {
|
||||
const area = this.hass.areas[device.area_id];
|
||||
if (area) {
|
||||
tooltipText += `<br><b>${this.hass.localize("ui.panel.config.bluetooth.area")}: </b>${area.name}`;
|
||||
}
|
||||
const area = getDeviceContext(device, this.hass).area;
|
||||
if (area) {
|
||||
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 { formatAsPaddedHex } from "./functions";
|
||||
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")
|
||||
export class ZHANetworkVisualizationPage extends LitElement {
|
||||
@@ -117,8 +119,11 @@ export class ZHANetworkVisualizationPage extends LitElement {
|
||||
} else {
|
||||
label += `<br><b>${this.hass.localize("ui.panel.config.zha.visualization.device_not_in_db")}</b>`;
|
||||
}
|
||||
if (device.area_id) {
|
||||
const area = this.hass.areas[device.area_id];
|
||||
const haDevice = this.hass.devices[device.device_reg_id] as
|
||||
| DeviceRegistryEntry
|
||||
| undefined;
|
||||
if (haDevice) {
|
||||
const area = getDeviceContext(haDevice, this.hass).area;
|
||||
if (area) {
|
||||
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
|
||||
}
|
||||
|
||||
const haDevice = this.hass.devices[device.device_reg_id] as
|
||||
| DeviceRegistryEntry
|
||||
| undefined;
|
||||
const area = haDevice
|
||||
? getDeviceContext(haDevice, this.hass).area
|
||||
: undefined;
|
||||
// Create node
|
||||
nodes.push({
|
||||
id: device.ieee,
|
||||
name: device.user_given_name || device.name || device.ieee,
|
||||
context: area?.name,
|
||||
category,
|
||||
value: isCoordinator ? 3 : device.device_type === "Router" ? 2 : 1,
|
||||
symbolSize: isCoordinator
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { getDeviceContext } from "../../../../../common/entity/context/get_device_context";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import { debounce } from "../../../../../common/util/debounce";
|
||||
import "../../../../../components/chart/ha-network-graph";
|
||||
@@ -124,7 +125,7 @@ export class ZWaveJSNetworkVisualization extends SubscribeMixin(LitElement) {
|
||||
return tip;
|
||||
}
|
||||
const { id, name } = data as any;
|
||||
const device = this._devices[id];
|
||||
const device = this._devices[id] as DeviceRegistryEntry | undefined;
|
||||
const nodeStatus = this._nodeStatuses[id];
|
||||
let tip = `${(params as any).marker} ${name}`;
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -197,10 +204,16 @@ export class ZWaveJSNetworkVisualization extends SubscribeMixin(LitElement) {
|
||||
if (node.is_controller_node) {
|
||||
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({
|
||||
id: 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,
|
||||
category:
|
||||
node.status === NodeStatus.Dead
|
||||
|
||||
@@ -41,7 +41,6 @@ class DialogRepairsIssueSubtitle extends LitElement {
|
||||
:host {
|
||||
display: block;
|
||||
font-size: var(--ha-font-size-m);
|
||||
margin-bottom: 8px;
|
||||
color: var(--secondary-text-color);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { mdiClose, mdiOpenInNew } from "@mdi/js";
|
||||
import { mdiOpenInNew } from "@mdi/js";
|
||||
import type { CSSResultGroup } 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 { isNavigationClick } from "../../../common/dom/is-navigation-click";
|
||||
import "../../../components/ha-alert";
|
||||
import "../../../components/ha-md-dialog";
|
||||
import type { HaMdDialog } from "../../../components/ha-md-dialog";
|
||||
import "../../../components/ha-wa-dialog";
|
||||
import "../../../components/ha-button";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/ha-dialog-header";
|
||||
import "../../../components/ha-dialog-footer";
|
||||
import "./dialog-repairs-issue-subtitle";
|
||||
import "../../../components/ha-markdown";
|
||||
import type { RepairsIssue } from "../../../data/repairs";
|
||||
@@ -26,11 +25,12 @@ class DialogRepairsIssue extends LitElement {
|
||||
|
||||
@state() private _params?: RepairsIssueDialogParams;
|
||||
|
||||
@query("ha-md-dialog") private _dialog?: HaMdDialog;
|
||||
@state() private _open = false;
|
||||
|
||||
public showDialog(params: RepairsIssueDialogParams): void {
|
||||
this._params = params;
|
||||
this._issue = this._params.issue;
|
||||
this._open = true;
|
||||
}
|
||||
|
||||
private _dialogClosed() {
|
||||
@@ -44,7 +44,7 @@ class DialogRepairsIssue extends LitElement {
|
||||
}
|
||||
|
||||
public closeDialog() {
|
||||
this._dialog?.close();
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
@@ -62,32 +62,19 @@ class DialogRepairsIssue extends LitElement {
|
||||
) || this.hass!.localize("ui.panel.config.repairs.dialog.title");
|
||||
|
||||
return html`
|
||||
<ha-md-dialog
|
||||
open
|
||||
@closed=${this._dialogClosed}
|
||||
aria-labelledby="dialog-repairs-issue-title"
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${dialogTitle}
|
||||
aria-describedby="dialog-repairs-issue-description"
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
<ha-dialog-header slot="headline">
|
||||
<ha-icon-button
|
||||
slot="navigationIcon"
|
||||
.label=${this.hass.localize("ui.common.close") ?? "Close"}
|
||||
.path=${mdiClose}
|
||||
@click=${this.closeDialog}
|
||||
></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">
|
||||
<dialog-repairs-issue-subtitle
|
||||
slot="headerSubtitle"
|
||||
.hass=${this.hass}
|
||||
.issue=${this._issue}
|
||||
></dialog-repairs-issue-subtitle>
|
||||
<div class="dialog-content">
|
||||
${this._issue.breaks_in_ha_version
|
||||
? html`
|
||||
<ha-alert alert-type="warning">
|
||||
@@ -122,8 +109,12 @@ class DialogRepairsIssue extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
</div>
|
||||
<div slot="actions">
|
||||
<ha-button appearance="plain" @click=${this._ignoreIssue}>
|
||||
<ha-dialog-footer slot="footer">
|
||||
<ha-button
|
||||
slot="secondaryAction"
|
||||
appearance="plain"
|
||||
@click=${this._ignoreIssue}
|
||||
>
|
||||
${this._issue!.ignored
|
||||
? this.hass!.localize("ui.panel.config.repairs.dialog.unignore")
|
||||
: this.hass!.localize("ui.panel.config.repairs.dialog.ignore")}
|
||||
@@ -131,6 +122,7 @@ class DialogRepairsIssue extends LitElement {
|
||||
${this._issue.learn_more_url
|
||||
? html`
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
appearance="filled"
|
||||
rel="noopener noreferrer"
|
||||
href=${learnMoreUrlIsHomeAssistant
|
||||
@@ -149,8 +141,8 @@ class DialogRepairsIssue extends LitElement {
|
||||
</ha-button>
|
||||
`
|
||||
: ""}
|
||||
</div>
|
||||
</ha-md-dialog>
|
||||
</ha-dialog-footer>
|
||||
</ha-wa-dialog>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -172,7 +164,7 @@ class DialogRepairsIssue extends LitElement {
|
||||
padding-top: 0;
|
||||
}
|
||||
ha-alert {
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: var(--ha-space-4);
|
||||
display: block;
|
||||
}
|
||||
.dismissed {
|
||||
|
||||
@@ -109,15 +109,26 @@ export class AssistPipelineDetailConversation extends LitElement {
|
||||
}
|
||||
|
||||
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
|
||||
setTimeout(() => {
|
||||
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 });
|
||||
}, 0);
|
||||
}
|
||||
this._supportedLanguages = ev.detail.value;
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
|
||||
@@ -148,7 +148,9 @@ export class AssistPipelineDebug extends LitElement {
|
||||
).pipeline_runs.reverse();
|
||||
} catch (e: any) {
|
||||
showAlertDialog(this, {
|
||||
title: "Failed to fetch pipeline runs",
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.error.fetch_runs"
|
||||
),
|
||||
text: e.message,
|
||||
});
|
||||
return;
|
||||
@@ -176,7 +178,9 @@ export class AssistPipelineDebug extends LitElement {
|
||||
).events;
|
||||
} catch (e: any) {
|
||||
showAlertDialog(this, {
|
||||
title: "Failed to fetch events",
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.error.fetch_events"
|
||||
),
|
||||
text: e.message,
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -30,16 +30,26 @@ export class AssistPipelineEvents extends LitElement {
|
||||
const run = this._processEvents(this.events);
|
||||
if (!run) {
|
||||
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-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>
|
||||
</ha-expansion-panel>
|
||||
</ha-card>`;
|
||||
}
|
||||
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`
|
||||
|
||||
@@ -11,31 +11,16 @@ import type { HomeAssistant } from "../../../../types";
|
||||
import { formatNumber } from "../../../../common/number/format_number";
|
||||
import "../../../../components/ha-yaml-editor";
|
||||
import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||
import type { LocalizeKeys } from "../../../../common/translations/localize";
|
||||
|
||||
const RUN_DATA = {
|
||||
pipeline: "Pipeline",
|
||||
language: "Language",
|
||||
};
|
||||
const WAKE_WORD_DATA = {
|
||||
engine: "Engine",
|
||||
};
|
||||
const RUN_DATA = ["pipeline", "language"];
|
||||
const WAKE_WORD_DATA = ["engine"];
|
||||
|
||||
const STT_DATA = {
|
||||
engine: "Engine",
|
||||
};
|
||||
const STT_DATA = ["engine"];
|
||||
|
||||
const INTENT_DATA = {
|
||||
engine: "Engine",
|
||||
language: "Language",
|
||||
intent_input: "Input",
|
||||
};
|
||||
const INTENT_DATA = ["engine", "language", "intent_input"];
|
||||
|
||||
const TTS_DATA = {
|
||||
engine: "Engine",
|
||||
language: "Language",
|
||||
voice: "Voice",
|
||||
tts_input: "Input",
|
||||
};
|
||||
const TTS_DATA = ["engine", "language", "voice", "tts_input"];
|
||||
|
||||
const STAGES: Record<PipelineRun["stage"], number> = {
|
||||
ready: 0,
|
||||
@@ -102,24 +87,32 @@ const renderProgress = (
|
||||
return html`${durationString}s ✅`;
|
||||
};
|
||||
|
||||
const renderData = (data: Record<string, any>, keys: Record<string, string>) =>
|
||||
Object.entries(keys).map(
|
||||
([key, label]) => html`
|
||||
const renderData = (
|
||||
hass: HomeAssistant,
|
||||
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>${label}</div>
|
||||
<div>${data[key]}</div>
|
||||
</div>
|
||||
`
|
||||
);
|
||||
`;
|
||||
});
|
||||
|
||||
const dataMinusKeysRender = (
|
||||
hass: HomeAssistant,
|
||||
data: Record<string, any>,
|
||||
keys: Record<string, string>
|
||||
keys: string[]
|
||||
) => {
|
||||
const result = {};
|
||||
let render = false;
|
||||
for (const key in data) {
|
||||
if (key in keys || key === "done") {
|
||||
if (keys.includes(key) || key === "done") {
|
||||
continue;
|
||||
}
|
||||
render = true;
|
||||
@@ -127,7 +120,9 @@ const dataMinusKeysRender = (
|
||||
}
|
||||
return render
|
||||
? 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-expansion-panel>`
|
||||
: "";
|
||||
@@ -139,6 +134,12 @@ export class AssistPipelineDebug extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public pipelineRun!: PipelineRun;
|
||||
|
||||
private _audioElement?: HTMLAudioElement;
|
||||
|
||||
private get _isPlaying(): boolean {
|
||||
return this._audioElement != null && !this._audioElement.paused;
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const lastRunStage: string = this.pipelineRun
|
||||
? ["tts", "intent", "stt", "wake_word"].find(
|
||||
@@ -177,11 +178,15 @@ export class AssistPipelineDebug extends LitElement {
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
<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>
|
||||
|
||||
${renderData(this.pipelineRun.run, RUN_DATA)}
|
||||
${renderData(this.hass, this.pipelineRun.run, RUN_DATA)}
|
||||
${messages.length > 0
|
||||
? html`
|
||||
<div class="messages">
|
||||
@@ -203,23 +208,39 @@ export class AssistPipelineDebug extends LitElement {
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
<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")}
|
||||
</div>
|
||||
${this.pipelineRun.wake_word
|
||||
? html`
|
||||
<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
|
||||
? html`<div class="row">
|
||||
<div>Model</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.stages.model"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.wake_word.wake_word_output
|
||||
.ww_id}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div>Timestamp</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.stages.timestamp"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.wake_word.wake_word_output
|
||||
.timestamp}
|
||||
@@ -227,6 +248,7 @@ export class AssistPipelineDebug extends LitElement {
|
||||
</div>`
|
||||
: ""}
|
||||
${dataMinusKeysRender(
|
||||
this.hass,
|
||||
this.pipelineRun.wake_word,
|
||||
WAKE_WORD_DATA
|
||||
)}
|
||||
@@ -243,7 +265,11 @@ export class AssistPipelineDebug extends LitElement {
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
<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(
|
||||
this.hass,
|
||||
this.pipelineRun,
|
||||
@@ -254,18 +280,30 @@ export class AssistPipelineDebug extends LitElement {
|
||||
${this.pipelineRun.stt
|
||||
? html`
|
||||
<div class="card-content">
|
||||
${renderData(this.pipelineRun.stt, STT_DATA)}
|
||||
${renderData(this.hass, this.pipelineRun.stt, STT_DATA)}
|
||||
<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.stt_output
|
||||
? 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>`
|
||||
: ""}
|
||||
${dataMinusKeysRender(this.pipelineRun.stt, STT_DATA)}
|
||||
${dataMinusKeysRender(
|
||||
this.hass,
|
||||
this.pipelineRun.stt,
|
||||
STT_DATA
|
||||
)}
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
@@ -279,16 +317,28 @@ export class AssistPipelineDebug extends LitElement {
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
<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")}
|
||||
</div>
|
||||
${this.pipelineRun.intent
|
||||
? html`
|
||||
<div class="card-content">
|
||||
${renderData(this.pipelineRun.intent, INTENT_DATA)}
|
||||
${renderData(
|
||||
this.hass,
|
||||
this.pipelineRun.intent,
|
||||
INTENT_DATA
|
||||
)}
|
||||
${this.pipelineRun.intent.intent_output
|
||||
? html`<div class="row">
|
||||
<div>Response type</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.stages.response_type"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.intent.intent_output
|
||||
.response.response_type}
|
||||
@@ -297,7 +347,11 @@ export class AssistPipelineDebug extends LitElement {
|
||||
${this.pipelineRun.intent.intent_output.response
|
||||
.response_type === "error"
|
||||
? html`<div class="row">
|
||||
<div>Error code</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.error.code"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.intent.intent_output
|
||||
.response.data.code}
|
||||
@@ -306,18 +360,27 @@ export class AssistPipelineDebug extends LitElement {
|
||||
: ""}`
|
||||
: ""}
|
||||
<div class="row">
|
||||
<div>Prefer handling locally</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.stages.prefer_local"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.intent.prefer_local_intents}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div>Processed locally</div>
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.stages.processed_locally"
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
${this.pipelineRun.intent.processed_locally}
|
||||
</div>
|
||||
</div>
|
||||
${dataMinusKeysRender(
|
||||
this.hass,
|
||||
this.pipelineRun.intent,
|
||||
INTENT_DATA
|
||||
)}
|
||||
@@ -334,14 +397,22 @@ export class AssistPipelineDebug extends LitElement {
|
||||
<ha-card>
|
||||
<div class="card-content">
|
||||
<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")}
|
||||
</div>
|
||||
${this.pipelineRun.tts
|
||||
? html`
|
||||
<div class="card-content">
|
||||
${renderData(this.pipelineRun.tts, TTS_DATA)}
|
||||
${dataMinusKeysRender(this.pipelineRun.tts, TTS_DATA)}
|
||||
${renderData(this.hass, this.pipelineRun.tts, TTS_DATA)}
|
||||
${dataMinusKeysRender(
|
||||
this.hass,
|
||||
this.pipelineRun.tts,
|
||||
TTS_DATA
|
||||
)}
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
@@ -349,8 +420,19 @@ export class AssistPipelineDebug extends LitElement {
|
||||
${this.pipelineRun?.tts?.tts_output
|
||||
? html`
|
||||
<div class="card-actions">
|
||||
<ha-button @click=${this._playTTS}>
|
||||
Play Audio
|
||||
<ha-button
|
||||
.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>
|
||||
</div>
|
||||
`
|
||||
@@ -361,7 +443,11 @@ export class AssistPipelineDebug extends LitElement {
|
||||
${maybeRenderError(this.pipelineRun, "tts", lastRunStage)}
|
||||
<ha-card>
|
||||
<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
|
||||
read-only
|
||||
auto-update
|
||||
@@ -373,14 +459,48 @@ export class AssistPipelineDebug extends LitElement {
|
||||
}
|
||||
|
||||
private _playTTS(): void {
|
||||
// Stop any existing audio first
|
||||
this._stopTTS();
|
||||
|
||||
const url = this.pipelineRun!.tts!.tts_output!.url;
|
||||
const audio = new Audio(url);
|
||||
audio.addEventListener("error", () => {
|
||||
showAlertDialog(this, { title: "Error", text: "Error playing audio" });
|
||||
this._audioElement = new Audio(url);
|
||||
|
||||
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`
|
||||
|
||||
@@ -214,7 +214,7 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
@click=${this._updatePipeline}
|
||||
.disabled=${this._submitting}
|
||||
.loading=${this._submitting}
|
||||
dialogInitialFocus
|
||||
>
|
||||
${this._params.pipeline?.id
|
||||
|
||||
@@ -52,6 +52,8 @@ export class HaLogbook extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public deviceIds?: string[];
|
||||
|
||||
@property({ attribute: false }) public stateFilter?: string[];
|
||||
|
||||
@property({ type: Boolean }) public narrow = false;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public virtualize = false;
|
||||
@@ -165,7 +167,7 @@ export class HaLogbook extends LitElement {
|
||||
protected willUpdate(changedProps: PropertyValues): void {
|
||||
let changed = changedProps.has("time");
|
||||
|
||||
for (const key of ["entityIds", "deviceIds"]) {
|
||||
for (const key of ["entityIds", "deviceIds", "stateFilter"]) {
|
||||
if (!changedProps.has(key)) {
|
||||
continue;
|
||||
}
|
||||
@@ -352,9 +354,19 @@ export class HaLogbook extends LitElement {
|
||||
"recent" in this.time
|
||||
? findStartOfRecentTime(new Date(), this.time.recent)
|
||||
: 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
|
||||
// make a copy first.
|
||||
const newEntries = [...streamMessage.events].reverse();
|
||||
const newEntries = eventsFiltered.reverse();
|
||||
if (!this._logbookEntries || !this._logbookEntries.length) {
|
||||
this._logbookEntries = newEntries;
|
||||
return;
|
||||
|
||||
@@ -2,14 +2,11 @@ import type { PropertyValues } from "lit";
|
||||
import { ReactiveElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import {
|
||||
attachConditionMediaQueriesListeners,
|
||||
checkConditionsMet,
|
||||
} from "../common/validate-condition";
|
||||
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||
import { checkConditionsMet } from "../common/validate-condition";
|
||||
import { createBadgeElement } from "../create-element/create-badge-element";
|
||||
import { createErrorBadgeConfig } from "../create-element/create-element-base";
|
||||
import type { LovelaceBadge } from "../types";
|
||||
@@ -22,7 +19,7 @@ declare global {
|
||||
}
|
||||
|
||||
@customElement("hui-badge")
|
||||
export class HuiBadge extends ReactiveElement {
|
||||
export class HuiBadge extends ConditionalListenerMixin(ReactiveElement) {
|
||||
@property({ type: Boolean }) public preview = false;
|
||||
|
||||
@property({ attribute: false }) public config?: LovelaceBadgeConfig;
|
||||
@@ -40,20 +37,16 @@ export class HuiBadge extends ReactiveElement {
|
||||
|
||||
private _element?: LovelaceBadge;
|
||||
|
||||
private _listeners: MediaQueriesListener[] = [];
|
||||
|
||||
protected createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearMediaQueries();
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._listenMediaQueries();
|
||||
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) {
|
||||
if (!this._element || !this.hass) {
|
||||
return;
|
||||
|
||||
@@ -80,41 +80,44 @@ export class HuiEnergyCompareCard
|
||||
|
||||
return html`
|
||||
<ha-alert dismissable @alert-dismissed-clicked=${this._stopCompare}>
|
||||
${this.hass.localize("ui.panel.energy.compare.info", {
|
||||
start: html`<b
|
||||
>${formatDate(
|
||||
this._start!,
|
||||
this.hass.locale,
|
||||
this.hass.config
|
||||
)}${dayDifference > 0
|
||||
? ` -
|
||||
${this.hass.localize(
|
||||
"ui.panel.lovelace.cards.energy.energy_compare.info",
|
||||
{
|
||||
start: html`<b
|
||||
>${formatDate(
|
||||
this._start!,
|
||||
this.hass.locale,
|
||||
this.hass.config
|
||||
)}${dayDifference > 0
|
||||
? ` -
|
||||
${formatDate(
|
||||
this._end || endOfDay(new Date()),
|
||||
this.hass.locale,
|
||||
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
|
||||
>
|
||||
<button class="link" @click=${this._changeCompareMode}>
|
||||
(${this._compareMode === CompareMode.PREVIOUS
|
||||
? this.hass.localize(
|
||||
"ui.panel.energy.compare.compare_previous_year"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.energy.compare.compare_previous_period"
|
||||
)})
|
||||
</button>`,
|
||||
})}
|
||||
>`,
|
||||
end: html`<b
|
||||
>${formatDate(
|
||||
this._startCompare,
|
||||
this.hass.locale,
|
||||
this.hass.config
|
||||
)}${dayDifference > 0
|
||||
? ` -
|
||||
${formatDate(this._endCompare, this.hass.locale, this.hass.config)}`
|
||||
: ""}</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>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||
|
||||
@state() private _calendars: Calendar[] = [];
|
||||
|
||||
@state() private _eventDisplay = "list-item";
|
||||
|
||||
@state() private _narrow = false;
|
||||
|
||||
@state() private _error?: string = undefined;
|
||||
@@ -144,7 +142,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||
.hass=${this.hass}
|
||||
.views=${views}
|
||||
.initialView=${this._config.initial_view!}
|
||||
.eventDisplay=${this._eventDisplay}
|
||||
.error=${this._error}
|
||||
@view-changed=${this._handleViewChanged}
|
||||
></ha-full-calendar>
|
||||
@@ -174,8 +171,6 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
|
||||
private _handleViewChanged(ev: HASSDomEvent<CalendarViewChanged>): void {
|
||||
this._eventDisplay =
|
||||
ev.detail.view === "dayGridMonth" ? "list-item" : "auto";
|
||||
this._startDate = ev.detail.start;
|
||||
this._endDate = ev.detail.end;
|
||||
this._fetchCalendarEvents();
|
||||
|
||||
@@ -2,16 +2,13 @@ import type { PropertyValues } from "lit";
|
||||
import { ReactiveElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||
import { migrateLayoutToGridOptions } from "../common/compute-card-grid-size";
|
||||
import { computeCardSize } from "../common/compute-card-size";
|
||||
import {
|
||||
attachConditionMediaQueriesListeners,
|
||||
checkConditionsMet,
|
||||
} from "../common/validate-condition";
|
||||
import { checkConditionsMet } from "../common/validate-condition";
|
||||
import { tryCreateCardElement } from "../create-element/create-card-element";
|
||||
import { createErrorCardElement } from "../create-element/create-element-base";
|
||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||
@@ -24,7 +21,7 @@ declare global {
|
||||
}
|
||||
|
||||
@customElement("hui-card")
|
||||
export class HuiCard extends ReactiveElement {
|
||||
export class HuiCard extends ConditionalListenerMixin(ReactiveElement) {
|
||||
@property({ type: Boolean }) public preview = false;
|
||||
|
||||
@property({ attribute: false }) public config?: LovelaceCardConfig;
|
||||
@@ -44,20 +41,16 @@ export class HuiCard extends ReactiveElement {
|
||||
|
||||
private _element?: LovelaceCard;
|
||||
|
||||
private _listeners: MediaQueriesListener[] = [];
|
||||
|
||||
protected createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearMediaQueries();
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._listenMediaQueries();
|
||||
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) {
|
||||
if (!this._element || !this.hass) {
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
||||
@@ -97,7 +98,10 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
||||
: `${sandbox_user_params} ${IFRAME_SANDBOX}`;
|
||||
|
||||
return html`
|
||||
<ha-card .header=${this._config.title}>
|
||||
<ha-card
|
||||
class=${classMap({ "hide-background": this._config.hide_background })}
|
||||
.header=${this._config.title}
|
||||
>
|
||||
<div
|
||||
id="root"
|
||||
style=${styleMap({
|
||||
@@ -133,6 +137,12 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
ha-card.hide-background {
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -64,6 +64,8 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
||||
|
||||
@state() private _targetPickerValue: HassServiceTarget = {};
|
||||
|
||||
@state() private _stateFilter?: string[];
|
||||
|
||||
public getCardSize(): number {
|
||||
return 9 + (this._config?.title ? 1 : 0);
|
||||
}
|
||||
@@ -129,6 +131,8 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
||||
};
|
||||
|
||||
this._targetPickerValue = target;
|
||||
|
||||
this._stateFilter = ensureArray(config.state_filter);
|
||||
}
|
||||
|
||||
private _getEntityIds(): string[] | undefined {
|
||||
@@ -209,6 +213,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
||||
.hass=${this.hass}
|
||||
.time=${this._time}
|
||||
.entityIds=${this._getEntityIds()}
|
||||
.stateFilter=${this._stateFilter}
|
||||
narrow
|
||||
relative-time
|
||||
virtualize
|
||||
|
||||
@@ -323,6 +323,7 @@ export interface IframeCardConfig extends LovelaceCardConfig {
|
||||
title?: string;
|
||||
allow?: string;
|
||||
url: string;
|
||||
hide_background?: boolean;
|
||||
}
|
||||
|
||||
export interface LightCardConfig extends LovelaceCardConfig {
|
||||
@@ -345,6 +346,7 @@ export interface LogbookCardConfig extends LovelaceCardConfig {
|
||||
title?: string;
|
||||
hours_to_show?: number;
|
||||
theme?: string;
|
||||
state_filter?: string[];
|
||||
}
|
||||
|
||||
export interface MapEntityConfig extends EntityConfig {
|
||||
|
||||
@@ -20,10 +20,11 @@ const calcPoints = (
|
||||
}
|
||||
});
|
||||
const rangeY = maxY - minY || minY * 0.1;
|
||||
// add top and bottom margins to prevent cropping
|
||||
maxY += rangeY * 0.1;
|
||||
minY -= rangeY * 0.1;
|
||||
if (maxY < 0) {
|
||||
// all values are negative
|
||||
// add margin
|
||||
maxY += rangeY * 0.1;
|
||||
maxY = Math.min(0, maxY);
|
||||
yAxisOrigin = 0;
|
||||
} else if (minY < 0) {
|
||||
@@ -31,8 +32,6 @@ const calcPoints = (
|
||||
yAxisOrigin = (maxY / (maxY - minY || 1)) * height;
|
||||
} else {
|
||||
// all values are positive
|
||||
// add margin
|
||||
minY -= rangeY * 0.1;
|
||||
minY = Math.max(0, minY);
|
||||
}
|
||||
const yDenom = maxY - minY || 1;
|
||||
|
||||
@@ -67,7 +67,7 @@ export const handleAction = async (
|
||||
await hass.loadBackendTranslation("title");
|
||||
const localize = await hass.loadBackendTranslation("services");
|
||||
serviceName = `${domainToName(localize, domain)}: ${
|
||||
localize(`component.${domain}.services.${serviceName}.name`) ||
|
||||
localize(`component.${domain}.services.${service}.name`) ||
|
||||
serviceDomains[domain][service].name ||
|
||||
service
|
||||
}`;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { ensureArray } from "../../../common/array/ensure-array";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import { listenMediaQuery } from "../../../common/dom/media_query";
|
||||
|
||||
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { UNKNOWN } from "../../../data/entity";
|
||||
import { getUserPerson } from "../../../data/person";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { ensureArray } from "../../../common/array/ensure-array";
|
||||
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
||||
|
||||
export type Condition =
|
||||
| LocationCondition
|
||||
@@ -362,31 +359,3 @@ export function addEntityToCondition(
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
|
||||
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;
|
||||
}, []);
|
||||
}
|
||||
|
||||
export function attachConditionMediaQueriesListeners(
|
||||
conditions: Condition[],
|
||||
onChange: (visibility: boolean) => void
|
||||
): MediaQueriesListener[] {
|
||||
const mediaQueries = extractMediaQueries(conditions);
|
||||
|
||||
const listeners = mediaQueries.map((query) => {
|
||||
const listener = listenMediaQuery(query, (matches) => {
|
||||
onChange(matches);
|
||||
});
|
||||
return listener;
|
||||
});
|
||||
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import { ReactiveElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import { deepEqual } from "../../../common/util/deep-equal";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||
import type { HuiCard } from "../cards/hui-card";
|
||||
import type { ConditionalCardConfig } from "../cards/types";
|
||||
import type { Condition } from "../common/validate-condition";
|
||||
import {
|
||||
attachConditionMediaQueriesListeners,
|
||||
checkConditionsMet,
|
||||
extractMediaQueries,
|
||||
validateConditionalConfig,
|
||||
} from "../common/validate-condition";
|
||||
import type { ConditionalRowConfig, LovelaceRow } from "../entity-rows/types";
|
||||
@@ -22,7 +19,9 @@ declare global {
|
||||
}
|
||||
|
||||
@customElement("hui-conditional-base")
|
||||
export class HuiConditionalBase extends ReactiveElement {
|
||||
export class HuiConditionalBase extends ConditionalListenerMixin(
|
||||
ReactiveElement
|
||||
) {
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
|
||||
@property({ type: Boolean }) public preview = false;
|
||||
@@ -31,10 +30,6 @@ export class HuiConditionalBase extends ReactiveElement {
|
||||
|
||||
protected _element?: HuiCard | LovelaceRow;
|
||||
|
||||
private _listeners: MediaQueriesListener[] = [];
|
||||
|
||||
private _mediaQueries: string[] = [];
|
||||
|
||||
protected createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
@@ -63,51 +58,25 @@ export class HuiConditionalBase extends ReactiveElement {
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearMediaQueries();
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._listenMediaQueries();
|
||||
this._updateVisibility();
|
||||
}
|
||||
|
||||
private _clearMediaQueries() {
|
||||
this._listeners.forEach((unsub) => unsub());
|
||||
this._listeners = [];
|
||||
}
|
||||
|
||||
private _listenMediaQueries() {
|
||||
protected setupConditionalListeners() {
|
||||
if (!this._config || !this.hass) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter to supported conditions (those with 'condition' property)
|
||||
const supportedConditions = this._config.conditions.filter(
|
||||
(c) => "condition" in c
|
||||
) as Condition[];
|
||||
const mediaQueries = extractMediaQueries(supportedConditions);
|
||||
|
||||
if (deepEqual(mediaQueries, this._mediaQueries)) return;
|
||||
|
||||
this._clearMediaQueries();
|
||||
|
||||
const conditions = this._config.conditions;
|
||||
const hasOnlyMediaQuery =
|
||||
conditions.length === 1 &&
|
||||
"condition" in conditions[0] &&
|
||||
conditions[0].condition === "screen" &&
|
||||
!!conditions[0].media_query;
|
||||
|
||||
this._listeners = attachConditionMediaQueriesListeners(
|
||||
supportedConditions,
|
||||
(matches) => {
|
||||
if (hasOnlyMediaQuery) {
|
||||
this.setVisibility(matches);
|
||||
return;
|
||||
}
|
||||
this._updateVisibility();
|
||||
}
|
||||
);
|
||||
// Pass filtered conditions to parent implementation
|
||||
super.setupConditionalListeners(supportedConditions);
|
||||
}
|
||||
|
||||
protected update(changed: PropertyValues): void {
|
||||
@@ -119,22 +88,21 @@ export class HuiConditionalBase extends ReactiveElement {
|
||||
changed.has("hass") ||
|
||||
changed.has("preview")
|
||||
) {
|
||||
this._listenMediaQueries();
|
||||
this.clearConditionalListeners();
|
||||
this.setupConditionalListeners();
|
||||
this._updateVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
private _updateVisibility() {
|
||||
private _updateVisibility(conditionsMet?: boolean) {
|
||||
if (!this._element || !this.hass || !this._config) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._element.preview = this.preview;
|
||||
|
||||
const conditionMet = checkConditionsMet(
|
||||
this._config!.conditions,
|
||||
this.hass!
|
||||
);
|
||||
const conditionMet =
|
||||
conditionsMet ?? checkConditionsMet(this._config.conditions, this.hass);
|
||||
|
||||
this.setVisibility(conditionMet);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ const cardConfigStruct = assign(
|
||||
url: optional(string()),
|
||||
aspect_ratio: optional(string()),
|
||||
allow_open_top_navigation: optional(boolean()),
|
||||
hide_background: optional(boolean()),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -29,6 +30,7 @@ const SCHEMA = [
|
||||
{ name: "aspect_ratio", selector: { text: {} } },
|
||||
],
|
||||
},
|
||||
{ name: "hide_background", selector: { boolean: {} } },
|
||||
] as const;
|
||||
|
||||
@customElement("hui-iframe-card-editor")
|
||||
@@ -56,6 +58,7 @@ export class HuiIframeCardEditor
|
||||
.data=${this._config}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
.computeHelper=${this._computeHelperCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
`;
|
||||
@@ -65,8 +68,29 @@ export class HuiIframeCardEditor
|
||||
fireEvent(this, "config-changed", { config: ev.detail.value });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) =>
|
||||
this.hass!.localize(`ui.panel.lovelace.editor.card.generic.${schema.name}`);
|
||||
private _computeLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) => {
|
||||
switch (schema.name) {
|
||||
case "hide_background":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.iframe.hide_background"
|
||||
);
|
||||
default:
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
private _computeHelperCallback = (schema: SchemaUnion<typeof SCHEMA>) => {
|
||||
switch (schema.name) {
|
||||
case "hide_background":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.iframe.hide_background_helper"
|
||||
);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import type { HassServiceTarget } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import {
|
||||
array,
|
||||
assert,
|
||||
@@ -9,21 +11,21 @@ import {
|
||||
optional,
|
||||
string,
|
||||
} from "superstruct";
|
||||
import type { HassServiceTarget } from "home-assistant-js-websocket";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/entity/ha-entities-picker";
|
||||
import "../../../../components/ha-target-picker";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||
import "../../../../components/ha-target-picker";
|
||||
import type { HaEntityPickerEntityFilterFunc } from "../../../../data/entity";
|
||||
import { filterLogbookCompatibleEntities } from "../../../../data/logbook";
|
||||
import { targetStruct } from "../../../../data/script";
|
||||
import { resolveEntityIDs } from "../../../../data/selector";
|
||||
import { getSensorNumericDeviceClasses } from "../../../../data/sensor";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-logbook-card";
|
||||
import type { LogbookCardConfig } from "../../cards/types";
|
||||
import type { LovelaceCardEditor } from "../../types";
|
||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-logbook-card";
|
||||
import { targetStruct } from "../../../../data/script";
|
||||
import { getSensorNumericDeviceClasses } from "../../../../data/sensor";
|
||||
import type { HaEntityPickerEntityFilterFunc } from "../../../../data/entity";
|
||||
|
||||
const cardConfigStruct = assign(
|
||||
baseLovelaceCardConfig,
|
||||
@@ -33,6 +35,7 @@ const cardConfigStruct = assign(
|
||||
hours_to_show: optional(number()),
|
||||
theme: optional(string()),
|
||||
target: optional(targetStruct),
|
||||
state_filter: optional(array(string())),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -50,6 +53,13 @@ const SCHEMA = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "state_filter",
|
||||
context: {
|
||||
filter_entity: "context_entities",
|
||||
},
|
||||
selector: { state: { multiple: true } },
|
||||
},
|
||||
] as const;
|
||||
|
||||
@customElement("hui-logbook-card-editor")
|
||||
@@ -106,7 +116,13 @@ export class HuiLogbookCardEditor
|
||||
return html`
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${this._config}
|
||||
.data=${this._data(
|
||||
this._config,
|
||||
this._targetPicker,
|
||||
this.hass.entities,
|
||||
this.hass.devices,
|
||||
this.hass.areas
|
||||
)}
|
||||
.schema=${SCHEMA}
|
||||
.computeLabel=${this._computeLabelCallback}
|
||||
@value-changed=${this._valueChanged}
|
||||
@@ -116,12 +132,30 @@ export class HuiLogbookCardEditor
|
||||
.hass=${this.hass}
|
||||
.entityFilter=${this._filterFunc}
|
||||
.value=${this._targetPicker}
|
||||
add-on-top
|
||||
@value-changed=${this._entitiesChanged}
|
||||
></ha-target-picker>
|
||||
`;
|
||||
}
|
||||
|
||||
private _data = memoizeOne(
|
||||
(
|
||||
config: LogbookCardConfig,
|
||||
target: HassServiceTarget,
|
||||
entities: HomeAssistant["entities"],
|
||||
devices: HomeAssistant["devices"],
|
||||
areas: HomeAssistant["areas"]
|
||||
) => ({
|
||||
...config,
|
||||
context_entities: resolveEntityIDs(
|
||||
this.hass!,
|
||||
target,
|
||||
entities,
|
||||
devices,
|
||||
areas
|
||||
),
|
||||
})
|
||||
);
|
||||
|
||||
private _filterFunc: HaEntityPickerEntityFilterFunc = (entity) =>
|
||||
filterLogbookCompatibleEntities(entity, this._sensorNumericDeviceClasses);
|
||||
|
||||
@@ -131,7 +165,9 @@ export class HuiLogbookCardEditor
|
||||
}
|
||||
|
||||
private _valueChanged(ev: CustomEvent): void {
|
||||
fireEvent(this, "config-changed", { config: ev.detail.value });
|
||||
const newConfig = { ...ev.detail.value };
|
||||
delete newConfig.context_entities;
|
||||
fireEvent(this, "config-changed", { config: newConfig });
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) => {
|
||||
@@ -142,12 +178,23 @@ export class HuiLogbookCardEditor
|
||||
)} (${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.config.optional"
|
||||
)})`;
|
||||
case "state_filter":
|
||||
return this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.card.logbook.state_filter"
|
||||
);
|
||||
default:
|
||||
return this.hass!.localize(
|
||||
`ui.panel.lovelace.editor.card.generic.${schema.name}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
static styles = css`
|
||||
ha-target-picker {
|
||||
display: block;
|
||||
margin-top: var(--ha-space-4);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -2,13 +2,10 @@ import type { PropertyValues } from "lit";
|
||||
import { ReactiveElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import {
|
||||
attachConditionMediaQueriesListeners,
|
||||
checkConditionsMet,
|
||||
} from "../common/validate-condition";
|
||||
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||
import { checkConditionsMet } from "../common/validate-condition";
|
||||
import { createHeadingBadgeElement } from "../create-element/create-heading-badge-element";
|
||||
import type { LovelaceHeadingBadge } from "../types";
|
||||
import type { LovelaceHeadingBadgeConfig } from "./types";
|
||||
@@ -21,7 +18,7 @@ declare global {
|
||||
}
|
||||
|
||||
@customElement("hui-heading-badge")
|
||||
export class HuiHeadingBadge extends ReactiveElement {
|
||||
export class HuiHeadingBadge extends ConditionalListenerMixin(ReactiveElement) {
|
||||
@property({ type: Boolean }) public preview = false;
|
||||
|
||||
@property({ attribute: false }) public config?: LovelaceHeadingBadgeConfig;
|
||||
@@ -39,20 +36,16 @@ export class HuiHeadingBadge extends ReactiveElement {
|
||||
|
||||
private _element?: LovelaceHeadingBadge;
|
||||
|
||||
private _listeners: MediaQueriesListener[] = [];
|
||||
|
||||
protected createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearMediaQueries();
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._listenMediaQueries();
|
||||
this._updateVisibility();
|
||||
}
|
||||
|
||||
@@ -137,30 +130,6 @@ export class HuiHeadingBadge 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(forceVisible?: boolean) {
|
||||
if (!this._element || !this.hass) {
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,6 @@ import { ReactiveElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { storage } from "../../../common/decorators/storage";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import type { MediaQueriesListener } from "../../../common/dom/media_query";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import type { LovelaceSectionElement } from "../../../data/lovelace";
|
||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||
@@ -14,12 +13,10 @@ import type {
|
||||
} from "../../../data/lovelace/config/section";
|
||||
import { isStrategySection } from "../../../data/lovelace/config/section";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import { ConditionalListenerMixin } from "../../../mixins/conditional-listener-mixin";
|
||||
import "../cards/hui-card";
|
||||
import type { HuiCard } from "../cards/hui-card";
|
||||
import {
|
||||
attachConditionMediaQueriesListeners,
|
||||
checkConditionsMet,
|
||||
} from "../common/validate-condition";
|
||||
import { checkConditionsMet } from "../common/validate-condition";
|
||||
import { createSectionElement } from "../create-element/create-section-element";
|
||||
import { showCreateCardDialog } from "../editor/card-editor/show-create-card-dialog";
|
||||
import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog";
|
||||
@@ -37,7 +34,7 @@ declare global {
|
||||
}
|
||||
|
||||
@customElement("hui-section")
|
||||
export class HuiSection extends ReactiveElement {
|
||||
export class HuiSection extends ConditionalListenerMixin(ReactiveElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property({ attribute: false }) public config!: LovelaceSectionRawConfig;
|
||||
@@ -59,8 +56,6 @@ export class HuiSection extends ReactiveElement {
|
||||
|
||||
private _layoutElement?: LovelaceSectionElement;
|
||||
|
||||
private _listeners: MediaQueriesListener[] = [];
|
||||
|
||||
private _config: LovelaceSectionConfig | undefined;
|
||||
|
||||
@storage({
|
||||
@@ -114,14 +109,10 @@ export class HuiSection extends ReactiveElement {
|
||||
|
||||
public disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._clearMediaQueries();
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.hasUpdated) {
|
||||
this._listenMediaQueries();
|
||||
}
|
||||
this._updateElement();
|
||||
}
|
||||
|
||||
@@ -158,30 +149,6 @@ export class HuiSection 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 != null;
|
||||
|
||||
this._listeners = attachConditionMediaQueriesListeners(
|
||||
this._config.visibility,
|
||||
(matches) => {
|
||||
this._updateElement(hasOnlyMediaQuery && matches);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private async _initializeConfig() {
|
||||
let sectionConfig = { ...this.config };
|
||||
let isStrategy = false;
|
||||
@@ -199,9 +166,6 @@ export class HuiSection extends ReactiveElement {
|
||||
type: sectionConfig.type || DEFAULT_SECTION_LAYOUT,
|
||||
};
|
||||
this._config = sectionConfig;
|
||||
if (this.isConnected) {
|
||||
this._listenMediaQueries();
|
||||
}
|
||||
|
||||
// Create a new layout element if necessary.
|
||||
let addLayoutElement = false;
|
||||
|
||||
@@ -1434,6 +1434,7 @@
|
||||
"back_to_info": "Back to info",
|
||||
"info": "Information",
|
||||
"related": "Related",
|
||||
"add_entity_to": "Add to",
|
||||
"history": "History",
|
||||
"aggregate": "5-minute aggregated",
|
||||
"logbook": "Activity",
|
||||
@@ -1450,6 +1451,10 @@
|
||||
"last_action": "Last action",
|
||||
"last_triggered": "Last triggered"
|
||||
},
|
||||
"add_to": {
|
||||
"no_actions": "No actions available",
|
||||
"action_failed": "Failed to perform the action {error}"
|
||||
},
|
||||
"sun": {
|
||||
"azimuth": "Azimuth",
|
||||
"elevation": "Elevation",
|
||||
@@ -3071,6 +3076,7 @@
|
||||
"remove_co2_signal": "Remove Electricity Maps integration",
|
||||
"add_co2_signal": "Add Electricity Maps integration",
|
||||
"flow_dialog": {
|
||||
"cost_entity_helper": "Any sensor with a unit of `{currency}/(valid energy unit)` (e.g. `{currency}/Wh` or `{currency}/kWh`) may be used and will be automatically converted.",
|
||||
"from": {
|
||||
"header": "Configure grid consumption",
|
||||
"paragraph": "Grid consumption is the energy that flows from the energy grid to your home.",
|
||||
@@ -3631,6 +3637,36 @@
|
||||
"older_run": "Older run",
|
||||
"newer_run": "Newer run",
|
||||
"start_debug_run": "Start debug run",
|
||||
"error": {
|
||||
"code": "Error code",
|
||||
"fetch_events": "Failed to fetch events",
|
||||
"fetch_runs": "Failed to fetch pipeline runs",
|
||||
"playing_audio": "Error playing audio",
|
||||
"showing_run": "Error showing run",
|
||||
"title": "Error"
|
||||
},
|
||||
"no_events": "There were no events in this run.",
|
||||
"play_audio": "Play audio",
|
||||
"raw": "Raw",
|
||||
"run": "Run",
|
||||
"stages": {
|
||||
"engine": "Engine",
|
||||
"input": "Input",
|
||||
"language": "Language",
|
||||
"model": "Model",
|
||||
"natural_language_processing": "Natural language processing",
|
||||
"output": "Output",
|
||||
"pipeline": "Pipeline",
|
||||
"prefer_local": "Prefer handling locally",
|
||||
"processed_locally": "Processed locally",
|
||||
"response_type": "Response type",
|
||||
"speech_to_text": "Speech-to-text",
|
||||
"text_to_speech": "Text-to-speech",
|
||||
"timestamp": "Timestamp",
|
||||
"voice": "Voice",
|
||||
"wake_word": "Wake word"
|
||||
},
|
||||
"stop_audio": "Stop audio",
|
||||
"pipeline": {
|
||||
"header": "Assist pipeline",
|
||||
"run_text_pipeline": "Run text pipeline",
|
||||
@@ -6526,7 +6562,8 @@
|
||||
"model": "Model",
|
||||
"status": "Status",
|
||||
"version": "Version",
|
||||
"data_rate": "Data rate"
|
||||
"data_rate": "Data rate",
|
||||
"area": "Area"
|
||||
},
|
||||
"node_status": {
|
||||
"0": "Unknown",
|
||||
@@ -7106,6 +7143,11 @@
|
||||
"card_indicates_energy_used": "This card indicates how much of the electricity consumed by your home was generated using non-fossil fuels like solar, wind, and nuclear. The higher, the better!",
|
||||
"low_carbon_energy_consumed": "Low-carbon electricity consumed",
|
||||
"low_carbon_energy_not_calculated": "Consumed low-carbon electricity couldn't be calculated"
|
||||
},
|
||||
"energy_compare": {
|
||||
"info": "You are comparing the period {start} with the period {end}",
|
||||
"compare_previous_year": "Compare previous year",
|
||||
"compare_previous_period": "Compare previous period"
|
||||
}
|
||||
},
|
||||
"heading": {
|
||||
@@ -7669,7 +7711,8 @@
|
||||
},
|
||||
"logbook": {
|
||||
"name": "Activity",
|
||||
"description": "The Activity card shows a list of events for entities."
|
||||
"description": "The Activity card shows a list of events for entities.",
|
||||
"state_filter": "State filter"
|
||||
},
|
||||
"history-graph": {
|
||||
"name": "History graph",
|
||||
@@ -7747,7 +7790,9 @@
|
||||
},
|
||||
"iframe": {
|
||||
"name": "Webpage",
|
||||
"description": "The Webpage card allows you to embed your favorite webpage right into Home Assistant."
|
||||
"description": "The Webpage card allows you to embed your favorite webpage right into Home Assistant.",
|
||||
"hide_background": "Hide background",
|
||||
"hide_background_helper": "Useful for pages which allow a transparent background."
|
||||
},
|
||||
"light": {
|
||||
"name": "Light",
|
||||
@@ -9353,11 +9398,6 @@
|
||||
"energy": {
|
||||
"download_data": "[%key:ui::panel::history::download_data%]",
|
||||
"configure": "[%key:ui::dialogs::quick-bar::commands::navigation::energy%]",
|
||||
"compare": {
|
||||
"info": "You are comparing the period {start} with the period {end}",
|
||||
"compare_previous_year": "Compare previous year",
|
||||
"compare_previous_period": "Compare previous period"
|
||||
},
|
||||
"setup": {
|
||||
"next": "Next",
|
||||
"back": "Back",
|
||||
|
||||
Reference in New Issue
Block a user