mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-30 16:49:04 +00:00
Compare commits
32
Commits
dev
..
20261125.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14034dda2d | ||
|
|
47582923aa | ||
|
|
75555390a1 | ||
|
|
9e39b72de4 | ||
|
|
2ae815f1fd | ||
|
|
92045529e2 | ||
|
|
baaf5d1503 | ||
|
|
39b5f62cdb | ||
|
|
77f2230f9b | ||
|
|
2cab493aaa | ||
|
|
c024b4594a | ||
|
|
b76650cb55 | ||
|
|
eae1d81471 | ||
|
|
99b9f2593c | ||
|
|
43b6d8a0ea | ||
|
|
caccbf3c59 | ||
|
|
e5f408fca0 | ||
|
|
1c70897226 | ||
|
|
3a27de8e0a | ||
|
|
bc21f2903d | ||
|
|
b067ce5515 | ||
|
|
c95ed9f16c | ||
|
|
95eb2641e2 | ||
|
|
4cb23b772a | ||
|
|
0bf5da2e09 | ||
|
|
c12ad32797 | ||
|
|
2c03c2d74a | ||
|
|
2705e6da51 | ||
|
|
e3871d47de | ||
|
|
ead8c01926 | ||
|
|
258cb6f8b9 | ||
|
|
72057cf504 |
No files matched your search
@@ -1,43 +0,0 @@
|
||||
---
|
||||
name: ha-frontend-browser-checks
|
||||
description: Check a Home Assistant frontend change in a browser and show it in a pull request. Use when checking how a change looks or behaves at different screen sizes, in light and dark mode, right to left (RTL) or with long translations, or when taking before and after screenshots or recording a demo of a feature for a pull request.
|
||||
---
|
||||
|
||||
# HA Frontend Browser Checks
|
||||
|
||||
Use this skill to check a visible change in a browser and to show it in a pull request. Any browser tool you already have works if it can open a page, set its size, run a script in it, take screenshots and record video. Load `ha-frontend-testing` for the dev servers, and `ha-frontend-loading` for loading states.
|
||||
|
||||
Screenshots and recordings help reviewers see what changed, but they don't make a large change easy to review. [Keep pull requests small](https://contributors.home-assistant.io/start/pull-requests/#keep-it-small), and make sure you have reviewed and understood the change and can explain it, as the [AI policy](https://contributors.home-assistant.io/start/ai-policy/) asks.
|
||||
|
||||
## Check Real Devices
|
||||
|
||||
Check the sizes the change affects rather than one fixed size, such as a phone, a tablet in both orientations, a laptop and a large desktop monitor. Include a small phone. Take each device's viewport in CSS pixels, its pixel ratio and touch support from the device presets your tools have, rather than from memory, and check the page really has that size once it's set.
|
||||
|
||||
## Check Light And Dark
|
||||
|
||||
When the change can look different in light and dark mode, such as a colour, border, background or image, check it in both. Switch the colour scheme in your browser tool, with the profile's theme following it, or pick light and dark in the profile. A fix for one mode only needs that mode.
|
||||
|
||||
## Check Right To Left (RTL)
|
||||
|
||||
Check layout, alignment, icons and anything with a direction in RTL. In the app, set your profile language to one written right to left, then set it back: many components take their direction from the language, so setting the page to RTL in your browser tool leaves them left to right. The gallery's RTL toggle checks styling only.
|
||||
|
||||
## Check Long Text
|
||||
|
||||
When a change adds or changes text, check it in a language with long words or long translations too, so labels, descriptions and buttons don't overflow or wrap badly. When the new string isn't translated yet, try a rough translation to check its length.
|
||||
|
||||
## Show It In The Pull Request
|
||||
|
||||
- When the change alters something that exists already, capture the same screen on `dev` and on your branch, in the same state, and put them side by side. Only a new screen, with nothing before it, needs just the after.
|
||||
- Keep the size of every capture fixed, screenshots as well as videos. Set the page size before you capture and don't change it in between, and capture the same area each time, so the subject sits in the same place in before and after. For a card or other part of the page, work out a fixed area around it for each size you test, and use that same area on both branches.
|
||||
- Say which device, size or mode each capture shows.
|
||||
- Make the change easy to see: capture the part of the screen it affects rather than a whole page where it's a few pixels.
|
||||
- Save captures outside the repository, so they can't be committed by accident.
|
||||
- Keep personal details out: use demo data, such as the demo or the Demo integration, and mask anything else before you capture, such as names, addresses, IP and MAC addresses, hostnames, serial numbers and tokens. Check each capture before you attach it.
|
||||
|
||||
Record a video when it shows the change better than a still, such as an animation, a drag, a loading sequence (hold the loading state as "Checking It" in `ha-frontend-loading` shows) or a flow across several screens. Keep each video short and small: GitHub limits upload sizes, and reviewers have to watch it. You can record it yourself with the tools you have; it doesn't need a person.
|
||||
|
||||
- Use the recording tools at hand: your browser tool's recorder for a page, or a desktop screen recorder for a window, such as a phone emulator, so the device frame shows.
|
||||
- Don't resize, zoom or take screenshots while recording, which redraw the page at another size and make the video jump.
|
||||
- Check the whole recording before you attach it. For a short clip, look at a frame every second or half second, not only the first and last, since the page can jump to another size partway through. Record again if it does. Take stills from the same frames, so they match the video.
|
||||
- Keep the window drawn on a screen. A hidden or minimised window records only a frame every few seconds.
|
||||
- Label each video, such as **Before** and **After**, and say what it shows and how you set it up. Say what you didn't record and why.
|
||||
@@ -20,7 +20,7 @@ When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the body
|
||||
- Do not omit, reorder, or rewrite template sections.
|
||||
- Check the appropriate "Type of change" box based on the actual change.
|
||||
- Do not check checklist items on behalf of the user.
|
||||
- If the PR includes UI changes, add screenshots or a short video, taken as `ha-frontend-browser-checks` describes. Only ask the user to add them when you can't take them yourself.
|
||||
- If the PR includes UI changes, remind the user to add screenshots or a short video.
|
||||
- Explain what the change does for users, not only implementation details.
|
||||
- Use Markdown.
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ workflows:
|
||||
- 'actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9'
|
||||
'.github/workflows/codeql-analysis.yaml':
|
||||
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
- 'github/codeql-action@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea'
|
||||
- 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066'
|
||||
'.github/workflows/copilot-setup-steps.yml':
|
||||
- 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9'
|
||||
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
@@ -29,7 +29,7 @@ workflows:
|
||||
- 'actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1'
|
||||
'.github/workflows/dependency-review.yaml':
|
||||
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
- 'actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec'
|
||||
- 'actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294'
|
||||
- 'actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3'
|
||||
'.github/workflows/design_deployment.yaml':
|
||||
- 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9'
|
||||
@@ -101,9 +101,9 @@ dependencies:
|
||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
owner_id: 44036562
|
||||
repo_id: 197814629
|
||||
'actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec':
|
||||
ref: 'v5.0.1'
|
||||
commit: 'sha1-bbc44d14a204704ccc493733616cd1e93a0321ec'
|
||||
'actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294':
|
||||
ref: 'v5.0.0'
|
||||
commit: 'sha1-a1d282b36b6f3519aa1f3fc636f609c47dddb294'
|
||||
owner_id: 44036562
|
||||
repo_id: 476372928
|
||||
'actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333':
|
||||
@@ -151,9 +151,9 @@ dependencies:
|
||||
commit: 'sha1-89ae32b08ed1a541efecbab17912962a5e38981c'
|
||||
owner_id: 7513068
|
||||
repo_id: 113918130
|
||||
'github/codeql-action@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea':
|
||||
ref: 'v4.39.4'
|
||||
commit: 'sha1-1bd86f2fdb4b86187fa4059f16f31a3202acc9ea'
|
||||
'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066':
|
||||
ref: 'v4.39.3'
|
||||
commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066'
|
||||
owner_id: 9919
|
||||
repo_id: 259445878
|
||||
'home-assistant/[email protected]':
|
||||
|
||||
@@ -32,12 +32,12 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
|
||||
uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||
with:
|
||||
languages: javascript-typescript
|
||||
build-mode: none
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
|
||||
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||
with:
|
||||
category: "/language:javascript-typescript"
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
contents: read # To compare the dependency graph between base and head
|
||||
steps:
|
||||
- name: Dependency review
|
||||
uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1
|
||||
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
||||
with:
|
||||
license-check: false # Covered by pnpm lint:licenses
|
||||
fail-on-severity: high
|
||||
|
||||
@@ -53,11 +53,10 @@ Detailed guidance lives in `.agents/skills/<name>/SKILL.md`. Load every matching
|
||||
- `ha-frontend-ux-readiness`: UI/UX routing that complements frontend review for new user experiences.
|
||||
- `ha-frontend-gallery`: gallery pages, demos, sidebar structure, content, and verification.
|
||||
- `ha-frontend-demo`: standalone demo structure, configurations, navigation, shared stubs, and verification.
|
||||
- `ha-frontend-browser-checks`: checking a change in a browser at real device sizes, in light and dark mode, right to left (RTL) and with long translations, and screenshots and recorded demos for pull requests.
|
||||
|
||||
## Pull Requests
|
||||
|
||||
When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the PR body. Preserve template sections, check only the appropriate type-of-change boxes, and do not check checklist items on behalf of the user. If the PR includes UI changes, add screenshots or a short video, taken as `ha-frontend-browser-checks` describes. Only ask the user to add them when you can't take them yourself.
|
||||
When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the PR body. Preserve template sections, check only the appropriate type-of-change boxes, and do not check checklist items on behalf of the user. If the PR includes UI changes, remind the user to add screenshots or a short video.
|
||||
|
||||
## AI policy
|
||||
|
||||
|
||||
@@ -25,7 +25,13 @@ const NOTICE_FILES = [path.join(NODE_MODULES, "echarts/NOTICE")];
|
||||
// that the new version's license still matches. The build will fail if
|
||||
// the pinned version is no longer installed.
|
||||
const LICENSE_OVERRIDES = [
|
||||
// No entries currently needed.
|
||||
{
|
||||
// type-fest ships two license files (MIT for code, CC0 for types).
|
||||
// We use the MIT license since that covers the bundled code.
|
||||
packageName: "type-fest",
|
||||
version: "5.10.0",
|
||||
licenseFile: "license-mit",
|
||||
},
|
||||
];
|
||||
|
||||
// Locate the directory of an installed package matching an exact version.
|
||||
|
||||
+31
-31
@@ -43,28 +43,28 @@
|
||||
"@babel/runtime": "8.1.3",
|
||||
"@braintree/sanitize-url": "7.1.2",
|
||||
"@codemirror/autocomplete": "6.20.4",
|
||||
"@codemirror/commands": "6.11.2",
|
||||
"@codemirror/commands": "6.11.1",
|
||||
"@codemirror/lang-jinja": "6.0.1",
|
||||
"@codemirror/lang-python": "6.2.1",
|
||||
"@codemirror/lang-yaml": "6.1.3",
|
||||
"@codemirror/language": "6.13.1",
|
||||
"@codemirror/lint": "6.9.8",
|
||||
"@codemirror/search": "6.7.3",
|
||||
"@codemirror/search": "6.7.2",
|
||||
"@codemirror/state": "6.7.6",
|
||||
"@codemirror/view": "6.44.2",
|
||||
"@codemirror/view": "6.43.15",
|
||||
"@date-fns/tz": "1.5.0",
|
||||
"@egjs/hammerjs": "2.0.17",
|
||||
"@formatjs/intl-datetimeformat": "8.2.2",
|
||||
"@formatjs/intl-displaynames": "8.0.5",
|
||||
"@formatjs/intl-durationformat": "0.13.2",
|
||||
"@formatjs/intl-getcanonicallocales": "3.4.2",
|
||||
"@formatjs/intl-listformat": "9.1.2",
|
||||
"@formatjs/intl-locale": "5.5.2",
|
||||
"@formatjs/intl-numberformat": "10.1.2",
|
||||
"@formatjs/intl-pluralrules": "7.1.2",
|
||||
"@formatjs/intl-relativetimeformat": "13.0.5",
|
||||
"@formatjs/intl-datetimeformat": "8.0.3",
|
||||
"@formatjs/intl-displaynames": "8.0.3",
|
||||
"@formatjs/intl-durationformat": "0.13.0",
|
||||
"@formatjs/intl-getcanonicallocales": "3.4.0",
|
||||
"@formatjs/intl-listformat": "9.1.0",
|
||||
"@formatjs/intl-locale": "5.5.0",
|
||||
"@formatjs/intl-numberformat": "10.1.0",
|
||||
"@formatjs/intl-pluralrules": "7.1.0",
|
||||
"@formatjs/intl-relativetimeformat": "13.0.3",
|
||||
"@home-assistant/webawesome": "3.14.0-ha.2",
|
||||
"@lezer/common": "1.5.7",
|
||||
"@lezer/common": "1.5.6",
|
||||
"@lezer/highlight": "1.2.5",
|
||||
"@lit-labs/motion": "1.1.0",
|
||||
"@lit-labs/observers": "2.1.0",
|
||||
@@ -79,12 +79,12 @@
|
||||
"@swc/helpers": "0.5.24",
|
||||
"@tsparticles/engine": "4.5.4",
|
||||
"@tsparticles/preset-links": "4.5.4",
|
||||
"@versatiles/style": "9.1.3",
|
||||
"@versatiles/style": "9.1.0",
|
||||
"@vibrant/color": "4.0.4",
|
||||
"@vvo/tzdb": "6.208.0",
|
||||
"@vvo/tzdb": "6.204.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.11",
|
||||
"barcode-detector": "3.2.5",
|
||||
"cally": "0.10.0",
|
||||
"barcode-detector": "3.2.4",
|
||||
"cally": "0.9.2",
|
||||
"color-name": "2.1.1",
|
||||
"comlink": "4.4.2",
|
||||
"core-js": "3.51.0",
|
||||
@@ -102,15 +102,15 @@
|
||||
"hls.js": "1.7.4",
|
||||
"home-assistant-js-websocket": "9.9.0",
|
||||
"idb-keyval": "6.3.0",
|
||||
"intl-messageformat": "12.2.1",
|
||||
"intl-messageformat": "12.2.0",
|
||||
"js-yaml": "5.5.0",
|
||||
"leaflet": "1.9.4",
|
||||
"leaflet.markercluster": "1.5.3",
|
||||
"lit": "3.3.3",
|
||||
"lit-html": "3.3.3",
|
||||
"maplibre-gl": "6.20.0",
|
||||
"marked": "18.3.0",
|
||||
"memoize-one": "7.0.0",
|
||||
"maplibre-gl": "6.19.0",
|
||||
"marked": "18.2.1",
|
||||
"memoize-one": "6.0.0",
|
||||
"nanoid": "6.0.2",
|
||||
"node-vibrant": "4.0.4",
|
||||
"object-hash": "3.0.0",
|
||||
@@ -147,13 +147,13 @@
|
||||
"@eslint/js": "10.0.1",
|
||||
"@gfx/zopfli": "1.0.15",
|
||||
"@home-assistant/components": "workspace:*",
|
||||
"@html-eslint/eslint-plugin": "0.69.0",
|
||||
"@html-eslint/eslint-plugin": "0.68.0",
|
||||
"@lokalise/node-api": "17.0.1",
|
||||
"@octokit/auth-oauth-device": "8.0.5",
|
||||
"@octokit/rest": "22.0.1",
|
||||
"@playwright/test": "1.65.1",
|
||||
"@rsdoctor/rspack-plugin": "1.6.5",
|
||||
"@rspack/core": "2.3.4",
|
||||
"@rspack/core": "2.3.3",
|
||||
"@rspack/dev-server": "2.2.2",
|
||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||
"@types/chromecast-caf-receiver": "7.0.1",
|
||||
@@ -162,15 +162,15 @@
|
||||
"@types/culori": "4.0.1",
|
||||
"@types/geojson": "7946.0.16",
|
||||
"@types/html-minifier-terser": "7.0.2",
|
||||
"@types/leaflet": "1.9.23",
|
||||
"@types/leaflet": "1.9.22",
|
||||
"@types/leaflet.markercluster": "1.5.6",
|
||||
"@types/lodash.merge": "4.6.9",
|
||||
"@types/node": "24.19.4",
|
||||
"@types/node": "24.19.2",
|
||||
"@types/qrcode": "1.5.6",
|
||||
"@types/sortablejs": "1.15.9",
|
||||
"@types/tar": "7.0.87",
|
||||
"@typescript/native": "npm:[email protected]",
|
||||
"@vitest/coverage-v8": "5.1.2",
|
||||
"@vitest/coverage-v8": "5.1.1",
|
||||
"babel-loader": "10.1.1",
|
||||
"babel-plugin-polyfill-corejs3": "1.0.0",
|
||||
"browserslist": "4.29.6",
|
||||
@@ -178,7 +178,7 @@
|
||||
"core-js-compat": "3.51.0",
|
||||
"del": "9.0.1",
|
||||
"eslint": "10.15.0",
|
||||
"eslint-config-prettier": "10.1.9",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-import-resolver-webpack": "0.13.11",
|
||||
"eslint-plugin-import-x": "4.18.1",
|
||||
"eslint-plugin-lit": "2.3.1",
|
||||
@@ -210,14 +210,14 @@
|
||||
"rspack-manifest-plugin": "5.2.2",
|
||||
"serve": "14.2.8",
|
||||
"sinon": "22.1.0",
|
||||
"tar": "7.5.24",
|
||||
"tar": "7.5.23",
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.74.0",
|
||||
"vite": "8.4.0",
|
||||
"typescript-eslint": "8.73.0",
|
||||
"vite": "8.3.8",
|
||||
"vite-tsconfig-paths": "6.1.1",
|
||||
"vitest": "5.1.2",
|
||||
"vitest": "5.1.1",
|
||||
"webpack-stats-plugin": "1.1.3",
|
||||
"webpackbar": "7.0.0",
|
||||
"workbox-build": "7.4.1"
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@custom-elements-manifest/analyzer": "0.11.0",
|
||||
"@rslib/core": "1.1.0",
|
||||
"@rslib/core": "1.0.7",
|
||||
"lit": "3.3.3",
|
||||
"typescript": "6.0.3"
|
||||
}
|
||||
|
||||
Generated
+702
-784
File diff suppressed because it is too large.
Load diff
@@ -18,8 +18,6 @@ trustPolicyExclude:
|
||||
- [email protected]
|
||||
# Pre-release published without provenance, used by workbox-build
|
||||
- "@trickfilm400/[email protected]"
|
||||
# Published without the trusted-publisher record; provenance still from vvo/tzdb release.yml
|
||||
- "@vvo/[email protected]"
|
||||
|
||||
# Dependency build scripts are denied unless listed here with true
|
||||
allowBuilds:
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "home-assistant-frontend"
|
||||
version = "20261125.0"
|
||||
version = "20261125.2"
|
||||
license = "Apache-2.0"
|
||||
license-files = ["LICENSE*"]
|
||||
description = "The Home Assistant frontend"
|
||||
|
||||
+2
-2
@@ -126,9 +126,9 @@
|
||||
"matchPackageNames": ["echarts", "zrender"]
|
||||
},
|
||||
{
|
||||
"description": "Group formatjs monorepo packages",
|
||||
"description": "Group formatjs monorepo package",
|
||||
"groupName": "formatjs",
|
||||
"matchPackageNames": ["@formatjs/**", "intl-messageformat"]
|
||||
"matchPackageNames": ["@formatjs/**"]
|
||||
},
|
||||
{
|
||||
"description": "Group Playwright package and CI container updates",
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import type { ReactiveControllerHost } from "@lit/reactive-element/reactive-controller";
|
||||
import type {
|
||||
ConditionContext,
|
||||
VisibilityCondition,
|
||||
} from "../../panels/lovelace/common/validate-condition";
|
||||
import { addEntityToCondition } from "../../panels/lovelace/common/validate-condition";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { ConditionEvaluation } from "../controllers/condition-evaluator-controller";
|
||||
import { ConditionEvaluatorController } from "../controllers/condition-evaluator-controller";
|
||||
import { dropInvalidConditions } from "./sanitize";
|
||||
|
||||
export interface VisibilitySubscription {
|
||||
/** Pass each new hass object so client-side conditions check again. */
|
||||
update(hass: HomeAssistant): void;
|
||||
/** Close the subscriptions. `onChange` is not called again. */
|
||||
unsubscribe(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Live visibility of a list of dashboard visibility conditions, for code
|
||||
* without a Lit host, such as custom cards and plugins. Conditions core
|
||||
* evaluates are subscribed to; the rest are checked locally. Reports
|
||||
* `unknown` until core replies.
|
||||
*/
|
||||
export const subscribeVisibility = (
|
||||
hass: HomeAssistant,
|
||||
conditions: VisibilityCondition[],
|
||||
onChange: (result: ConditionEvaluation, error?: string) => void,
|
||||
context: ConditionContext = {}
|
||||
): VisibilitySubscription => {
|
||||
// The controller only needs a host to register with and to re-render.
|
||||
const host: ReactiveControllerHost = {
|
||||
addController: () => undefined,
|
||||
removeController: () => undefined,
|
||||
requestUpdate: () => undefined,
|
||||
updateComplete: Promise.resolve(true),
|
||||
};
|
||||
|
||||
let active = true;
|
||||
|
||||
const controller = new ConditionEvaluatorController(host, {
|
||||
resubscribeDelay: 0,
|
||||
onResult: (result, error) => {
|
||||
if (active) {
|
||||
onChange(result, error);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const sanitized = dropInvalidConditions(conditions);
|
||||
const { entity_id: entityId } = context;
|
||||
|
||||
// Core-evaluated conditions never see the context, so fold its entity in
|
||||
// first, as the dashboard mixin does.
|
||||
const validConditions = entityId
|
||||
? sanitized.map((condition) => addEntityToCondition(condition, entityId))
|
||||
: sanitized;
|
||||
const getContext = () => context;
|
||||
|
||||
controller.hostConnected();
|
||||
controller.observe(validConditions, hass, getContext);
|
||||
|
||||
return {
|
||||
update: (newHass) => {
|
||||
if (active) {
|
||||
controller.observe(validConditions, newHass, getContext);
|
||||
}
|
||||
},
|
||||
unsubscribe: () => {
|
||||
active = false;
|
||||
controller.hostDisconnected();
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -245,7 +245,7 @@ export class HaCameraPlayer extends LitElement {
|
||||
const aspectRatio = this._aspectRatio();
|
||||
if (aspectRatio !== this._firedAspectRatio) {
|
||||
this._firedAspectRatio = aspectRatio;
|
||||
fireEvent(this, "media-size-changed", { aspectRatio });
|
||||
fireEvent(this, "camera-aspect-ratio-changed", { aspectRatio });
|
||||
}
|
||||
if (changedProps.has("keepAwake")) {
|
||||
if (this.keepAwake) {
|
||||
@@ -1282,7 +1282,6 @@ declare global {
|
||||
"ha-camera-player": HaCameraPlayer;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
/** The natural width limits the picture's width when it is set */
|
||||
"media-size-changed": { aspectRatio: number; naturalWidth?: number };
|
||||
"camera-aspect-ratio-changed": { aspectRatio: number };
|
||||
}
|
||||
}
|
||||
@@ -328,11 +328,6 @@ export function generateStatisticsChartData(
|
||||
: undefined,
|
||||
color: chartType === "bar" ? backgroundColor : borderColor,
|
||||
};
|
||||
if (chartType === "bar") {
|
||||
// echarts sizes bars from the smallest gap between points, so sparse
|
||||
// data (one point, or points far apart) gets huge bars without a cap
|
||||
(series as BarSeriesOption).barMaxWidth = 50;
|
||||
}
|
||||
if (chartStacked) {
|
||||
series.stack = `band-stacked`;
|
||||
series.stackStrategy = "samesign";
|
||||
|
||||
@@ -139,17 +139,12 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
protected updated(changedProps: PropertyValues): void {
|
||||
super.updated(changedProps);
|
||||
const activeValue = this._getActiveValue();
|
||||
if (
|
||||
this._activeSlider &&
|
||||
activeValue != null &&
|
||||
changedProps.has(this._activeSlider) &&
|
||||
this[this._activeSlider] !== this._lastChanging
|
||||
) {
|
||||
this._lastChanging = this._steppedValue(activeValue);
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: this._lastChanging,
|
||||
});
|
||||
this._lastChanging = undefined;
|
||||
}
|
||||
if (!this._activeSlider) {
|
||||
if (changedProps.has("value")) {
|
||||
@@ -184,10 +179,6 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._destroyListeners();
|
||||
if (this._activeSlider) {
|
||||
this._cancelInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
private _managers: HammerManager[] = [];
|
||||
@@ -257,18 +248,6 @@ export class HaControlCircularSlider extends LitElement {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _cancelInteraction() {
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
}
|
||||
|
||||
private _setupListeners() {
|
||||
if (this._interactions && this._managers.length === 0) {
|
||||
this._interactions.forEach((interaction) => {
|
||||
@@ -300,7 +279,15 @@ export class HaControlCircularSlider extends LitElement {
|
||||
mc.add(new Tap({ event: "singletap" }));
|
||||
|
||||
const cancelInteraction = () => {
|
||||
this._cancelInteraction();
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
if (pressToActivate) {
|
||||
panRecognizer.set({ enable: false });
|
||||
}
|
||||
|
||||
@@ -73,15 +73,6 @@ export class HaDropdown extends Dropdown {
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
private override async showMenu() {
|
||||
// Flip away from the safe areas instead of opening into them, where the
|
||||
// max-height below would squeeze the menu.
|
||||
const styles = getComputedStyle(this);
|
||||
// @ts-ignore flipPadding is typed as a number, floating-ui accepts sides
|
||||
this.popup.flipPadding = {
|
||||
top: parseFloat(styles.getPropertyValue("--safe-area-inset-top")) || 0,
|
||||
bottom:
|
||||
parseFloat(styles.getPropertyValue("--safe-area-inset-bottom")) || 0,
|
||||
};
|
||||
// @ts-ignore
|
||||
await super.showMenu();
|
||||
const triggerElement = this.getTrigger();
|
||||
|
||||
@@ -45,7 +45,7 @@ function adjustRgb(
|
||||
if (wv != null) {
|
||||
return rgbw2rgb([...rgb, wv] as [number, number, number, number]);
|
||||
}
|
||||
if (cw != null && ww != null) {
|
||||
if (cw != null && ww !== null) {
|
||||
return rgbww2rgb(
|
||||
[...rgb, cw, ww] as [number, number, number, number, number],
|
||||
minKelvin,
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
getPanelIcon,
|
||||
getPanelIconPath,
|
||||
getPanelTitle,
|
||||
getSelectedPanelUrlPath,
|
||||
} from "../data/panel";
|
||||
import type { PersistentNotification } from "../data/persistent_notification";
|
||||
import { subscribeNotifications } from "../data/persistent_notification";
|
||||
@@ -232,36 +231,12 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const selectedPanel = this.hass.panelUrl;
|
||||
|
||||
// prettier-ignore
|
||||
return html`
|
||||
${this._renderHeader()}
|
||||
${this._renderAllPanels()}`;
|
||||
}
|
||||
|
||||
private _computeSidebarPanels(): [PanelInfo[], PanelInfo[]] | undefined {
|
||||
if (!this._panelOrder || !this._hiddenPanels) {
|
||||
return undefined;
|
||||
}
|
||||
return computePanels(
|
||||
this.hass.panels,
|
||||
getDefaultPanelUrlPath(this.hass),
|
||||
this._panelOrder,
|
||||
this._hiddenPanels,
|
||||
this.hass.locale
|
||||
);
|
||||
}
|
||||
|
||||
private _computeSelectedPanel(
|
||||
sidebarPanels: [PanelInfo[], PanelInfo[]] | undefined,
|
||||
route: Route | undefined
|
||||
): string {
|
||||
if (!route) {
|
||||
return this.hass.panelUrl;
|
||||
}
|
||||
const urlPaths = (sidebarPanels ?? [[], []])
|
||||
.flat()
|
||||
.map((panel) => panel.url_path);
|
||||
return getSelectedPanelUrlPath(urlPaths, route.path);
|
||||
${this._renderAllPanels(selectedPanel)}`;
|
||||
}
|
||||
|
||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||
@@ -279,20 +254,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (!this.hass) {
|
||||
return false;
|
||||
}
|
||||
if (changedProps.has("route")) {
|
||||
const sidebarPanels = this._computeSidebarPanels();
|
||||
const oldRoute = changedProps.get("route") as Route | undefined;
|
||||
if (
|
||||
this._computeSelectedPanel(sidebarPanels, oldRoute) !==
|
||||
this._computeSelectedPanel(sidebarPanels, this.route)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!changedProps.has("hass")) {
|
||||
if (!this.hass || !changedProps.has("hass")) {
|
||||
return false;
|
||||
}
|
||||
const oldHass = changedProps.get("hass") as HomeAssistant;
|
||||
@@ -393,9 +355,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private _renderAllPanels() {
|
||||
const sidebarPanels = this._computeSidebarPanels();
|
||||
const selectedPanel = this._computeSelectedPanel(sidebarPanels, this.route);
|
||||
private _renderAllPanels(selectedPanel: string) {
|
||||
const renderList = (content, cls: string, scrollable: boolean) =>
|
||||
html`<ha-list-nav
|
||||
class=${classMap({
|
||||
@@ -405,7 +365,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
>${content}</ha-list-nav
|
||||
>`;
|
||||
|
||||
if (!sidebarPanels) {
|
||||
if (!this._panelOrder || !this._hiddenPanels) {
|
||||
return html`<div class="panels-list">
|
||||
<div class="wrapper">
|
||||
${renderList(
|
||||
@@ -430,7 +390,15 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
const [beforeSpacer, afterSpacer] = sidebarPanels;
|
||||
const defaultPanel = getDefaultPanelUrlPath(this.hass);
|
||||
|
||||
const [beforeSpacer, afterSpacer] = computePanels(
|
||||
this.hass.panels,
|
||||
defaultPanel,
|
||||
this._panelOrder,
|
||||
this._hiddenPanels,
|
||||
this.hass.locale
|
||||
);
|
||||
|
||||
// prettier-ignore
|
||||
return html`<div class="panels-list">
|
||||
|
||||
@@ -200,7 +200,6 @@ class HaEntityMarker extends LitElement {
|
||||
}
|
||||
.entity-picture {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -196,21 +196,6 @@ export const getPanelIconPath = (panel: PanelInfo): string | undefined => {
|
||||
|
||||
export const FIXED_PANELS = [PROFILE_PANEL, "config", NOT_FOUND_PANEL];
|
||||
|
||||
// A panel's url_path can span several segments (e.g. "config/logs"), so the
|
||||
// most specific url_path matching the path wins over its first segment.
|
||||
export const getSelectedPanelUrlPath = (
|
||||
urlPaths: string[],
|
||||
path: string
|
||||
): string =>
|
||||
urlPaths.reduce(
|
||||
(selected, urlPath) =>
|
||||
urlPath.length > selected.length &&
|
||||
(path === `/${urlPath}` || path.startsWith(`/${urlPath}/`))
|
||||
? urlPath
|
||||
: selected,
|
||||
path.split("/")[1] ?? ""
|
||||
);
|
||||
|
||||
export interface PanelMutableParams {
|
||||
title?: string | null;
|
||||
icon?: string | null;
|
||||
|
||||
@@ -223,7 +223,6 @@ export const SENSOR_DEVICE_CLASS_UNITS: Record<string, (string | null)[]> = {
|
||||
voltage: ["kV", "MV", "mV", "V", "μV"],
|
||||
volume: ["CCF", "fl. oz.", "ft³", "gal", "L", "MCF", "mL", "m³"],
|
||||
volume_flow_rate: [
|
||||
"ft³/h",
|
||||
"ft³/min",
|
||||
"gal/d",
|
||||
"gal/h",
|
||||
@@ -400,7 +399,6 @@ export const SENSOR_DEVICE_CLASS_CONVERTIBLE_UNITS: Record<
|
||||
voltage: ["kV", "MV", "mV", "V", "μV"],
|
||||
volume: ["CCF", "fl. oz.", "ft³", "gal", "L", "MCF", "mL", "m³"],
|
||||
volume_flow_rate: [
|
||||
"ft³/h",
|
||||
"ft³/min",
|
||||
"gal/d",
|
||||
"gal/h",
|
||||
|
||||
@@ -2,8 +2,6 @@ import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { transform } from "../../../common/decorators/transform";
|
||||
import type { HASSDomCurrentTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { connectionContext, formattersContext } from "../../../data/context";
|
||||
import type { ImageEntity } from "../../../data/image";
|
||||
import { computeImageUrl } from "../../../data/image";
|
||||
@@ -30,17 +28,6 @@ class MoreInfoImage extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj?: ImageEntity;
|
||||
|
||||
private _size?: HASSDomEvents["media-size-changed"];
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
// A cached view that was detached while the picture loaded couldn't send
|
||||
// its size, and the picture doesn't load again when it's shown
|
||||
if (this._size) {
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this._connection || !this.stateObj) {
|
||||
return nothing;
|
||||
@@ -52,28 +39,16 @@ class MoreInfoImage extends LitElement {
|
||||
return html`<img
|
||||
alt=${this._formatEntityName?.(this.stateObj) || this.stateObj.entity_id}
|
||||
src=${this._connection.hassUrl(imageUrl)}
|
||||
@load=${this._imageLoaded}
|
||||
/> `;
|
||||
}
|
||||
|
||||
private _imageLoaded(ev: HASSDomCurrentTargetEvent<HTMLImageElement>) {
|
||||
const { naturalWidth, naturalHeight } = ev.currentTarget;
|
||||
if (!naturalWidth || !naturalHeight) {
|
||||
return;
|
||||
}
|
||||
this._size = { aspectRatio: naturalWidth / naturalHeight, naturalWidth };
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
max-height: var(--more-info-media-max-height, none);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -149,12 +149,10 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public large = false;
|
||||
|
||||
// The dialog grows with the camera's or image's picture, as high as there
|
||||
// is room for
|
||||
@state() private _mediaAspectRatio?: number;
|
||||
@state() private _fill = false;
|
||||
|
||||
// An image is not shown larger than it is
|
||||
@state() private _mediaNaturalWidth?: number;
|
||||
// The dialog grows with the camera's picture, as high as there is room for
|
||||
@state() private _cameraAspectRatio?: number;
|
||||
|
||||
// Height of the controls the camera's info shows below the picture
|
||||
@state() private _cameraControlsHeight?: string;
|
||||
@@ -198,6 +196,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
|
||||
public showDialog(params: MoreInfoDialogParams) {
|
||||
// The camera player keeps running for the same entity and doesn't send
|
||||
// its size again
|
||||
if (params.entityId !== this._entityId) {
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
this._entityId = params.entityId;
|
||||
if (!this._entityId) {
|
||||
this.closeDialog();
|
||||
@@ -215,6 +219,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._detailsYamlMode = false;
|
||||
|
||||
this.large = params.large ?? false;
|
||||
this._fill = false;
|
||||
this._open = true;
|
||||
this._loadEntityRegistryEntry();
|
||||
}
|
||||
@@ -260,6 +265,8 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._currView = DEFAULT_VIEW;
|
||||
this._childViewStack = [];
|
||||
this._returnUrl = undefined;
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
this._isEscapeEnabled = true;
|
||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.removeEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -684,32 +691,30 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`
|
||||
: nothing;
|
||||
|
||||
// Also when it was opened from a smaller entity's related view
|
||||
const mediaAspectRatio =
|
||||
(domain === "camera" || domain === "image") && isDefaultView
|
||||
? this._mediaAspectRatio
|
||||
// Also when the camera was opened from a smaller entity's related view
|
||||
const cameraAspectRatio =
|
||||
domain === "camera" && isDefaultView
|
||||
? this._cameraAspectRatio
|
||||
: undefined;
|
||||
// As wide as the picture is when it's as high as there is room for
|
||||
const fullHeightWidth = `var(--more-info-media-max-height) * ${mediaAspectRatio}`;
|
||||
const mediaPictureWidth = this._mediaNaturalWidth
|
||||
? `min(${fullHeightWidth}, ${this._mediaNaturalWidth}px)`
|
||||
: fullHeightWidth;
|
||||
|
||||
return html`
|
||||
<ha-adaptive-dialog
|
||||
.open=${this._open}
|
||||
.width=${this.large || mediaAspectRatio ? "large" : "medium"}
|
||||
class=${classMap({
|
||||
camera: domain === "camera",
|
||||
image: domain === "image",
|
||||
})}
|
||||
.width=${
|
||||
this._fill
|
||||
? "full"
|
||||
: this.large || cameraAspectRatio
|
||||
? "large"
|
||||
: "medium"
|
||||
}
|
||||
class=${classMap({ camera: domain === "camera" })}
|
||||
style=${styleMap({
|
||||
"--more-info-camera-controls-height": this._cameraControlsHeight,
|
||||
"--ha-dialog-width-lg": mediaAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(${mediaPictureWidth} + var(--more-info-media-inline-padding, 0px)), 1920px)`
|
||||
"--ha-dialog-width-lg": cameraAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(var(--video-max-height) * ${cameraAspectRatio}), 1920px)`
|
||||
: undefined,
|
||||
})}
|
||||
@media-size-changed=${this._mediaSizeChanged}
|
||||
@camera-aspect-ratio-changed=${this._cameraAspectRatioChanged}
|
||||
@camera-controls-height-changed=${this._cameraControlsHeightChanged}
|
||||
.accessibleLabel=${title}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -742,7 +747,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
></ha-icon-button-prev>
|
||||
`
|
||||
}
|
||||
<span slot="headerTitle" class="title">
|
||||
<span slot="headerTitle" @click=${this._enlarge} class="title">
|
||||
${
|
||||
breadcrumb.length > 0
|
||||
? !__DEMO__ && isAdmin
|
||||
@@ -1066,17 +1071,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`;
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
// Also when going to a related entity or back. The camera player or image
|
||||
// of the same entity keeps running and doesn't send its size again.
|
||||
if (changedProps.has("_entityId")) {
|
||||
this._mediaAspectRatio = undefined;
|
||||
this._mediaNaturalWidth = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
this.addEventListener("close-dialog", () => this.closeDialog());
|
||||
@@ -1146,11 +1140,10 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._entry = ev.detail;
|
||||
}
|
||||
|
||||
private _mediaSizeChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["media-size-changed"]>
|
||||
private _cameraAspectRatioChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["camera-aspect-ratio-changed"]>
|
||||
) {
|
||||
this._mediaAspectRatio = ev.detail.aspectRatio;
|
||||
this._mediaNaturalWidth = ev.detail.naturalWidth;
|
||||
this._cameraAspectRatio = ev.detail.aspectRatio;
|
||||
}
|
||||
|
||||
private _cameraControlsHeightChanged(
|
||||
@@ -1159,6 +1152,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._cameraControlsHeight = ev.detail.height;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this._fill = !this._fill;
|
||||
});
|
||||
}
|
||||
|
||||
private _handleOpened() {
|
||||
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.addEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -1217,14 +1216,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
--dialog-content-padding: 0;
|
||||
}
|
||||
|
||||
/* The dialog's margin, the safe area like the dialog's height limit,
|
||||
its header of about 68px and what the info shows besides the
|
||||
picture */
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100vh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
/* The dialog's margin, its header of about 68px and the controls
|
||||
below the picture */
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100vh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
);
|
||||
/* Along with the height of the picture */
|
||||
--ha-dialog-width-transition:
|
||||
@@ -1235,33 +1232,14 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
/* A custom property takes any value, so it can't fall back to the
|
||||
declaration before it. svh like the height limit of the dialog. */
|
||||
@supports (height: 1svh) {
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100svh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100svh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ha-adaptive-dialog.camera {
|
||||
--more-info-media-reserved-height: var(
|
||||
--more-info-camera-controls-height,
|
||||
0px
|
||||
);
|
||||
--video-max-height: var(--more-info-media-max-height);
|
||||
}
|
||||
|
||||
/* The info's padding around the picture and the entity's row of 40px
|
||||
above it, with 16px between them */
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-reserved-height: calc(
|
||||
var(--ha-space-6) +
|
||||
max(var(--safe-area-inset-bottom, 0px), var(--ha-space-6)) + 56px
|
||||
);
|
||||
--more-info-media-inline-padding: calc(var(--ha-space-6) * 2);
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
|
||||
@@ -13,6 +13,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type { HASSDomCurrentTargetEvent } from "../../common/dom/fire_event";
|
||||
import "../../components/animation/ha-fade-in";
|
||||
import "../../components/ha-adaptive-dialog";
|
||||
import "../../components/ha-alert";
|
||||
import "../../components/ha-expansion-panel";
|
||||
import "../../components/ha-icon-next";
|
||||
import "../../components/ha-spinner";
|
||||
@@ -20,6 +21,10 @@ import "../../components/item/ha-list-item-button";
|
||||
import type { HaListItemButton } from "../../components/item/ha-list-item-button";
|
||||
import "../../components/list/ha-list-base";
|
||||
import "../../components/progress/ha-progress-bar";
|
||||
import {
|
||||
getBackupState,
|
||||
type BackupManagerState,
|
||||
} from "../../data/backup_manager";
|
||||
import {
|
||||
extractApiErrorMessage,
|
||||
ignoreSupervisorError,
|
||||
@@ -31,14 +36,14 @@ import {
|
||||
shutdownHost,
|
||||
} from "../../data/hassio/host";
|
||||
import { haStyle, haStyleDialog } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { HomeAssistant, ServiceCallRequest } from "../../types";
|
||||
import { HOST_ACTION_TOAST_ID, showToast } from "../../util/toast";
|
||||
import { showAlertDialog } from "../generic/show-dialog-box";
|
||||
import {
|
||||
confirmRestartAction,
|
||||
showRestartConfirmation,
|
||||
type RestartAction,
|
||||
} from "./show-restart-confirmation";
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
} from "../generic/show-dialog-box";
|
||||
import { showRestartWaitDialog } from "./show-dialog-restart";
|
||||
import "./automation-restart-status";
|
||||
|
||||
@customElement("dialog-restart")
|
||||
class DialogRestart extends LitElement {
|
||||
@@ -69,6 +74,15 @@ class DialogRestart extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _loadBackupState() {
|
||||
try {
|
||||
return await getBackupState(this.hass);
|
||||
} catch (_err) {
|
||||
// Do nothing
|
||||
return "idle";
|
||||
}
|
||||
}
|
||||
|
||||
private async _loadHostInfo() {
|
||||
this._loadingHostInfo = true;
|
||||
try {
|
||||
@@ -259,16 +273,45 @@ class DialogRestart extends LitElement {
|
||||
duration: 1000,
|
||||
});
|
||||
|
||||
try {
|
||||
await this.hass.callService("homeassistant", "reload_all");
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, {
|
||||
title: this.hass.localize("ui.dialogs.restart.reload.failed"),
|
||||
text: err.message,
|
||||
});
|
||||
this._restartAction(
|
||||
"homeassistant",
|
||||
"reload_all",
|
||||
this.hass.localize("ui.dialogs.restart.reload.failed")
|
||||
)();
|
||||
}
|
||||
|
||||
private _getBackupProgressMessage(backupState: BackupManagerState) {
|
||||
switch (backupState) {
|
||||
case "create_backup":
|
||||
return this.hass.localize("ui.dialogs.restart.backup_in_progress");
|
||||
case "receive_backup":
|
||||
return this.hass.localize("ui.dialogs.restart.upload_in_progress");
|
||||
case "restore_backup":
|
||||
return this.hass.localize("ui.dialogs.restart.restore_in_progress");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private _restartAction =
|
||||
(
|
||||
domain: ServiceCallRequest["domain"],
|
||||
service: ServiceCallRequest["service"],
|
||||
errorTitle: string,
|
||||
|
||||
serviceData?: ServiceCallRequest["serviceData"]
|
||||
) =>
|
||||
async () => {
|
||||
try {
|
||||
await this.hass.callService(domain, service, serviceData);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, {
|
||||
title: errorTitle,
|
||||
text: err.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _hostAction =
|
||||
(toastMessage: string, action: "reboot" | "shutdown") => async () => {
|
||||
showToast(this, {
|
||||
@@ -300,32 +343,75 @@ class DialogRestart extends LitElement {
|
||||
};
|
||||
|
||||
private async _handleAction(
|
||||
ev: HASSDomCurrentTargetEvent<HaListItemButton & { action: RestartAction }>
|
||||
ev: HASSDomCurrentTargetEvent<
|
||||
HaListItemButton & {
|
||||
action: "restart" | "reboot" | "shutdown" | "restart-safe-mode";
|
||||
}
|
||||
>
|
||||
) {
|
||||
if (this._loadingBackupInfo) {
|
||||
return;
|
||||
}
|
||||
this._loadingBackupInfo = true;
|
||||
const action = ev.currentTarget.action;
|
||||
try {
|
||||
const confirmed =
|
||||
action === "restart" || action === "restart-safe-mode"
|
||||
? await showRestartConfirmation(this, this.hass, action)
|
||||
: await confirmRestartAction(
|
||||
this,
|
||||
this.hass,
|
||||
action,
|
||||
this._hostAction(
|
||||
this.hass.localize(`ui.dialogs.restart.${action}.action_toast`),
|
||||
action
|
||||
)
|
||||
);
|
||||
if (confirmed) {
|
||||
this._dialogOpen = false;
|
||||
}
|
||||
} finally {
|
||||
this._loadingBackupInfo = false;
|
||||
|
||||
const backupState = await this._loadBackupState();
|
||||
|
||||
const backupProgressMessage = this._getBackupProgressMessage(backupState);
|
||||
|
||||
this._loadingBackupInfo = false;
|
||||
|
||||
const confirmed = await showConfirmationDialog(this, {
|
||||
title: this.hass.localize(`ui.dialogs.restart.${action}.confirm_title`),
|
||||
text: html`${this.hass.localize(
|
||||
`ui.dialogs.restart.${action}.confirm_description`
|
||||
)}${
|
||||
backupProgressMessage
|
||||
? html`<br /><br /><ha-alert>${backupProgressMessage}</ha-alert>`
|
||||
: nothing
|
||||
} <br /><br /><automation-restart-status></automation-restart-status>`,
|
||||
confirmText: this.hass.localize(
|
||||
`ui.dialogs.restart.${action}.confirm_action${backupState === "idle" ? "" : "_backup"}`
|
||||
),
|
||||
destructive: true,
|
||||
});
|
||||
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._dialogOpen = false;
|
||||
|
||||
let actionFunc: () => Promise<void>;
|
||||
|
||||
if (["restart", "restart-safe-mode"].includes(action)) {
|
||||
const serviceData =
|
||||
action === "restart-safe-mode" ? { safe_mode: true } : undefined;
|
||||
actionFunc = this._restartAction(
|
||||
"homeassistant",
|
||||
"restart",
|
||||
this.hass.localize(`ui.dialogs.restart.${action}.failed`),
|
||||
serviceData
|
||||
);
|
||||
} else {
|
||||
actionFunc = this._hostAction(
|
||||
this.hass.localize(
|
||||
`ui.dialogs.restart.${action as "reboot" | "shutdown"}.action_toast`
|
||||
),
|
||||
action as "reboot" | "shutdown"
|
||||
);
|
||||
}
|
||||
|
||||
if (backupState !== "idle") {
|
||||
showRestartWaitDialog(this, {
|
||||
title: this.hass.localize(`ui.dialogs.restart.${action}.title`),
|
||||
initialBackupState: backupState,
|
||||
action: actionFunc,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
actionFunc();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import { html, nothing } from "lit";
|
||||
import "../../components/ha-alert";
|
||||
import {
|
||||
getBackupState,
|
||||
type BackupManagerState,
|
||||
} from "../../data/backup_manager";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import {
|
||||
showAlertDialog,
|
||||
showConfirmationDialog,
|
||||
} from "../generic/show-dialog-box";
|
||||
import "./automation-restart-status";
|
||||
import { showRestartWaitDialog } from "./show-dialog-restart";
|
||||
|
||||
export type RestartAction =
|
||||
"restart" | "reboot" | "shutdown" | "restart-safe-mode";
|
||||
type ConfirmationContext = Pick<HomeAssistant, "connection" | "localize">;
|
||||
|
||||
function getBackupProgressMessage(
|
||||
localize: HomeAssistant["localize"],
|
||||
backupState: BackupManagerState
|
||||
) {
|
||||
switch (backupState) {
|
||||
case "create_backup":
|
||||
return localize("ui.dialogs.restart.backup_in_progress");
|
||||
case "receive_backup":
|
||||
return localize("ui.dialogs.restart.upload_in_progress");
|
||||
case "restore_backup":
|
||||
return localize("ui.dialogs.restart.restore_in_progress");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirmRestartAction(
|
||||
element: HTMLElement,
|
||||
hass: ConfirmationContext,
|
||||
action: RestartAction,
|
||||
run: () => Promise<void>
|
||||
) {
|
||||
const backupState = await getBackupState(hass).catch(() => "idle" as const);
|
||||
const backupProgressMessage = getBackupProgressMessage(
|
||||
hass.localize,
|
||||
backupState
|
||||
);
|
||||
const confirmed = await showConfirmationDialog(element, {
|
||||
title: hass.localize(`ui.dialogs.restart.${action}.confirm_title`),
|
||||
text: html`${hass.localize(
|
||||
`ui.dialogs.restart.${action}.confirm_description`
|
||||
)}${
|
||||
backupProgressMessage
|
||||
? html`<br /><br /><ha-alert>${backupProgressMessage}</ha-alert>`
|
||||
: nothing
|
||||
} <br /><br /><automation-restart-status></automation-restart-status>`,
|
||||
confirmText: hass.localize(
|
||||
`ui.dialogs.restart.${action}.confirm_action${backupState === "idle" ? "" : "_backup"}`
|
||||
),
|
||||
destructive: true,
|
||||
});
|
||||
|
||||
if (!confirmed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (backupState !== "idle") {
|
||||
showRestartWaitDialog(element, {
|
||||
title: hass.localize(`ui.dialogs.restart.${action}.title`),
|
||||
initialBackupState: backupState,
|
||||
action: run,
|
||||
});
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function showRestartConfirmation(
|
||||
element: HTMLElement,
|
||||
hass: ConfirmationContext & Pick<HomeAssistant, "callService">,
|
||||
action: "restart" | "restart-safe-mode" = "restart"
|
||||
) {
|
||||
return confirmRestartAction(element, hass, action, async () => {
|
||||
try {
|
||||
await hass.callService(
|
||||
"homeassistant",
|
||||
"restart",
|
||||
action === "restart-safe-mode" ? { safe_mode: true } : undefined
|
||||
);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(element, {
|
||||
title: hass.localize(`ui.dialogs.restart.${action}.failed`),
|
||||
text: err.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,9 +145,7 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
|
||||
return html`
|
||||
<ha-dialog
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.satellite_wizard.title"
|
||||
)}
|
||||
header-title="Voice Satellite setup"
|
||||
prevent-scrim-close
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
|
||||
@@ -2,10 +2,4 @@ import "@webcomponents/scoped-custom-element-registry/scoped-custom-element-regi
|
||||
import "../resources/scoped-registry-ready";
|
||||
import "../layouts/home-assistant";
|
||||
|
||||
// Custom cards and plugins can reach the helpers on any page, not only once a
|
||||
// dashboard has loaded.
|
||||
Object.assign(window, {
|
||||
loadCardHelpers: () => import("../panels/lovelace/custom-card-helpers"),
|
||||
});
|
||||
|
||||
import("../resources/append-ha-style");
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { loadTokens, saveTokens } from "../common/auth/token_storage";
|
||||
import { hassUrl } from "../data/auth";
|
||||
import { isExternal } from "../data/external";
|
||||
import { subscribeFrontendUserData } from "../data/frontend";
|
||||
import { fetchConfig } from "../data/lovelace/config/types";
|
||||
import { fetchResources } from "../data/lovelace/resource";
|
||||
import { MAIN_WINDOW_NAME } from "../data/main_window";
|
||||
@@ -187,6 +188,7 @@ window.hassConnection.then(({ conn }) => {
|
||||
subscribePanels(conn, noop);
|
||||
subscribeThemes(conn, noop);
|
||||
subscribeUser(conn, noop);
|
||||
subscribeFrontendUserData(conn, "core", noop);
|
||||
subscribeRepairsIssueRegistry(conn, noop);
|
||||
|
||||
const preloadWindow = window as WindowWithPreloads;
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import { supportsFeatureFromAttributes } from "../../common/entity/supports-feature";
|
||||
import { ClimateEntityFeature } from "../../data/climate";
|
||||
import {
|
||||
CLIMATE_HVAC_ACTION_TO_MODE,
|
||||
ClimateEntityFeature,
|
||||
} from "../../data/climate";
|
||||
import type { HvacAction } from "../../data/climate";
|
||||
import { MockBaseEntity } from "./base-entity";
|
||||
import type { EntityAttributes } from "./types";
|
||||
|
||||
// Reverse mapping: mode → action (e.g. "cool" → "cooling")
|
||||
const HVAC_MODE_TO_ACTION: Partial<Record<string, HvacAction>> =
|
||||
Object.fromEntries(
|
||||
Object.entries(CLIMATE_HVAC_ACTION_TO_MODE).map(([action, mode]) => [
|
||||
mode,
|
||||
action as HvacAction,
|
||||
])
|
||||
);
|
||||
|
||||
export class MockClimateEntity extends MockBaseEntity {
|
||||
public async handleService(
|
||||
domain: string,
|
||||
@@ -231,13 +243,10 @@ export class MockClimateEntity extends MockBaseEntity {
|
||||
return "off";
|
||||
}
|
||||
|
||||
// Heat and cool get their action from the temperatures below
|
||||
if (state === "dry") {
|
||||
return "drying";
|
||||
}
|
||||
|
||||
if (state === "fan_only") {
|
||||
return "fan";
|
||||
// Use the reverse mapping for direct mode → action (e.g. "fan_only" → "fan", "dry" → "drying")
|
||||
const directAction = HVAC_MODE_TO_ACTION[state];
|
||||
if (directAction && directAction !== "idle" && directAction !== "off") {
|
||||
return directAction;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -267,17 +276,13 @@ export class MockClimateEntity extends MockBaseEntity {
|
||||
const current = attrs.current_temperature;
|
||||
const lowTarget = attrs.target_temp_low;
|
||||
const highTarget = attrs.target_temp_high;
|
||||
// Heat mode can only heat and cool mode only cool, while auto and
|
||||
// heat_cool use both ends of the range
|
||||
if (current != null) {
|
||||
if (state !== "cool" && lowTarget != null && lowTarget > current) {
|
||||
if (lowTarget != null && lowTarget > current) {
|
||||
return "heating";
|
||||
}
|
||||
|
||||
if (state !== "heat" && highTarget != null && highTarget < current) {
|
||||
if (highTarget != null && highTarget < current) {
|
||||
return "cooling";
|
||||
}
|
||||
|
||||
return "idle";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,22 +607,6 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
||||
atmospheric_pressure: {
|
||||
default: "mdi:thermometer-lines",
|
||||
},
|
||||
battery: {
|
||||
default: "mdi:battery-unknown",
|
||||
range: {
|
||||
"0": "mdi:battery-alert",
|
||||
"10": "mdi:battery-10",
|
||||
"20": "mdi:battery-20",
|
||||
"30": "mdi:battery-30",
|
||||
"40": "mdi:battery-40",
|
||||
"50": "mdi:battery-50",
|
||||
"60": "mdi:battery-60",
|
||||
"70": "mdi:battery-70",
|
||||
"80": "mdi:battery-80",
|
||||
"90": "mdi:battery-90",
|
||||
"100": "mdi:battery",
|
||||
},
|
||||
},
|
||||
carbon_dioxide: {
|
||||
default: "mdi:molecule-co2",
|
||||
},
|
||||
|
||||
@@ -27,12 +27,6 @@ import {
|
||||
import { updateHassGroups } from "../data/context/updateContext";
|
||||
import type { IconCategory } from "../data/icons";
|
||||
import type { EntityRegistryDisplayEntry } from "../data/entity/entity_registry";
|
||||
import { evaluateConditionsLocally } from "../common/condition/evaluate-locally";
|
||||
import {
|
||||
isLogicalCondition,
|
||||
logicalChildren,
|
||||
} from "../common/condition/translate";
|
||||
import type { VisibilityCondition } from "../panels/lovelace/common/validate-condition";
|
||||
import {
|
||||
DateFormat,
|
||||
FirstWeekday,
|
||||
@@ -59,24 +53,6 @@ import type { EntityInput } from "./entities/types";
|
||||
const ensureArray = <T>(val: T | T[]): T[] =>
|
||||
Array.isArray(val) ? val : [val];
|
||||
|
||||
// Core's `not` passes when none of its conditions pass, and the frontend's
|
||||
// unless all of them pass, so each `not` gets one `or` of its conditions
|
||||
const withCoreNot = (condition: VisibilityCondition): VisibilityCondition => {
|
||||
if (!isLogicalCondition(condition) || condition.conditions === undefined) {
|
||||
return condition;
|
||||
}
|
||||
|
||||
const conditions = logicalChildren(condition).map(withCoreNot);
|
||||
|
||||
return {
|
||||
...condition,
|
||||
conditions:
|
||||
condition.condition === "not"
|
||||
? [{ condition: "or", conditions }]
|
||||
: conditions,
|
||||
};
|
||||
};
|
||||
|
||||
type MockServiceCallback = (
|
||||
data: Record<string, any> | undefined,
|
||||
target: Record<string, any> | undefined,
|
||||
@@ -245,8 +221,6 @@ export const provideHass = (
|
||||
return lazyLoaderPromise;
|
||||
};
|
||||
const eventListeners: Record<string, ((event) => void)[]> = {};
|
||||
// Checks each subscribed condition again, for when the states change.
|
||||
const conditionChecks = new Set<() => void>();
|
||||
const entities = {};
|
||||
let localResources: Resources = {};
|
||||
|
||||
@@ -690,51 +664,6 @@ export const provideHass = (
|
||||
resources: category === "entity_component" ? ENTITY_COMPONENT_ICONS : {},
|
||||
}));
|
||||
|
||||
// Core answers the visibility conditions of cards and rows that depend on
|
||||
// states. Here they are checked against the mock states, as the frontend
|
||||
// does itself before Core answers, and again each time the states change.
|
||||
// A condition only Core can check, such as a template, gets an error, so
|
||||
// a `not` around it can't show the card.
|
||||
hassObj.mockWS(
|
||||
"subscribe_condition",
|
||||
({ condition }: { condition: VisibilityCondition }, _hass, onChange) => {
|
||||
const check = () => {
|
||||
const result = evaluateConditionsLocally(
|
||||
[withCoreNot(condition)],
|
||||
hass(),
|
||||
{}
|
||||
);
|
||||
|
||||
onChange?.(
|
||||
result === undefined
|
||||
? {
|
||||
error: {
|
||||
code: "not_supported",
|
||||
message: "The demo can't check this condition",
|
||||
},
|
||||
}
|
||||
: { result }
|
||||
);
|
||||
};
|
||||
|
||||
conditionChecks.add(check);
|
||||
check();
|
||||
|
||||
return () => conditionChecks.delete(check);
|
||||
}
|
||||
);
|
||||
|
||||
// Check the conditions again after each state update, also when the host
|
||||
// passed its own updateHass, as the demo does
|
||||
const applyUpdate = hassObj.updateHass;
|
||||
hassObj.updateHass = (obj: Partial<MockHomeAssistant>) => {
|
||||
applyUpdate(obj);
|
||||
|
||||
if (obj.states) {
|
||||
conditionChecks.forEach((check) => check());
|
||||
}
|
||||
};
|
||||
|
||||
// Set hass if required
|
||||
if (setHassProperty) {
|
||||
elements.forEach((el) => {
|
||||
|
||||
@@ -26,7 +26,6 @@ import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import { formatListWithAnds } from "../../../common/string/format-list";
|
||||
import { copyToClipboard } from "../../../common/util/copy-clipboard";
|
||||
import "../../../components/ha-dropdown";
|
||||
import type { HaDropdownSelectEvent } from "../../../components/ha-dropdown";
|
||||
@@ -96,9 +95,6 @@ export class HaConfigEntryRow extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public data!: ConfigEntryData;
|
||||
|
||||
/** The loaded integrations that lose this integration with this entry. */
|
||||
@property({ attribute: false }) public dependents?: IntegrationManifest[];
|
||||
|
||||
@state() private _expanded = true;
|
||||
|
||||
@state() private _devicesExpanded = true;
|
||||
@@ -816,33 +812,14 @@ export class HaConfigEntryRow extends LitElement {
|
||||
const applicationCredentialsId =
|
||||
await this._applicationCredentialForRemove(entryId);
|
||||
|
||||
const text = this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.delete_confirm_text"
|
||||
);
|
||||
const confirmed = await showConfirmationDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.delete_confirm_title",
|
||||
{ title: this.data.entry.title }
|
||||
),
|
||||
text: this.dependents?.length
|
||||
? html`${text}<br /><br />${this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.delete_confirm_dependents",
|
||||
{
|
||||
count: this.dependents.length,
|
||||
integrations: formatListWithAnds(
|
||||
this.hass.locale,
|
||||
this.dependents.map((manifest) =>
|
||||
domainToName(this.hass.localize, manifest.domain, manifest)
|
||||
)
|
||||
),
|
||||
name: domainToName(
|
||||
this.hass.localize,
|
||||
this.data.entry.domain,
|
||||
this.manifest
|
||||
),
|
||||
}
|
||||
)}`
|
||||
: text,
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.delete_confirm_text"
|
||||
),
|
||||
confirmText: this.hass!.localize("ui.common.delete"),
|
||||
dismissText: this.hass!.localize("ui.common.cancel"),
|
||||
destructive: true,
|
||||
|
||||
@@ -21,7 +21,7 @@ import memoizeOne from "memoize-one";
|
||||
import { ensureArray } from "../../../common/array/ensure-array";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
import { QueryParamsController } from "../../../common/controllers/query-params-controller";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { ContextSubscriptionController } from "../../../common/decorators/consume";
|
||||
import type { HASSDomTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { computeDeviceNameDisplay } from "../../../common/entity/compute_device_name";
|
||||
import {
|
||||
@@ -176,9 +176,9 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
@state() private _manifest?: IntegrationManifest;
|
||||
|
||||
/** The manifests of all loaded integrations, to find the dependents. */
|
||||
@consume({ context: manifestsContext, subscribe: true })
|
||||
@state()
|
||||
private _loadedManifests?: DomainManifestLookup;
|
||||
@state() private _loadedManifests?: DomainManifestLookup;
|
||||
|
||||
private _manifestsConsumer?: ContextSubscriptionController<DomainManifestLookup>;
|
||||
|
||||
@state() private _extraConfigEntries?: ConfigEntry[];
|
||||
|
||||
@@ -432,23 +432,17 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
this.domain
|
||||
);
|
||||
|
||||
const dependents = this._getDependents(
|
||||
this.domain,
|
||||
this._loadedManifests,
|
||||
this.hass.localize,
|
||||
this.hass.locale.language
|
||||
);
|
||||
// Without the dependents, a dependency looks like a YAML integration.
|
||||
const dependencyOnly =
|
||||
normalEntries.length === 0 &&
|
||||
dependents.length > 0 &&
|
||||
!this._manifest?.config_flow;
|
||||
// Deleting the last entry in use leaves the dependents without it.
|
||||
const entriesInUse = configEntries.filter(
|
||||
(entry) => entry.source !== "ignore" && !entry.disabled_by
|
||||
);
|
||||
const lastEntryId =
|
||||
entriesInUse.length === 1 ? entriesInUse[0].entry_id : undefined;
|
||||
const dependents =
|
||||
this._manifest && !this._manifest.config_flow
|
||||
? this._getDependents(
|
||||
this.domain,
|
||||
this._loadedManifests,
|
||||
this.hass.localize,
|
||||
this.hass.locale.language
|
||||
)
|
||||
: [];
|
||||
const showDependents = normalEntries.length === 0 && dependents.length > 0;
|
||||
// Hold back the YAML texts and "Add entry" until the manifest and the
|
||||
// dependents are known. Entries do not wait, so a failed request cannot
|
||||
// hide them.
|
||||
@@ -467,7 +461,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
|
||||
const showAddEntry =
|
||||
this._manifest?.integration_type !== "hardware" &&
|
||||
!dependencyOnly &&
|
||||
!showDependents &&
|
||||
!dependentsLoading &&
|
||||
!setUpInPanel &&
|
||||
(!this._manifest?.single_config_entry ||
|
||||
@@ -659,7 +653,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
${
|
||||
normalEntries.length === 0 &&
|
||||
!dependencyOnly &&
|
||||
!showDependents &&
|
||||
!dependentsLoading &&
|
||||
!setUpInPanel &&
|
||||
this._manifest &&
|
||||
@@ -1016,11 +1010,6 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
.diagnosticHandler=${this._diagnosticHandler}
|
||||
.entities=${this._entities}
|
||||
.data=${data}
|
||||
.dependents=${
|
||||
data.entry.entry_id === lastEntryId
|
||||
? dependents
|
||||
: undefined
|
||||
}
|
||||
data-entry-id=${data.entry.entry_id}
|
||||
></ha-config-entry-row>`
|
||||
)}
|
||||
@@ -1029,7 +1018,19 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
dependencyOnly ||
|
||||
showDependents
|
||||
? html`<div class="section">
|
||||
<h3 class="section-header">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.integration_page.used_by"
|
||||
)}
|
||||
</h3>
|
||||
${this._renderDependents(dependents)}
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
showDependents ||
|
||||
dependentsLoading ||
|
||||
(setUpInPanel && normalEntries.length === 0)
|
||||
? nothing
|
||||
@@ -1076,11 +1077,6 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
.diagnosticHandler=${this._diagnosticHandler}
|
||||
.entities=${this._entities}
|
||||
.data=${data}
|
||||
.dependents=${
|
||||
data.entry.entry_id === lastEntryId
|
||||
? dependents
|
||||
: undefined
|
||||
}
|
||||
data-entry-id=${data.entry.entry_id}
|
||||
></ha-config-entry-row>`
|
||||
)}
|
||||
@@ -1088,23 +1084,26 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
</div>`
|
||||
}
|
||||
${
|
||||
dependents.length
|
||||
? html`<div class="section">
|
||||
<h3 class="section-header">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.integration_page.used_by"
|
||||
)}
|
||||
</h3>
|
||||
${this._renderDependents(dependents)}
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
</hass-subpage>
|
||||
`;
|
||||
}
|
||||
|
||||
// Only an integration without a config flow needs the loaded manifests, so
|
||||
// other integration pages do not make the context fetch them.
|
||||
private _watchLoadedManifests(): void {
|
||||
if (this._manifestsConsumer) {
|
||||
return;
|
||||
}
|
||||
this._manifestsConsumer = new ContextSubscriptionController(
|
||||
this,
|
||||
manifestsContext,
|
||||
(manifests) => {
|
||||
this._loadedManifests = manifests;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private _getDependents = memoizeOne(
|
||||
(
|
||||
domain: string,
|
||||
@@ -1200,6 +1199,9 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
this._manifest = await fetchIntegrationManifest(this.hass, this.domain);
|
||||
if (!this._manifest.config_flow) {
|
||||
this._watchLoadedManifests();
|
||||
}
|
||||
if (
|
||||
this._manifest.integration_type &&
|
||||
!["device", "hub", "service"].includes(this._manifest.integration_type)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { mdiArrowDown, mdiArrowUp, mdiMenuDown } from "@mdi/js";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -9,10 +8,7 @@ import { formatDateTime } from "../../../common/datetime/format_date_time";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { consumeLocalize } from "../../../common/decorators/consume-context-entry";
|
||||
import { transform } from "../../../common/decorators/transform";
|
||||
import type {
|
||||
HASSDomCurrentTargetEvent,
|
||||
HASSDomEvent,
|
||||
} from "../../../common/dom/fire_event";
|
||||
import type { HASSDomCurrentTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||
import { formatNumber } from "../../../common/number/format_number";
|
||||
@@ -21,20 +17,13 @@ import "../../../components/data-table/ha-data-table";
|
||||
import type {
|
||||
DataTableColumnContainer,
|
||||
DataTableRowData,
|
||||
SortingChangedEvent,
|
||||
SortingDirection,
|
||||
} from "../../../components/data-table/ha-data-table";
|
||||
import "../../../components/chips/ha-assist-chip";
|
||||
import "../../../components/ha-alert";
|
||||
import "../../../components/ha-button";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-dropdown";
|
||||
import type { HaDropdownSelectEvent } from "../../../components/ha-dropdown";
|
||||
import "../../../components/ha-dropdown-item";
|
||||
import "../../../components/ha-segmented-bar";
|
||||
import type { Segment } from "../../../components/ha-segmented-bar";
|
||||
import "../../../components/ha-spinner";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import {
|
||||
configContext,
|
||||
fullEntitiesContext,
|
||||
@@ -178,10 +167,6 @@ export class StorageDatabaseCard extends LitElement {
|
||||
@consume({ context: fullEntitiesContext, subscribe: true })
|
||||
private _entityRegistry: EntityRegistryEntry[] = [];
|
||||
|
||||
@state() private _sortColumn?: string;
|
||||
|
||||
@state() private _sortDirection: SortingDirection = null;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const usage = this.usage;
|
||||
return html`
|
||||
@@ -219,7 +204,6 @@ export class StorageDatabaseCard extends LitElement {
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
${usage ? this._renderTable(usage) : nothing}
|
||||
<div class="card-actions">
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
@@ -286,25 +270,15 @@ export class StorageDatabaseCard extends LitElement {
|
||||
></ha-segmented-bar>`
|
||||
: nothing
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderTable(usage: RecorderDatabaseUsage) {
|
||||
const columns = this._columns(
|
||||
this._localize,
|
||||
this._locale,
|
||||
this.narrow,
|
||||
usage.tables !== null,
|
||||
this._sortColumn
|
||||
);
|
||||
return html`
|
||||
<div class="table">
|
||||
<ha-data-table
|
||||
.narrow=${this.narrow}
|
||||
.columns=${columns}
|
||||
.sortColumn=${this._sortColumn}
|
||||
.sortDirection=${this._sortDirection}
|
||||
@sorting-changed=${this._sortingChanged}
|
||||
.columns=${this._columns(
|
||||
this._localize,
|
||||
this._locale,
|
||||
this.narrow,
|
||||
usage.tables !== null
|
||||
)}
|
||||
.data=${this._rows(usage, this._entityRegistry, this._localize)}
|
||||
.searchLabel=${this._localize(
|
||||
"ui.panel.config.storage.database.search"
|
||||
@@ -312,9 +286,7 @@ export class StorageDatabaseCard extends LitElement {
|
||||
.noDataText=${this._localize(
|
||||
"ui.panel.config.storage.database.no_entities"
|
||||
)}
|
||||
>
|
||||
${this.narrow ? this._renderSortMenu(columns) : nothing}
|
||||
</ha-data-table>
|
||||
></ha-data-table>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@@ -399,157 +371,84 @@ export class StorageDatabaseCard extends LitElement {
|
||||
localize: LocalizeFunc,
|
||||
locale: FrontendLocaleData,
|
||||
narrow: boolean,
|
||||
hasSizes: boolean,
|
||||
sortColumn: string | undefined
|
||||
): DataTableColumnContainer<EntityUsageRow> => {
|
||||
// Narrow screens show one number beside the name: the sorted one.
|
||||
const narrowColumn =
|
||||
sortColumn && sortColumn !== "name"
|
||||
? sortColumn
|
||||
: hasSizes
|
||||
? "bytes"
|
||||
: "states";
|
||||
return {
|
||||
name: {
|
||||
title: localize("ui.panel.config.storage.database.columns.entity"),
|
||||
main: true,
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
flex: 3,
|
||||
template: (row) => {
|
||||
const content = html`${row.name}
|
||||
${
|
||||
row.id !== UNKNOWN_ROW_ID && row.name !== row.id
|
||||
? html`<div class="secondary">${row.id}</div>`
|
||||
: nothing
|
||||
}`;
|
||||
// Rendered inside the data table, which styles .row-button.
|
||||
return row.hasSettings
|
||||
? html`<button
|
||||
type="button"
|
||||
class="row-button"
|
||||
data-entity-id=${row.id}
|
||||
@click=${this._openSettings}
|
||||
>
|
||||
${content}
|
||||
</button>`
|
||||
: content;
|
||||
},
|
||||
},
|
||||
id: {
|
||||
title: localize("ui.panel.config.storage.database.columns.entity_id"),
|
||||
filterable: true,
|
||||
hidden: true,
|
||||
},
|
||||
states: {
|
||||
title: localize("ui.panel.config.storage.database.columns.states"),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
// Without sizes the rows are sorted by states instead.
|
||||
direction: hasSizes ? undefined : "desc",
|
||||
showNarrow: narrow && narrowColumn === "states",
|
||||
template: (row) => formatNumber(row.states, locale),
|
||||
},
|
||||
statistics: {
|
||||
title: localize(
|
||||
"ui.panel.config.storage.database.columns.statistics"
|
||||
),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
showNarrow: narrow && narrowColumn === "statistics",
|
||||
template: (row) => formatNumber(row.statistics, locale),
|
||||
},
|
||||
statistics_short_term: {
|
||||
title: localize(
|
||||
"ui.panel.config.storage.database.columns.statistics_short_term"
|
||||
),
|
||||
type: "numeric",
|
||||
minWidth: "130px",
|
||||
maxWidth: "130px",
|
||||
sortable: true,
|
||||
showNarrow: narrow && narrowColumn === "statistics_short_term",
|
||||
template: (row) => formatNumber(row.statistics_short_term, locale),
|
||||
},
|
||||
bytes: {
|
||||
title: localize("ui.panel.config.storage.database.columns.size"),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
direction: hasSizes ? "desc" : undefined,
|
||||
hidden: !hasSizes,
|
||||
showNarrow: narrow && narrowColumn === "bytes",
|
||||
template: (row) => bytesToString(row.bytes ?? 0),
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// Replaces the column headers on narrow screens, like the list pages do.
|
||||
private _renderSortMenu(columns: DataTableColumnContainer<EntityUsageRow>) {
|
||||
const sortColumn = this._sortColumn ? columns[this._sortColumn] : undefined;
|
||||
return html`
|
||||
<div slot="header-row" class="narrow-header-row">
|
||||
<ha-dropdown @wa-select=${this._handleSortBy}>
|
||||
<ha-assist-chip
|
||||
slot="trigger"
|
||||
.label=${this._localize(
|
||||
"ui.components.subpage-data-table.sort_by",
|
||||
{
|
||||
sortColumn: sortColumn ? ` ${sortColumn.title}` : "",
|
||||
}
|
||||
)}
|
||||
>
|
||||
<ha-svg-icon
|
||||
slot="trailing-icon"
|
||||
.path=${mdiMenuDown}
|
||||
></ha-svg-icon>
|
||||
</ha-assist-chip>
|
||||
${Object.entries(columns).map(([id, column]) =>
|
||||
column.sortable && !column.hidden
|
||||
? html`<ha-dropdown-item
|
||||
.value=${id}
|
||||
.selected=${id === this._sortColumn}
|
||||
>
|
||||
${
|
||||
id === this._sortColumn
|
||||
? html`<ha-svg-icon
|
||||
slot="details"
|
||||
.path=${
|
||||
this._sortDirection === "desc"
|
||||
? mdiArrowDown
|
||||
: mdiArrowUp
|
||||
}
|
||||
></ha-svg-icon>`
|
||||
: nothing
|
||||
}
|
||||
${column.title}
|
||||
</ha-dropdown-item>`
|
||||
hasSizes: boolean
|
||||
): DataTableColumnContainer<EntityUsageRow> => ({
|
||||
name: {
|
||||
title: localize("ui.panel.config.storage.database.columns.entity"),
|
||||
main: true,
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
flex: 3,
|
||||
template: (row) => {
|
||||
const content = html`${row.name}
|
||||
${
|
||||
row.id !== UNKNOWN_ROW_ID && row.name !== row.id
|
||||
? html`<div class="secondary">${row.id}</div>`
|
||||
: nothing
|
||||
)}
|
||||
</ha-dropdown>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private _sortingChanged(ev: HASSDomEvent<SortingChangedEvent>) {
|
||||
this._sortDirection = ev.detail.direction;
|
||||
this._sortColumn = ev.detail.direction ? ev.detail.column : undefined;
|
||||
}
|
||||
|
||||
private _handleSortBy(ev: HaDropdownSelectEvent) {
|
||||
ev.preventDefault(); // keep the dropdown open
|
||||
const column = ev.detail.item.value;
|
||||
this._sortDirection =
|
||||
column === this._sortColumn && this._sortDirection === "asc"
|
||||
? "desc"
|
||||
: "asc";
|
||||
this._sortColumn = column;
|
||||
}
|
||||
}`;
|
||||
// Rendered inside the data table, which styles .row-button.
|
||||
return row.hasSettings
|
||||
? html`<button
|
||||
type="button"
|
||||
class="row-button"
|
||||
data-entity-id=${row.id}
|
||||
@click=${this._openSettings}
|
||||
>
|
||||
${content}
|
||||
</button>`
|
||||
: content;
|
||||
},
|
||||
},
|
||||
id: {
|
||||
title: localize("ui.panel.config.storage.database.columns.entity_id"),
|
||||
filterable: true,
|
||||
hidden: true,
|
||||
},
|
||||
states: {
|
||||
title: localize("ui.panel.config.storage.database.columns.states"),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
// Without sizes the rows are sorted by states instead.
|
||||
direction: hasSizes ? undefined : "desc",
|
||||
hidden: narrow && hasSizes,
|
||||
showNarrow: !hasSizes,
|
||||
template: (row) => formatNumber(row.states, locale),
|
||||
},
|
||||
statistics: {
|
||||
title: localize("ui.panel.config.storage.database.columns.statistics"),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
hidden: narrow,
|
||||
template: (row) => formatNumber(row.statistics, locale),
|
||||
},
|
||||
statistics_short_term: {
|
||||
title: localize(
|
||||
"ui.panel.config.storage.database.columns.statistics_short_term"
|
||||
),
|
||||
type: "numeric",
|
||||
minWidth: "130px",
|
||||
maxWidth: "130px",
|
||||
sortable: true,
|
||||
hidden: narrow,
|
||||
template: (row) => formatNumber(row.statistics_short_term, locale),
|
||||
},
|
||||
bytes: {
|
||||
title: localize("ui.panel.config.storage.database.columns.size"),
|
||||
type: "numeric",
|
||||
minWidth: "100px",
|
||||
maxWidth: "100px",
|
||||
sortable: true,
|
||||
direction: hasSizes ? "desc" : undefined,
|
||||
hidden: !hasSizes,
|
||||
showNarrow: hasSizes,
|
||||
template: (row) => bytesToString(row.bytes ?? 0),
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
private _analyze() {
|
||||
fireEvent(this, "database-analyze");
|
||||
@@ -609,17 +508,6 @@ export class StorageDatabaseCard extends LitElement {
|
||||
--data-table-row-height: 44px;
|
||||
height: 100%;
|
||||
}
|
||||
.narrow-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
padding-inline: var(--ha-space-4);
|
||||
}
|
||||
ha-assist-chip {
|
||||
--ha-assist-chip-container-shape: 10px;
|
||||
--ha-assist-chip-container-color: var(--card-background-color);
|
||||
--ha-assist-chip-trailing-space: 8px;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,9 @@ import {
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import type { HassConfig, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { formatDateTimeWithSeconds } from "../../../../common/datetime/format_date_time";
|
||||
import "../../../../components/ha-control-select-menu";
|
||||
import type { SelectOption } from "../../../../components/ha-control-select-menu";
|
||||
import type { HaDropdownSelectEvent } from "../../../../components/ha-dropdown";
|
||||
import type { FrontendLocaleData } from "../../../../data/translation";
|
||||
import type {
|
||||
PipelineRunEvent,
|
||||
AssistRunListing,
|
||||
@@ -83,20 +79,20 @@ export class AssistPipelineDebug extends LitElement {
|
||||
@click=${this._pickOlderRun}
|
||||
.path=${mdiRayEndArrow}
|
||||
></ha-icon-button>
|
||||
<ha-control-select-menu
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.voice_assistants.debug.run"
|
||||
)}
|
||||
hide-label
|
||||
show-arrow
|
||||
.value=${this._runId}
|
||||
.options=${this._runOptions(
|
||||
<select .value=${this._runId} @change=${this._pickRun}>
|
||||
${repeat(
|
||||
this._runs,
|
||||
this.hass.locale,
|
||||
this.hass.config
|
||||
(run) => run.pipeline_run_id,
|
||||
(run) =>
|
||||
html`<option value=${run.pipeline_run_id}>
|
||||
${formatDateTimeWithSeconds(
|
||||
new Date(run.timestamp),
|
||||
this.hass.locale,
|
||||
this.hass.config
|
||||
)}
|
||||
</option>`
|
||||
)}
|
||||
@wa-select=${this._pickRun}
|
||||
></ha-control-select-menu>
|
||||
</select>
|
||||
<ha-icon-button
|
||||
.disabled=${this._runs[0].pipeline_run_id === this._runId}
|
||||
.label=${this.hass.localize(
|
||||
@@ -258,27 +254,8 @@ export class AssistPipelineDebug extends LitElement {
|
||||
this._runId = this._runs![curIndex - 1].pipeline_run_id;
|
||||
}
|
||||
|
||||
private _runOptions = memoizeOne(
|
||||
(
|
||||
runs: AssistRunListing[],
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig
|
||||
): SelectOption[] =>
|
||||
runs.map((run) => ({
|
||||
value: run.pipeline_run_id,
|
||||
label: formatDateTimeWithSeconds(
|
||||
new Date(run.timestamp),
|
||||
locale,
|
||||
config
|
||||
),
|
||||
}))
|
||||
);
|
||||
|
||||
private _pickRun(ev: HaDropdownSelectEvent) {
|
||||
const runId = ev.detail.item?.value;
|
||||
if (runId) {
|
||||
this._runId = runId;
|
||||
}
|
||||
private _pickRun(ev) {
|
||||
this._runId = ev.target.value;
|
||||
}
|
||||
|
||||
static styles = [
|
||||
@@ -293,13 +270,6 @@ export class AssistPipelineDebug extends LitElement {
|
||||
border-bottom: var(--app-header-border-bottom, none);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.toolbar ha-control-select-menu {
|
||||
min-width: min(
|
||||
240px,
|
||||
calc(100% - 2 * var(--ha-icon-button-size, 48px))
|
||||
);
|
||||
--control-select-menu-height: 40px;
|
||||
}
|
||||
.content {
|
||||
padding: 24px 0 32px;
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
|
||||
@@ -2,7 +2,6 @@ import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { live } from "lit/directives/live";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import {
|
||||
consumeEntityState,
|
||||
@@ -140,7 +139,7 @@ class HuiNumericInputCardFeature
|
||||
return html`
|
||||
<ha-control-number-buttons
|
||||
.label=${label}
|
||||
.value=${live(value)}
|
||||
.value=${value}
|
||||
.min=${stateObj.attributes.min}
|
||||
.max=${stateObj.attributes.max}
|
||||
.step=${stateObj.attributes.step}
|
||||
@@ -154,7 +153,7 @@ class HuiNumericInputCardFeature
|
||||
return html`
|
||||
<ha-control-slider
|
||||
.label=${label}
|
||||
.value=${live(value)}
|
||||
.value=${value}
|
||||
.min=${stateObj.attributes.min}
|
||||
.max=${stateObj.attributes.max}
|
||||
.step=${stateObj.attributes.step}
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import durationToSeconds from "../../../common/datetime/duration_to_seconds";
|
||||
import { consumeEntityState } from "../../../common/decorators/consume-context-entry";
|
||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { LovelaceCardFeature } from "../types";
|
||||
import { cardFeatureStyles } from "./common/card-feature-styles";
|
||||
import type {
|
||||
LovelaceCardFeatureContext,
|
||||
TimerProgressCardFeatureConfig,
|
||||
} from "./types";
|
||||
import { TimerRemainingTimeController } from "../../../common/controllers/timer-remaining-time-controller";
|
||||
import { reducedMotionContext } from "../../../data/context";
|
||||
|
||||
export const supportsTimerProgressCardFeature = (
|
||||
hass: HomeAssistant,
|
||||
context: LovelaceCardFeatureContext
|
||||
) => {
|
||||
const stateObj = context.entity_id
|
||||
? hass.states[context.entity_id]
|
||||
: undefined;
|
||||
return !!stateObj && computeDomain(stateObj.entity_id) === "timer";
|
||||
};
|
||||
|
||||
@customElement("hui-timer-progress-card-feature")
|
||||
class HuiTimerProgressCardFeature
|
||||
extends LitElement
|
||||
implements LovelaceCardFeature
|
||||
{
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["context", "entity_id"] })
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: reducedMotionContext, subscribe: true })
|
||||
private _reducedMotion = false;
|
||||
|
||||
@state() private _config?: TimerProgressCardFeatureConfig;
|
||||
private _timeRemaining = new TimerRemainingTimeController(this);
|
||||
private _prevRatio = 0;
|
||||
private _animate = false;
|
||||
|
||||
static getStubConfig(): TimerProgressCardFeatureConfig {
|
||||
return { type: "timer-progress" };
|
||||
}
|
||||
|
||||
public setConfig(config: TimerProgressCardFeatureConfig): void {
|
||||
if (!config) {
|
||||
throw new Error("Invalid configuration");
|
||||
}
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected update(changedProps: PropertyValues): void {
|
||||
if (changedProps.has("_stateObj")) {
|
||||
this._timeRemaining.setStateObj(this._stateObj);
|
||||
}
|
||||
if (this._stateObj) {
|
||||
const ratio = this._ratio(this._stateObj);
|
||||
this._animate =
|
||||
!this._reducedMotion &&
|
||||
this._stateObj.state === "active" &&
|
||||
ratio <= this._prevRatio;
|
||||
this._prevRatio = ratio;
|
||||
}
|
||||
super.update(changedProps);
|
||||
}
|
||||
|
||||
private _ratio(stateObj: HassEntity, offset = 0): number {
|
||||
const { duration } = stateObj.attributes;
|
||||
const total =
|
||||
typeof duration === "string" ? durationToSeconds(duration) : 0;
|
||||
if (!total || stateObj.state === "idle") {
|
||||
return 0;
|
||||
}
|
||||
const left = (this._timeRemaining.timeRemaining ?? 0) - offset;
|
||||
return Math.min(Math.max(left / total, 0), 1);
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (
|
||||
!this._config ||
|
||||
!this.context ||
|
||||
!this._stateObj ||
|
||||
computeDomain(this._stateObj.entity_id) !== "timer"
|
||||
) {
|
||||
return nothing;
|
||||
}
|
||||
const stateObj = this._stateObj;
|
||||
const ratio = this._ratio(stateObj);
|
||||
const target = this._animate ? this._ratio(stateObj, 1) : ratio;
|
||||
return html`
|
||||
<div
|
||||
class="track"
|
||||
role="progressbar"
|
||||
aria-label=${stateObj.attributes.friendly_name || stateObj.entity_id}
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow=${Math.round(ratio * 100)}
|
||||
>
|
||||
<div
|
||||
class="bar"
|
||||
style=${styleMap({
|
||||
transform: `scaleX(${target})`,
|
||||
transition: this._animate ? "transform 1s linear" : "none",
|
||||
})}
|
||||
></div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
static styles = [
|
||||
cardFeatureStyles,
|
||||
css`
|
||||
:host {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
.track {
|
||||
height: var(--feature-height);
|
||||
border-radius: var(--feature-border-radius);
|
||||
background: color-mix(in srgb, var(--feature-color) 20%, transparent);
|
||||
overflow: hidden;
|
||||
}
|
||||
.bar {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
transform-origin: var(--float-start, left);
|
||||
background: var(--feature-color);
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"hui-timer-progress-card-feature": HuiTimerProgressCardFeature;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,6 @@ import { supportsTargetHumidityCardFeature } from "./hui-target-humidity-card-fe
|
||||
import { supportsTargetTemperatureCardFeature } from "./hui-target-temperature-card-feature";
|
||||
import { supportsTimerActionsCardFeature } from "./hui-timer-actions-card-feature";
|
||||
import { supportsTimerPresetsCardFeature } from "./hui-timer-presets-card-feature";
|
||||
import { supportsTimerProgressCardFeature } from "./hui-timer-progress-card-feature";
|
||||
import { supportsToggleCardFeature } from "./hui-toggle-card-feature";
|
||||
import { supportsTrendGraphCardFeature } from "./hui-trend-graph-card-feature";
|
||||
import { supportsUpdateActionsCardFeature } from "./hui-update-actions-card-feature";
|
||||
@@ -111,7 +110,6 @@ export const UI_FEATURE_TYPES = [
|
||||
"target-temperature",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
@@ -171,7 +169,6 @@ export const SUPPORTS_FEATURE_TYPES: Record<UiFeatureType, SupportsFeature> = {
|
||||
"temperature-forecast": supportsTemperatureForecastCardFeature,
|
||||
"timer-actions": supportsTimerActionsCardFeature,
|
||||
"timer-presets": supportsTimerPresetsCardFeature,
|
||||
"timer-progress": supportsTimerProgressCardFeature,
|
||||
toggle: supportsToggleCardFeature,
|
||||
"update-actions": supportsUpdateActionsCardFeature,
|
||||
"vacuum-commands": supportsVacuumCommandsCardFeature,
|
||||
|
||||
@@ -237,10 +237,6 @@ export interface TimerPresetsCardFeatureConfig {
|
||||
style?: "buttons" | "dropdown";
|
||||
}
|
||||
|
||||
export interface TimerProgressCardFeatureConfig {
|
||||
type: "timer-progress";
|
||||
}
|
||||
|
||||
export interface WaterHeaterOperationModesCardFeatureConfig {
|
||||
type: "water-heater-operation-modes";
|
||||
style?: "dropdown" | "icons";
|
||||
@@ -410,7 +406,6 @@ export type LovelaceCardFeatureConfig =
|
||||
| TargetTemperatureCardFeatureConfig
|
||||
| TimerActionsCardFeatureConfig
|
||||
| TimerPresetsCardFeatureConfig
|
||||
| TimerProgressCardFeatureConfig
|
||||
| ToggleCardFeatureConfig
|
||||
| UpdateActionsCardFeatureConfig
|
||||
| VacuumCommandsCardFeatureConfig
|
||||
|
||||
@@ -84,7 +84,7 @@ const DOMAIN_VARIANTS: Record<string, TileVariant[]> = {
|
||||
],
|
||||
alarm_control_panel: [TILE_VARIANT, ["alarm-modes"]],
|
||||
counter: [TILE_VARIANT, ["counter-actions"]],
|
||||
timer: [TILE_VARIANT, ["timer-actions"], ["timer-progress"]],
|
||||
timer: [TILE_VARIANT, ["timer-actions"]],
|
||||
input_select: SELECT_VARIANTS,
|
||||
select: SELECT_VARIANTS,
|
||||
input_number: NUMERIC_INPUT_VARIANTS,
|
||||
|
||||
@@ -89,10 +89,10 @@ export class HuiDateCard extends LitElement implements LovelaceCard {
|
||||
case "large":
|
||||
return {
|
||||
min_rows: 2,
|
||||
rows: 3,
|
||||
rows: 2,
|
||||
max_rows: 4,
|
||||
min_columns: 6,
|
||||
columns: 12,
|
||||
columns: 6,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||
import { mdiDotsVertical } from "@mdi/js";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
@@ -25,13 +25,13 @@ import type { HumidifierCardConfig } from "./types";
|
||||
|
||||
@customElement("hui-humidifier-card")
|
||||
export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
||||
@query(".container") private _container?: HTMLElement;
|
||||
|
||||
// Observe .container, not the host: in a sections view the host keeps its
|
||||
// size when the entity appears and the warning is replaced by the control.
|
||||
private _resizeController = new ResizeController(this, {
|
||||
target: null,
|
||||
callback: () => this._container?.clientHeight,
|
||||
callback: (entries) => {
|
||||
const container = entries[0]?.target.shadowRoot?.querySelector(
|
||||
".container"
|
||||
) as HTMLElement | undefined;
|
||||
return container?.clientHeight;
|
||||
},
|
||||
});
|
||||
|
||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||
@@ -142,7 +142,7 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
||||
return html`
|
||||
<ha-card role="group" aria-labelledby="title">
|
||||
<p class="title" id="title">${name}</p>
|
||||
<div class="container" ${this._resizeController.target()}>
|
||||
<div class="container">
|
||||
<ha-state-control-humidifier-humidity
|
||||
style=${styleMap({
|
||||
maxWidth: controlMaxWidth,
|
||||
|
||||
@@ -387,7 +387,7 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
ha-icon-button {
|
||||
--ha-icon-button-size: 40px;
|
||||
--ha-color-on-disabled-quiet: currentColor;
|
||||
--disabled-text-color: currentColor;
|
||||
color: var(--ha-picture-icon-button-color, #a9a9a9);
|
||||
}
|
||||
ha-icon-button.state-on {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||
import { mdiDotsVertical } from "@mdi/js";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, query, state } from "lit/decorators";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
@@ -26,13 +26,13 @@ import type { ThermostatCardConfig } from "./types";
|
||||
|
||||
@customElement("hui-thermostat-card")
|
||||
export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
||||
@query(".container") private _container?: HTMLElement;
|
||||
|
||||
// Observe .container, not the host: in a sections view the host keeps its
|
||||
// size when the entity appears and the warning is replaced by the control.
|
||||
private _resizeController = new ResizeController(this, {
|
||||
target: null,
|
||||
callback: () => this._container?.clientHeight,
|
||||
callback: (entries) => {
|
||||
const container = entries[0]?.target.shadowRoot?.querySelector(
|
||||
".container"
|
||||
) as HTMLElement | undefined;
|
||||
return container?.clientHeight;
|
||||
},
|
||||
});
|
||||
|
||||
public static async getConfigElement(): Promise<LovelaceCardEditor> {
|
||||
@@ -141,7 +141,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
||||
return html`
|
||||
<ha-card role="group" aria-labelledby="title">
|
||||
<p class="title" id="title">${name}</p>
|
||||
<div class="container" ${this._resizeController.target()}>
|
||||
<div class="container">
|
||||
${
|
||||
domain === "water_heater"
|
||||
? html` <ha-state-control-water_heater-temperature
|
||||
|
||||
@@ -38,7 +38,6 @@ import "../card-features/hui-target-humidity-card-feature";
|
||||
import "../card-features/hui-target-temperature-card-feature";
|
||||
import "../card-features/hui-timer-actions-card-feature";
|
||||
import "../card-features/hui-timer-presets-card-feature";
|
||||
import "../card-features/hui-timer-progress-card-feature";
|
||||
import "../card-features/hui-toggle-card-feature";
|
||||
import "../card-features/hui-update-actions-card-feature";
|
||||
import "../card-features/hui-vacuum-commands-card-feature";
|
||||
@@ -105,7 +104,6 @@ const TYPES = new Set<LovelaceCardFeatureConfig["type"]>([
|
||||
"temperature-forecast",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
|
||||
@@ -9,8 +9,6 @@ export {
|
||||
showPromptDialog,
|
||||
} from "../../dialogs/generic/show-dialog-box";
|
||||
export { importMoreInfoControl } from "../../dialogs/more-info/state_more_info_control";
|
||||
|
||||
export { subscribeVisibility } from "../../common/condition/subscribe-visibility";
|
||||
export { createBadgeElement } from "./create-element/create-badge-element";
|
||||
export { createCardElement } from "./create-element/create-card-element";
|
||||
export { createHeaderFooterElement } from "./create-element/create-header-footer-element";
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
mdiClose,
|
||||
mdiFullscreen,
|
||||
mdiFullscreenExit,
|
||||
mdiHelpCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
|
||||
import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -73,8 +68,6 @@ export class HuiDialogEditBadge
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
@state() private _badgeConfig?: LovelaceBadgeConfig;
|
||||
|
||||
@state() private _saving = false;
|
||||
@@ -202,8 +195,6 @@ export class HuiDialogEditBadge
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -214,18 +205,12 @@ export class HuiDialogEditBadge
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
<span slot="headerTitle">${heading}</span>
|
||||
<ha-icon-button
|
||||
slot="headerActionItems"
|
||||
class="enlarge"
|
||||
.path=${this.large ? mdiFullscreenExit : mdiFullscreen}
|
||||
.label=${this.hass.localize(
|
||||
this.large
|
||||
? "ui.panel.lovelace.editor.edit_badge.shrink"
|
||||
: "ui.panel.lovelace.editor.edit_badge.enlarge"
|
||||
)}
|
||||
@click=${this._toggleLarge}
|
||||
></ha-icon-button>
|
||||
<span
|
||||
slot="headerTitle"
|
||||
class="title-enlargeable"
|
||||
@click=${this._enlarge}
|
||||
>${heading}</span
|
||||
>
|
||||
${
|
||||
this._documentationURL !== undefined
|
||||
? html`
|
||||
@@ -319,14 +304,10 @@ export class HuiDialogEditBadge
|
||||
`;
|
||||
}
|
||||
|
||||
private _toggleLarge() {
|
||||
this._animateWidth = true;
|
||||
this.large = !this.large;
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this.large = !this.large;
|
||||
});
|
||||
}
|
||||
|
||||
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||
@@ -513,18 +494,8 @@ export class HuiDialogEditBadge
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
ha-dialog[fullscreen] .enlarge {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 999px) {
|
||||
.enlarge {
|
||||
display: none;
|
||||
}
|
||||
.title-enlargeable {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
mdiClose,
|
||||
mdiFullscreen,
|
||||
mdiFullscreenExit,
|
||||
mdiHelpCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
|
||||
import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
@@ -81,8 +76,6 @@ export class HuiDialogEditCard
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
@state() private _cardConfig?: LovelaceCardConfig;
|
||||
|
||||
@state() private _sectionConfig?: LovelaceSectionConfig;
|
||||
@@ -214,8 +207,6 @@ export class HuiDialogEditCard
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -226,18 +217,12 @@ export class HuiDialogEditCard
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
<span slot="headerTitle">${heading}</span>
|
||||
<ha-icon-button
|
||||
slot="headerActionItems"
|
||||
class="enlarge"
|
||||
.path=${this.large ? mdiFullscreenExit : mdiFullscreen}
|
||||
.label=${this.hass.localize(
|
||||
this.large
|
||||
? "ui.panel.lovelace.editor.edit_card.shrink"
|
||||
: "ui.panel.lovelace.editor.edit_card.enlarge"
|
||||
)}
|
||||
@click=${this._toggleLarge}
|
||||
></ha-icon-button>
|
||||
<span
|
||||
slot="headerTitle"
|
||||
class="title-enlargeable"
|
||||
@click=${this._enlarge}
|
||||
>${heading}</span
|
||||
>
|
||||
${
|
||||
this._documentationURL !== undefined
|
||||
? html`
|
||||
@@ -345,14 +330,10 @@ export class HuiDialogEditCard
|
||||
`;
|
||||
}
|
||||
|
||||
private _toggleLarge() {
|
||||
this._animateWidth = true;
|
||||
this.large = !this.large;
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this.large = !this.large;
|
||||
});
|
||||
}
|
||||
|
||||
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||
@@ -595,18 +576,8 @@ export class HuiDialogEditCard
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
ha-dialog[fullscreen] .enlarge {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 999px) {
|
||||
.enlarge {
|
||||
display: none;
|
||||
}
|
||||
.title-enlargeable {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -67,7 +67,6 @@ import { supportsTargetHumidityCardFeature } from "../../card-features/hui-targe
|
||||
import { supportsTargetTemperatureCardFeature } from "../../card-features/hui-target-temperature-card-feature";
|
||||
import { supportsTimerActionsCardFeature } from "../../card-features/hui-timer-actions-card-feature";
|
||||
import { supportsTimerPresetsCardFeature } from "../../card-features/hui-timer-presets-card-feature";
|
||||
import { supportsTimerProgressCardFeature } from "../../card-features/hui-timer-progress-card-feature";
|
||||
import { supportsToggleCardFeature } from "../../card-features/hui-toggle-card-feature";
|
||||
import { supportsTrendGraphCardFeature } from "../../card-features/hui-trend-graph-card-feature";
|
||||
import { supportsUpdateActionsCardFeature } from "../../card-features/hui-update-actions-card-feature";
|
||||
@@ -137,7 +136,6 @@ const UI_FEATURE_TYPES = [
|
||||
"temperature-forecast",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
@@ -241,7 +239,6 @@ const SUPPORTS_FEATURE_TYPES: Record<
|
||||
"temperature-forecast": supportsTemperatureForecastCardFeature,
|
||||
"timer-actions": supportsTimerActionsCardFeature,
|
||||
"timer-presets": supportsTimerPresetsCardFeature,
|
||||
"timer-progress": supportsTimerProgressCardFeature,
|
||||
toggle: supportsToggleCardFeature,
|
||||
"update-actions": supportsUpdateActionsCardFeature,
|
||||
"vacuum-commands": supportsVacuumCommandsCardFeature,
|
||||
|
||||
@@ -96,6 +96,8 @@ export class HuiDialogEditSection
|
||||
|
||||
@property({ attribute: false }) public lovelace?: Lovelace;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public large = false;
|
||||
|
||||
@state() private _params?: EditSectionDialogParams;
|
||||
|
||||
@state() private _config?: LovelaceSectionRawConfig;
|
||||
@@ -112,8 +114,6 @@ export class HuiDialogEditSection
|
||||
|
||||
@state() private _yamlError = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
@storage({
|
||||
key: "dashboardSectionPreviewMode",
|
||||
state: true,
|
||||
@@ -177,7 +177,7 @@ export class HuiDialogEditSection
|
||||
|
||||
private _dialogClosed(): void {
|
||||
this._params = undefined;
|
||||
this._animateWidth = false;
|
||||
this.large = false;
|
||||
this._yamlMode = false;
|
||||
this._config = undefined;
|
||||
this._currTab = TABS[0];
|
||||
@@ -202,14 +202,8 @@ export class HuiDialogEditSection
|
||||
? "tab-appearance"
|
||||
: this._currTab;
|
||||
|
||||
// YAML mode accepts any value, and the dialog width depends on it
|
||||
const configColumnSpan = this._config.column_span;
|
||||
const columnSpan = Math.min(
|
||||
typeof configColumnSpan === "number" &&
|
||||
Number.isInteger(configColumnSpan) &&
|
||||
configColumnSpan >= 1
|
||||
? configColumnSpan
|
||||
: DEFAULT_SECTION_COLUMN_SPAN,
|
||||
this._config.column_span ?? DEFAULT_SECTION_COLUMN_SPAN,
|
||||
this._viewConfig?.max_columns || DEFAULT_MAX_COLUMNS
|
||||
);
|
||||
const singleColumn = columnSpan === 1;
|
||||
@@ -264,10 +258,7 @@ export class HuiDialogEditSection
|
||||
<ha-dialog
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
width="large"
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
style=${styleMap({ "--preview-column-span": previewColumnSpan })}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
.preventScrimClose=${this.isDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -278,7 +269,12 @@ export class HuiDialogEditSection
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
<span slot="headerTitle">${heading}</span>
|
||||
<span
|
||||
slot="headerTitle"
|
||||
class="title-enlargeable"
|
||||
@click=${this._enlarge}
|
||||
>${heading}</span
|
||||
>
|
||||
${
|
||||
this._params.newSection
|
||||
? nothing
|
||||
@@ -458,7 +454,6 @@ export class HuiDialogEditSection
|
||||
ev: ValueChangedEvent<LovelaceSectionRawConfig>
|
||||
): void {
|
||||
ev.stopPropagation();
|
||||
this._animateWidth = true;
|
||||
this._config = ev.detail.value;
|
||||
this._updateDirtyState(this._config!);
|
||||
}
|
||||
@@ -499,15 +494,15 @@ export class HuiDialogEditSection
|
||||
}
|
||||
|
||||
private _previewModeClicked(ev: Event) {
|
||||
this._animateWidth = true;
|
||||
this._storedPreviewMode = (
|
||||
ev.currentTarget as HTMLElement & { mode: PreviewMode }
|
||||
).mode;
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this.large = !this.large;
|
||||
});
|
||||
}
|
||||
|
||||
private _handleTabChanged(ev: CustomEvent): void {
|
||||
@@ -742,18 +737,6 @@ export class HuiDialogEditSection
|
||||
|
||||
ha-dialog {
|
||||
--dialog-content-padding: var(--ha-space-2);
|
||||
--preview-column-width: 390px;
|
||||
--preview-width: calc(
|
||||
var(--preview-column-span) * var(--preview-column-width) +
|
||||
(var(--preview-column-span) - 1) *
|
||||
var(--ha-view-sections-column-gap, 32px)
|
||||
);
|
||||
}
|
||||
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
|
||||
.content {
|
||||
@@ -769,18 +752,29 @@ export class HuiDialogEditSection
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (min-width: 451px) and (min-height: 501px) {
|
||||
:host([large]) .content {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.content .preview-frame {
|
||||
padding: 4px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.content .section-preview {
|
||||
--preview-column-width: 390px;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: var(--preview-column-width);
|
||||
}
|
||||
.content .section-preview.wide {
|
||||
max-width: none;
|
||||
width: var(--preview-width);
|
||||
width: calc(
|
||||
var(--column-span) * var(--preview-column-width) +
|
||||
(var(--column-span) - 1) *
|
||||
var(--ha-view-sections-column-gap, 32px)
|
||||
);
|
||||
}
|
||||
.preview-header {
|
||||
display: flex;
|
||||
@@ -834,28 +828,19 @@ export class HuiDialogEditSection
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
ha-dialog {
|
||||
--editor-column-width: 520px;
|
||||
/* Plus the paddings of the preview and the dialog */
|
||||
--ha-dialog-width-lg: calc(
|
||||
var(--editor-column-width) + var(--preview-width) + 28px + 2 *
|
||||
var(--dialog-content-padding)
|
||||
);
|
||||
}
|
||||
.content {
|
||||
flex-direction: row;
|
||||
max-height: var(--code-mirror-max-height);
|
||||
}
|
||||
.content > .element-editor {
|
||||
box-sizing: border-box;
|
||||
flex: 0 1 var(--editor-column-width);
|
||||
padding-inline-end: var(--ha-space-4);
|
||||
}
|
||||
.content > .element-preview {
|
||||
flex: 1 1 0;
|
||||
max-width: 500px;
|
||||
}
|
||||
.content > .element-editor,
|
||||
.content > .element-preview {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
}
|
||||
@@ -904,6 +889,9 @@ export class HuiDialogEditSection
|
||||
margin-inline-end: auto;
|
||||
margin-inline-start: initial;
|
||||
}
|
||||
.title-enlargeable {
|
||||
display: block;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { live } from "lit/directives/live";
|
||||
import { debounce } from "../../../common/util/debounce";
|
||||
import "../../../components/ha-slider";
|
||||
import "../../../components/input/ha-input";
|
||||
@@ -89,7 +88,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
|
||||
.step=${Number(stateObj.attributes.step)}
|
||||
.min=${Number(stateObj.attributes.min)}
|
||||
.max=${Number(stateObj.attributes.max)}
|
||||
.value=${live(Number(stateObj.state))}
|
||||
.value=${Number(stateObj.state)}
|
||||
@change=${this._selectedValueChanged}
|
||||
></ha-slider>
|
||||
<span class="state">
|
||||
@@ -112,7 +111,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
|
||||
.step=${Number(stateObj.attributes.step)}
|
||||
.min=${Number(stateObj.attributes.min)}
|
||||
.max=${Number(stateObj.attributes.max)}
|
||||
.value=${live(Number(stateObj.state).toString())}
|
||||
.value=${Number(stateObj.state).toString()}
|
||||
type="number"
|
||||
@change=${this._selectedValueChanged}
|
||||
>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||
import "../../../components/ha-button";
|
||||
@@ -29,7 +29,7 @@ const EMPTY_STATE_OBJ = {
|
||||
|
||||
@customElement("hui-button-row")
|
||||
export class HuiButtonRow extends LitElement implements LovelaceRow {
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
public hass?: HomeAssistant;
|
||||
|
||||
@state() private _config?: ButtonRowConfig;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiCheckCircle, mdiDownloadMultiple, mdiStar } from "@mdi/js";
|
||||
import { mdiCheckCircle, mdiDownload, mdiStar } from "@mdi/js";
|
||||
import type { CSSResultGroup } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
@@ -160,7 +160,7 @@ export class HaMarketplaceDiscover extends LitElement {
|
||||
${
|
||||
repository.downloads
|
||||
? html`<span>
|
||||
<ha-svg-icon .path=${mdiDownloadMultiple}></ha-svg-icon>
|
||||
<ha-svg-icon .path=${mdiDownload}></ha-svg-icon>
|
||||
${formatNumber(repository.downloads, locale, compact)}
|
||||
</span>`
|
||||
: nothing
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
mdiCheckCircleOutline,
|
||||
mdiCompassOutline,
|
||||
mdiDotsVertical,
|
||||
mdiDownloadMultiple,
|
||||
mdiDownload,
|
||||
mdiLinkPlus,
|
||||
mdiOpenInNew,
|
||||
mdiStar,
|
||||
@@ -674,7 +674,7 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
|
||||
return html`${
|
||||
narrow
|
||||
? html`<ha-svg-icon .path=${mdiDownloadMultiple}></ha-svg-icon>`
|
||||
? html`<ha-svg-icon .path=${mdiDownload}></ha-svg-icon>`
|
||||
: nothing
|
||||
}${formatNumber(repository.downloads, this._i18n.locale, compact)}`;
|
||||
},
|
||||
|
||||
@@ -3,11 +3,12 @@ import {
|
||||
mdiAccountGroup,
|
||||
mdiAlertCircleOutline,
|
||||
mdiArrowUpBoldCircleOutline,
|
||||
mdiBug,
|
||||
mdiCheckCircle,
|
||||
mdiCheckCircleOutline,
|
||||
mdiDotsVertical,
|
||||
mdiDownloadMultiple,
|
||||
mdiPackageVariantClosed,
|
||||
mdiDownload,
|
||||
mdiGithub,
|
||||
mdiRestart,
|
||||
mdiStar,
|
||||
mdiTestTube,
|
||||
@@ -57,7 +58,7 @@ import type { UpdateEntity } from "../../../data/update";
|
||||
import { latestVersionIsSkipped } from "../../../data/update";
|
||||
import { showConfigFlowDialog } from "../../../dialogs/config-flow/show-dialog-config-flow";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { showRestartConfirmation } from "../../../dialogs/restart/show-restart-confirmation";
|
||||
import { showRestartDialog } from "../../../dialogs/restart/show-dialog-restart";
|
||||
import "../../../layouts/hass-error-screen";
|
||||
import "../../../layouts/hass-loading-screen";
|
||||
import "../../../layouts/hass-subpage";
|
||||
@@ -174,8 +175,6 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
@consume({ context: connectionContext, subscribe: true })
|
||||
private _connection!: ContextType<typeof connectionContext>;
|
||||
|
||||
@state() private _confirmingRestart = false;
|
||||
|
||||
@state() private _integrationCategoryIcons?: IntegrationCategoryIcons;
|
||||
|
||||
@state()
|
||||
@@ -707,12 +706,13 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
if (!repository.installed) {
|
||||
return {
|
||||
kind: "available",
|
||||
icon: mdiPackageVariantClosed,
|
||||
icon: mdiDownload,
|
||||
title: localize("ui.panel.marketplace.repository.status.not_installed"),
|
||||
detail: localize("ui.panel.marketplace.repository.status.available", {
|
||||
version: repository.available_version,
|
||||
}),
|
||||
action: this._installButton(
|
||||
mdiDownload,
|
||||
localize("ui.panel.marketplace.common.install")
|
||||
),
|
||||
};
|
||||
@@ -734,7 +734,11 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
installed: repository.installed_version,
|
||||
version: repository.available_version,
|
||||
}),
|
||||
action: this._installButton(localize("ui.common.update"), this._update),
|
||||
action: this._installButton(
|
||||
mdiArrowUpBoldCircleOutline,
|
||||
localize("ui.common.update"),
|
||||
this._update
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -751,9 +755,9 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
action: html`<ha-button
|
||||
variant="warning"
|
||||
appearance="filled"
|
||||
.loading=${this._confirmingRestart}
|
||||
@click=${this._restart}
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiRestart}></ha-svg-icon>
|
||||
${localize("ui.panel.marketplace.repository.next_step.restart_button")}
|
||||
</ha-button>`,
|
||||
};
|
||||
@@ -796,10 +800,12 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
}
|
||||
|
||||
private _installButton(
|
||||
icon: string,
|
||||
label: string,
|
||||
handler: () => void = this._installRepositoryDialog
|
||||
) {
|
||||
return html`<ha-button appearance="filled" @click=${handler}>
|
||||
<ha-svg-icon slot="start" .path=${icon}></ha-svg-icon>
|
||||
${label}
|
||||
</ha-button>`;
|
||||
}
|
||||
@@ -932,6 +938,7 @@ type: module</pre>`,
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiGithub}></ha-svg-icon>
|
||||
${localize("ui.panel.marketplace.repository.details.source_code")}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@@ -940,6 +947,7 @@ type: module</pre>`,
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${mdiBug}></ha-svg-icon>
|
||||
${localize("ui.panel.marketplace.repository.details.issue_tracker")}
|
||||
</ha-button>
|
||||
</div>
|
||||
@@ -1019,7 +1027,7 @@ type: module</pre>`,
|
||||
}
|
||||
if (repository.downloads) {
|
||||
signals.push({
|
||||
icon: mdiDownloadMultiple,
|
||||
icon: mdiDownload,
|
||||
text: localize("ui.panel.marketplace.repository.community.downloads", {
|
||||
number: repository.downloads,
|
||||
count: html`<strong
|
||||
@@ -1084,20 +1092,8 @@ type: module</pre>`,
|
||||
this._installRepositoryDialog();
|
||||
}
|
||||
|
||||
private async _restart() {
|
||||
if (this._confirmingRestart) {
|
||||
return;
|
||||
}
|
||||
this._confirmingRestart = true;
|
||||
try {
|
||||
await showRestartConfirmation(this, {
|
||||
localize: this._i18n.localize,
|
||||
connection: this._connection.connection,
|
||||
callService: this._api.callService,
|
||||
});
|
||||
} finally {
|
||||
this._confirmingRestart = false;
|
||||
}
|
||||
private _restart() {
|
||||
showRestartDialog(this);
|
||||
}
|
||||
|
||||
private _setUp() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiGithub } from "@mdi/js";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
@@ -11,7 +10,6 @@ import "../../../components/ha-dialog";
|
||||
import "../../../components/ha-dialog-footer";
|
||||
import "../../../components/ha-form/ha-form";
|
||||
import type { HaFormSchema } from "../../../components/ha-form/types";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/progress/ha-progress-bar";
|
||||
import { apiContext, internationalizationContext } from "../../../data/context";
|
||||
import type { RepositoryType } from "../../../data/marketplace/repository";
|
||||
@@ -81,7 +79,6 @@ export class DialogMarketplaceCustomRepositories extends DialogMixin<Marketplace
|
||||
this._githubConnected
|
||||
? nothing
|
||||
: html`<ha-alert alert-type="info">
|
||||
<ha-svg-icon slot="icon" .path=${mdiGithub}></ha-svg-icon>
|
||||
${this._i18n.localize(
|
||||
"ui.panel.marketplace.dialog_custom_repositories.github_needed"
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { RenderItemFunction } from "@lit-labs/virtualizer/virtualize";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { mdiSwapHorizontal, mdiUpdate } from "@mdi/js";
|
||||
import type { CSSResultGroup } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
@@ -22,7 +21,6 @@ import {
|
||||
type PickerComboBoxItem,
|
||||
} from "../../../components/ha-picker-combo-box";
|
||||
import "../../../components/ha-spinner";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import "../../../components/progress/ha-progress-bar";
|
||||
|
||||
import { relativeTime } from "../../../common/datetime/relative_time";
|
||||
@@ -261,7 +259,6 @@ export class DialogMarketplaceInstall extends DialogMixin<MarketplaceInstallDial
|
||||
{ domain: repository.domain }
|
||||
)}
|
||||
>
|
||||
<ha-svg-icon slot="icon" .path=${mdiSwapHorizontal}></ha-svg-icon>
|
||||
${this._i18n.localize(
|
||||
"ui.panel.marketplace.dialog_install.replaces_built_in_warning",
|
||||
{ repository: repository.name, domain: repository.domain }
|
||||
@@ -284,7 +281,6 @@ export class DialogMarketplaceInstall extends DialogMixin<MarketplaceInstallDial
|
||||
${
|
||||
tooNew
|
||||
? html`<ha-alert alert-type="warning">
|
||||
<ha-svg-icon slot="icon" .path=${mdiUpdate}></ha-svg-icon>
|
||||
${installBlockedReason(this._i18n.localize, repository)}
|
||||
${this._i18n.localize(
|
||||
"ui.panel.marketplace.dialog_install.older_version_hint"
|
||||
|
||||
@@ -3,7 +3,6 @@ import { mdiMinus, mdiPlus, mdiWaterPercent } from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { keyed } from "lit/directives/keyed";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import type { HASSDomEvent } from "../../common/dom/fire_event";
|
||||
@@ -53,8 +52,6 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
|
||||
@state() private _targetHumidity?: number;
|
||||
|
||||
@state() private _changingHumidity?: number;
|
||||
|
||||
private _sizeController = createStateControlCircularSliderController(this);
|
||||
|
||||
private _pendingSync = new PendingValueSync();
|
||||
@@ -64,11 +61,7 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
if (!changedProp.has("stateObj")) {
|
||||
return;
|
||||
}
|
||||
if (this.stateObj.state === UNAVAILABLE) {
|
||||
this._changingHumidity = undefined;
|
||||
}
|
||||
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
|
||||
this._changingHumidity = undefined;
|
||||
this._debouncedCallService.cancel();
|
||||
this._pendingSync.reset();
|
||||
this._syncTargetHumidity();
|
||||
@@ -78,9 +71,6 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
}
|
||||
|
||||
private _syncTargetHumidity() {
|
||||
if (this.stateObj.attributes.humidity !== this._targetHumidity) {
|
||||
this._changingHumidity = undefined;
|
||||
}
|
||||
this._targetHumidity = this.stateObj.attributes.humidity;
|
||||
}
|
||||
|
||||
@@ -106,11 +96,8 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
|
||||
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
|
||||
const { value } = ev.detail;
|
||||
if (typeof value !== "number" || isNaN(value)) {
|
||||
this._changingHumidity = undefined;
|
||||
return;
|
||||
}
|
||||
this._changingHumidity = value;
|
||||
if (typeof value !== "number" || isNaN(value)) return;
|
||||
this._targetHumidity = value;
|
||||
}
|
||||
|
||||
private _debouncedCallService = debounce(() => this._callService(), 1000);
|
||||
@@ -225,10 +212,6 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return keyed(this.stateObj.entity_id, this._renderControl());
|
||||
}
|
||||
|
||||
private _renderControl() {
|
||||
const supportsTargetHumidity = supportsFeature(
|
||||
this.stateObj,
|
||||
ClimateEntityFeature.TARGET_HUMIDITY
|
||||
@@ -281,8 +264,7 @@ export class HaStateControlClimateHumidity extends LitElement {
|
||||
>
|
||||
</ha-control-circular-slider>
|
||||
<div class="info">
|
||||
${this._renderLabel()}
|
||||
${this._renderTarget(this._changingHumidity ?? targetHumidity)}
|
||||
${this._renderLabel()} ${this._renderTarget(targetHumidity)}
|
||||
${this._renderCurrentHumidity(
|
||||
this.stateObj.attributes.current_humidity
|
||||
)}
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { keyed } from "lit/directives/keyed";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { UNIT_F } from "../../common/const";
|
||||
@@ -82,8 +81,6 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
|
||||
@state() private _targetTemperature: Partial<Record<Target, number>> = {};
|
||||
|
||||
@state() private _changingTemperature: Partial<Record<Target, number>> = {};
|
||||
|
||||
@state() private _selectTargetTemperature: Target = "low";
|
||||
|
||||
private _sizeController = createStateControlCircularSliderController(this);
|
||||
@@ -95,11 +92,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
if (!changedProp.has("stateObj")) {
|
||||
return;
|
||||
}
|
||||
if (this.stateObj.state === UNAVAILABLE) {
|
||||
this._changingTemperature = {};
|
||||
}
|
||||
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
|
||||
this._changingTemperature = {};
|
||||
this._debouncedCallService.cancel();
|
||||
this._pendingSync.reset();
|
||||
this._syncTargetTemperature();
|
||||
@@ -109,20 +102,11 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
}
|
||||
|
||||
private _syncTargetTemperature() {
|
||||
const targetTemperature: Partial<Record<Target, number>> = {
|
||||
this._targetTemperature = {
|
||||
value: this.stateObj.attributes.temperature,
|
||||
low: this.stateObj.attributes.target_temp_low,
|
||||
high: this.stateObj.attributes.target_temp_high,
|
||||
};
|
||||
if (
|
||||
(Object.keys(this._changingTemperature) as Target[]).some(
|
||||
(target) =>
|
||||
targetTemperature[target] !== this._targetTemperature[target]
|
||||
)
|
||||
) {
|
||||
this._changingTemperature = {};
|
||||
}
|
||||
this._targetTemperature = targetTemperature;
|
||||
}
|
||||
|
||||
private get _step() {
|
||||
@@ -143,31 +127,27 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
private _valueChanged(ev: HASSDomEvent<HASSDomEvents["value-changed"]>) {
|
||||
const { value } = ev.detail;
|
||||
if (typeof value !== "number" || isNaN(value)) return;
|
||||
const target = ev.type.replace("-changed", "") as Target;
|
||||
const target = ev.type.replace("-changed", "");
|
||||
this._targetTemperature = {
|
||||
...this._targetTemperature,
|
||||
[target]: this._clampToRange(target, value),
|
||||
[target]: value,
|
||||
};
|
||||
this._selectTargetTemperature = target;
|
||||
this._selectTargetTemperature = target as Target;
|
||||
this._debouncedCallService.cancel();
|
||||
this._callService(target);
|
||||
}
|
||||
|
||||
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
|
||||
const { value } = ev.detail;
|
||||
if (typeof value !== "number" || isNaN(value)) {
|
||||
this._changingTemperature = {};
|
||||
return;
|
||||
}
|
||||
if (typeof value !== "number" || isNaN(value)) return;
|
||||
const target = ev.type.replace("-changing", "");
|
||||
this._changingTemperature = { [target]: value };
|
||||
this._targetTemperature = {
|
||||
...this._targetTemperature,
|
||||
[target]: value,
|
||||
};
|
||||
this._selectTargetTemperature = target as Target;
|
||||
}
|
||||
|
||||
private get _displayedTemperature() {
|
||||
return { ...this._targetTemperature, ...this._changingTemperature };
|
||||
}
|
||||
|
||||
private _debouncedCallService = debounce(
|
||||
(target: Target) => this._callService(target),
|
||||
1000
|
||||
@@ -200,25 +180,21 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
let temp = this._targetTemperature[target] ?? defaultValue;
|
||||
temp += step;
|
||||
temp = clamp(temp, this._min, this._max);
|
||||
if (target === "high" && this._targetTemperature.low != null) {
|
||||
temp = clamp(temp, this._targetTemperature.low, this._max);
|
||||
}
|
||||
if (target === "low" && this._targetTemperature.high != null) {
|
||||
temp = clamp(temp, this._min, this._targetTemperature.high);
|
||||
}
|
||||
|
||||
this._targetTemperature = {
|
||||
...this._targetTemperature,
|
||||
[target]: this._clampToRange(target, temp),
|
||||
[target]: temp,
|
||||
};
|
||||
this._pendingSync.schedule();
|
||||
this._debouncedCallService(target);
|
||||
}
|
||||
|
||||
private _clampToRange(target: Target, temp: number) {
|
||||
if (target === "high" && this._targetTemperature.low != null) {
|
||||
return clamp(temp, this._targetTemperature.low, this._max);
|
||||
}
|
||||
if (target === "low" && this._targetTemperature.high != null) {
|
||||
return clamp(temp, this._min, this._targetTemperature.high);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
private _handleSelectTemp(ev) {
|
||||
const target = ev.currentTarget.target as Target;
|
||||
this._selectTargetTemperature = target;
|
||||
@@ -378,7 +354,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
}
|
||||
|
||||
if (this._supportsTargetTemperature && !this.showCurrentAsPrimary) {
|
||||
return this._renderTarget(this._displayedTemperature.value!, "big");
|
||||
return this._renderTarget(this._targetTemperature.value!, "big");
|
||||
}
|
||||
|
||||
if (this._supportsTargetTemperatureRange && !this.showCurrentAsPrimary) {
|
||||
@@ -398,7 +374,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
"target_temp_low"
|
||||
)}
|
||||
</span>
|
||||
${this._renderTarget(this._displayedTemperature.low!, "big")}
|
||||
${this._renderTarget(this._targetTemperature.low!, "big")}
|
||||
</button>
|
||||
<button
|
||||
@click=${this._handleSelectTemp}
|
||||
@@ -414,7 +390,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
"target_temp_high"
|
||||
)}
|
||||
</span>
|
||||
${this._renderTarget(this._displayedTemperature.high!, "big")}
|
||||
${this._renderTarget(this._targetTemperature.high!, "big")}
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
@@ -451,7 +427,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
return html`
|
||||
<p class="label secondary">
|
||||
<ha-svg-icon .path=${mdiThermostat}></ha-svg-icon>
|
||||
${this._renderTarget(this._displayedTemperature.value!, "normal")}
|
||||
${this._renderTarget(this._targetTemperature.value!, "normal")}
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
@@ -474,7 +450,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
"target_temp_low"
|
||||
)}
|
||||
</span>
|
||||
${this._renderTarget(this._displayedTemperature.low!, "normal", true)}
|
||||
${this._renderTarget(this._targetTemperature.low!, "normal", true)}
|
||||
</button>
|
||||
<span>·</span>
|
||||
<button
|
||||
@@ -491,7 +467,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
"target_temp_high"
|
||||
)}
|
||||
</span>
|
||||
${this._renderTarget(this._displayedTemperature.high!, "normal", true)}
|
||||
${this._renderTarget(this._targetTemperature.high!, "normal", true)}
|
||||
</button>
|
||||
</p>
|
||||
`;
|
||||
@@ -527,10 +503,6 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return keyed(this.stateObj.entity_id, this._renderControl());
|
||||
}
|
||||
|
||||
private _renderControl() {
|
||||
const mode = this.stateObj.state;
|
||||
const action = this.stateObj.attributes.hvac_action;
|
||||
const active = stateActive(this.stateObj);
|
||||
@@ -577,7 +549,7 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
.preventInteractionOnScroll=${this.preventInteractionOnScroll}
|
||||
.inactive=${!active}
|
||||
.mode=${sliderMode}
|
||||
.value=${this._displayedTemperature.value}
|
||||
.value=${this._targetTemperature.value}
|
||||
.min=${this._min}
|
||||
.max=${this._max}
|
||||
.step=${this._step}
|
||||
@@ -613,8 +585,8 @@ export class HaStateControlClimateTemperature extends LitElement {
|
||||
.preventInteractionOnScroll=${this.preventInteractionOnScroll}
|
||||
.inactive=${!active}
|
||||
dual
|
||||
.low=${this._displayedTemperature.low}
|
||||
.high=${this._displayedTemperature.high}
|
||||
.low=${this._targetTemperature.low}
|
||||
.high=${this._targetTemperature.high}
|
||||
.min=${this._min}
|
||||
.max=${this._max}
|
||||
.step=${this._step}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { mdiMinus, mdiPlus, mdiThermostat, mdiWaterPercent } from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { keyed } from "lit/directives/keyed";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { consumeLocalize } from "../../common/decorators/consume-context-entry";
|
||||
@@ -58,8 +57,6 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
|
||||
@state() private _targetHumidity?: number;
|
||||
|
||||
@state() private _changingHumidity?: number;
|
||||
|
||||
private _sizeController = createStateControlCircularSliderController(this);
|
||||
|
||||
private _pendingSync = new PendingValueSync();
|
||||
@@ -69,11 +66,7 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
if (!changedProp.has("stateObj")) {
|
||||
return;
|
||||
}
|
||||
if (this.stateObj.state === UNAVAILABLE) {
|
||||
this._changingHumidity = undefined;
|
||||
}
|
||||
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
|
||||
this._changingHumidity = undefined;
|
||||
this._debouncedCallService.cancel();
|
||||
this._pendingSync.reset();
|
||||
this._syncTargetHumidity();
|
||||
@@ -83,9 +76,6 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
}
|
||||
|
||||
private _syncTargetHumidity() {
|
||||
if (this.stateObj.attributes.humidity !== this._targetHumidity) {
|
||||
this._changingHumidity = undefined;
|
||||
}
|
||||
this._targetHumidity = this.stateObj.attributes.humidity;
|
||||
}
|
||||
|
||||
@@ -111,11 +101,8 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
|
||||
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
|
||||
const { value } = ev.detail;
|
||||
if (typeof value !== "number" || isNaN(value)) {
|
||||
this._changingHumidity = undefined;
|
||||
return;
|
||||
}
|
||||
this._changingHumidity = value;
|
||||
if (typeof value !== "number" || isNaN(value)) return;
|
||||
this._targetHumidity = value;
|
||||
}
|
||||
|
||||
private _debouncedCallService = debounce(() => this._callService(), 1000);
|
||||
@@ -213,10 +200,7 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
}
|
||||
|
||||
if (this._targetHumidity != null && !this.showCurrentAsPrimary) {
|
||||
return this._renderTarget(
|
||||
this._changingHumidity ?? this._targetHumidity,
|
||||
"big"
|
||||
);
|
||||
return this._renderTarget(this._targetHumidity!, "big");
|
||||
}
|
||||
|
||||
if (this.stateObj.state !== UNAVAILABLE) {
|
||||
@@ -250,10 +234,7 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
return html`
|
||||
<p class="label">
|
||||
<ha-svg-icon .path=${mdiThermostat}></ha-svg-icon>
|
||||
${this._renderCurrent(
|
||||
this._changingHumidity ?? this._targetHumidity,
|
||||
"normal"
|
||||
)}
|
||||
${this._renderCurrent(this._targetHumidity, "normal")}
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
@@ -318,10 +299,6 @@ export class HaStateControlHumidifierHumidity extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return keyed(this.stateObj.entity_id, this._renderControl());
|
||||
}
|
||||
|
||||
private _renderControl() {
|
||||
const stateColor = stateColorCss(this.stateObj);
|
||||
const active = stateActive(this.stateObj);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { mdiMinus, mdiPlus } from "@mdi/js";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { keyed } from "lit/directives/keyed";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { UNIT_F } from "../../common/const";
|
||||
@@ -61,8 +60,6 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
|
||||
@state() private _targetTemperature?: number;
|
||||
|
||||
@state() private _changingTemperature?: number;
|
||||
|
||||
private _sizeController = createStateControlCircularSliderController(this);
|
||||
|
||||
private _pendingSync = new PendingValueSync();
|
||||
@@ -72,11 +69,7 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
if (!changedProp.has("stateObj")) {
|
||||
return;
|
||||
}
|
||||
if (this.stateObj.state === UNAVAILABLE) {
|
||||
this._changingTemperature = undefined;
|
||||
}
|
||||
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
|
||||
this._changingTemperature = undefined;
|
||||
this._debouncedCallService.cancel();
|
||||
this._pendingSync.reset();
|
||||
this._syncTargetTemperature();
|
||||
@@ -86,9 +79,6 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
}
|
||||
|
||||
private _syncTargetTemperature() {
|
||||
if (this.stateObj.attributes.temperature !== this._targetTemperature) {
|
||||
this._changingTemperature = undefined;
|
||||
}
|
||||
this._targetTemperature = this.stateObj.attributes.temperature;
|
||||
}
|
||||
|
||||
@@ -117,11 +107,8 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
|
||||
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
|
||||
const { value } = ev.detail;
|
||||
if (typeof value !== "number" || isNaN(value)) {
|
||||
this._changingTemperature = undefined;
|
||||
return;
|
||||
}
|
||||
this._changingTemperature = value;
|
||||
if (typeof value !== "number" || isNaN(value)) return;
|
||||
this._targetTemperature = value;
|
||||
}
|
||||
|
||||
private _debouncedCallService = debounce(() => this._callService(), 1000);
|
||||
@@ -244,10 +231,6 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
}
|
||||
|
||||
protected render() {
|
||||
return keyed(this.stateObj.entity_id, this._renderControl());
|
||||
}
|
||||
|
||||
private _renderControl() {
|
||||
const supportsTargetTemperature = supportsFeature(
|
||||
this.stateObj,
|
||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
@@ -288,9 +271,7 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
|
||||
</ha-control-circular-slider>
|
||||
<div class="info">
|
||||
${this._renderLabel()}
|
||||
${this._renderTargetTemperature(
|
||||
this._changingTemperature ?? this._targetTemperature
|
||||
)}
|
||||
${this._renderTargetTemperature(this._targetTemperature)}
|
||||
${this._renderCurrentTemperature(
|
||||
this.stateObj.attributes.current_temperature
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import type { HASSDomEvent } from "../common/dom/fire_event";
|
||||
import { mainWindow } from "../common/dom/get_main_window";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { replaceCurrentUrl } from "../common/navigate";
|
||||
import {
|
||||
createMoreInfoUrl,
|
||||
@@ -11,6 +12,8 @@ import type { MoreInfoDialogParams } from "../dialogs/more-info/ha-more-info-dia
|
||||
import type { Constructor } from "../types";
|
||||
import type { HassBaseEl } from "./hass-base-mixin";
|
||||
|
||||
const LARGE_MORE_INFO_DOMAINS = ["camera", "image"];
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
interface HASSDomEvents {
|
||||
@@ -44,7 +47,13 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
{
|
||||
entityId: ev.detail.entityId,
|
||||
view,
|
||||
large: ev.detail.large,
|
||||
large:
|
||||
ev.detail.large ??
|
||||
(ev.detail.entityId
|
||||
? LARGE_MORE_INFO_DOMAINS.includes(
|
||||
computeDomain(ev.detail.entityId)
|
||||
)
|
||||
: false),
|
||||
data: ev.detail.data,
|
||||
returnUrl,
|
||||
},
|
||||
|
||||
@@ -2423,7 +2423,7 @@
|
||||
},
|
||||
"recreate_entity_ids": {
|
||||
"confirm_rename_title": "Are you sure you want to recreate your entity IDs?",
|
||||
"confirm_rename_warning": "This will not update any configuration (like automations, scripts, scenes, dashboards) that is currently using these entities! You will have to manually edit them yourself to use the new entity IDs!",
|
||||
"confirm_rename_warning": "This will not change any configuration (like automations, scripts, scenes, dashboards) that is currently using these entities! You will have to manually edit them yourself to use the new entity IDs!",
|
||||
"will_rename": "{count} {count, plural,\n one {entity ID}\n other {entity IDs}\n} will be renamed",
|
||||
"new": "New",
|
||||
"old": "Old",
|
||||
@@ -5800,7 +5800,6 @@
|
||||
"expose_new_entities_info": "Should new entities be exposed? Exposes supported devices that are not classified as security devices."
|
||||
},
|
||||
"satellite_wizard": {
|
||||
"title": "Voice satellite setup",
|
||||
"skip": "Skip",
|
||||
"not_available": "Your voice assistant is not available.",
|
||||
"update": {
|
||||
@@ -8266,7 +8265,6 @@
|
||||
"delete": "Delete",
|
||||
"delete_confirm_title": "Delete {title}?",
|
||||
"delete_confirm_text": "Its devices and entities will be permanently deleted.",
|
||||
"delete_confirm_dependents": "{integrations} {count, plural,\n one {depends}\n other {depend}\n} on {name} and may stop working.",
|
||||
"enable_debug_logging": "Enable debug logging",
|
||||
"reconfigure": "Reconfigure",
|
||||
"reload": "Reload",
|
||||
@@ -10961,8 +10959,6 @@
|
||||
"pick_card": "Add to dashboard",
|
||||
"pick_card_title": "Which card would you like to add to {name}",
|
||||
"toggle_editor": "Toggle editor",
|
||||
"enlarge": "Enlarge",
|
||||
"shrink": "Shrink",
|
||||
"unsaved_changes": "You have unsaved changes",
|
||||
"confirm_cancel": "Are you sure you want to cancel?",
|
||||
"show_visual_editor": "Show visual editor",
|
||||
@@ -11011,8 +11007,6 @@
|
||||
"pick_badge": "Which badge would you like to add?",
|
||||
"pick_badge_title": "Which badge would you like to add to \"{name}\"?",
|
||||
"toggle_editor": "[%key:ui::panel::lovelace::editor::edit_card::toggle_editor%]",
|
||||
"enlarge": "[%key:ui::panel::lovelace::editor::edit_card::enlarge%]",
|
||||
"shrink": "[%key:ui::panel::lovelace::editor::edit_card::shrink%]",
|
||||
"unsaved_changes": "[%key:ui::panel::lovelace::editor::edit_card::unsaved_changes%]",
|
||||
"confirm_cancel": "[%key:ui::panel::lovelace::editor::edit_card::confirm_cancel%]",
|
||||
"show_visual_editor": "[%key:ui::panel::lovelace::editor::edit_card::show_visual_editor%]",
|
||||
@@ -12463,9 +12457,6 @@
|
||||
"dropdown": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style_list::dropdown%]"
|
||||
}
|
||||
},
|
||||
"timer-progress": {
|
||||
"label": "Timer progress"
|
||||
},
|
||||
"fan-preset-modes": {
|
||||
"label": "Fan preset modes",
|
||||
"style": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style%]",
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { subscribeVisibility } from "../../../src/common/condition/subscribe-visibility";
|
||||
import type { VisibilityCondition } from "../../../src/panels/lovelace/common/validate-condition";
|
||||
import type { HomeAssistant } from "../../../src/types";
|
||||
|
||||
interface CapturedSubscription {
|
||||
push: (message: { result?: boolean }) => void;
|
||||
unsub: ReturnType<typeof vi.fn>;
|
||||
condition: unknown;
|
||||
}
|
||||
|
||||
let subs: CapturedSubscription[];
|
||||
|
||||
const tick = () =>
|
||||
new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, 10);
|
||||
});
|
||||
|
||||
const createHass = (userId = "user1"): HomeAssistant =>
|
||||
({
|
||||
connection: {
|
||||
subscribeMessage: vi.fn(
|
||||
(
|
||||
onChange: CapturedSubscription["push"],
|
||||
msg: { condition: unknown }
|
||||
) => {
|
||||
const unsub = vi.fn();
|
||||
|
||||
subs.push({ push: onChange, unsub, condition: msg.condition });
|
||||
|
||||
return Promise.resolve(unsub);
|
||||
}
|
||||
),
|
||||
},
|
||||
states: {},
|
||||
user: { id: userId },
|
||||
locale: { time_zone: "local" },
|
||||
config: { time_zone: "America/New_York" },
|
||||
}) as unknown as HomeAssistant;
|
||||
|
||||
describe("subscribeVisibility", () => {
|
||||
beforeEach(() => {
|
||||
subs = [];
|
||||
});
|
||||
|
||||
it("checks client conditions again with each hass passed to update", async () => {
|
||||
const onChange = vi.fn();
|
||||
|
||||
const conditions: VisibilityCondition[] = [
|
||||
{ condition: "user", users: ["user1"] },
|
||||
];
|
||||
|
||||
const subscription = subscribeVisibility(
|
||||
createHass("user1"),
|
||||
conditions,
|
||||
onChange
|
||||
);
|
||||
|
||||
await tick();
|
||||
expect(onChange).toHaveBeenLastCalledWith("visible", undefined);
|
||||
|
||||
subscription.update(createHass("user2"));
|
||||
expect(onChange).toHaveBeenLastCalledWith("hidden", undefined);
|
||||
});
|
||||
|
||||
it("closes core subscriptions and stops reporting after unsubscribe", async () => {
|
||||
const onChange = vi.fn();
|
||||
|
||||
const conditions: VisibilityCondition[] = [
|
||||
{ condition: "state", entity: "light.kitchen", state: "on" },
|
||||
];
|
||||
|
||||
const subscription = subscribeVisibility(
|
||||
createHass(),
|
||||
conditions,
|
||||
onChange
|
||||
);
|
||||
|
||||
await tick();
|
||||
expect(subs).toHaveLength(1);
|
||||
|
||||
subs[0].push({ result: true });
|
||||
expect(onChange).toHaveBeenLastCalledWith("visible", undefined);
|
||||
onChange.mockClear();
|
||||
|
||||
subscription.unsubscribe();
|
||||
await tick();
|
||||
expect(subs[0].unsub).toHaveBeenCalled();
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sends the context entity to core for conditions without one", async () => {
|
||||
const conditions: VisibilityCondition[] = [
|
||||
{ condition: "state", state: "on" },
|
||||
];
|
||||
|
||||
subscribeVisibility(createHass(), conditions, vi.fn(), {
|
||||
entity_id: "light.kitchen",
|
||||
});
|
||||
|
||||
await tick();
|
||||
expect(subs).toHaveLength(1);
|
||||
expect(subs[0].condition).toEqual({
|
||||
condition: "state",
|
||||
entity_id: "light.kitchen",
|
||||
state: "on",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -177,7 +177,6 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
|
||||
"datasets": [
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#4269d07F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -348,7 +347,6 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
|
||||
},
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#f4bd4a7F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -1382,7 +1380,6 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
|
||||
"datasets": [
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#4269d07F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -1447,7 +1444,6 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
|
||||
},
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#f4bd4a7F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
|
||||
+1
-44
@@ -1,8 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getConfigSubpageTitle,
|
||||
getSelectedPanelUrlPath,
|
||||
} from "../../src/data/panel";
|
||||
import { getConfigSubpageTitle } from "../../src/data/panel";
|
||||
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
|
||||
import type { HomeAssistant } from "../../src/types";
|
||||
|
||||
@@ -86,43 +83,3 @@ describe("getConfigSubpageTitle", () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSelectedPanelUrlPath", () => {
|
||||
const urlPaths = ["lovelace", "history", "config/logs", "config/logs/raw"];
|
||||
|
||||
it("falls back to the first path segment", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/config/automation")).toBe(
|
||||
"config"
|
||||
);
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/profile/general")).toBe(
|
||||
"profile"
|
||||
);
|
||||
});
|
||||
|
||||
it("selects a panel whose url_path has several segments", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs")).toBe(
|
||||
"config/logs"
|
||||
);
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs/details")).toBe(
|
||||
"config/logs"
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the most specific url_path", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs/raw")).toBe(
|
||||
"config/logs/raw"
|
||||
);
|
||||
});
|
||||
|
||||
it("only matches whole segments", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/config/logsfoo")).toBe("config");
|
||||
});
|
||||
|
||||
it("keeps matching single segment panels on their subpaths", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/lovelace/0")).toBe("lovelace");
|
||||
});
|
||||
|
||||
it("returns an empty url_path for the root path", () => {
|
||||
expect(getSelectedPanelUrlPath(urlPaths, "/")).toBe("");
|
||||
});
|
||||
});
|
||||
@@ -1,63 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ClimateEntityFeature } from "../../../src/data/climate";
|
||||
import { MockClimateEntity } from "../../../src/fake_data/entities/climate-entity";
|
||||
|
||||
const hvacAction = (state: string, current: number, target: number) =>
|
||||
new MockClimateEntity({
|
||||
entity_id: "climate.demo",
|
||||
state,
|
||||
attributes: {
|
||||
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
|
||||
current_temperature: current,
|
||||
temperature: target,
|
||||
},
|
||||
}).toState().attributes.hvac_action;
|
||||
|
||||
// A range of 20° to 24° only, like climate.upstairs in the arsaboo demo
|
||||
const rangeHvacAction = (state: string, current: number) =>
|
||||
new MockClimateEntity({
|
||||
entity_id: "climate.demo",
|
||||
state,
|
||||
attributes: {
|
||||
supported_features:
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE +
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
|
||||
current_temperature: current,
|
||||
temperature: null,
|
||||
target_temp_low: 20,
|
||||
target_temp_high: 24,
|
||||
},
|
||||
}).toState().attributes.hvac_action;
|
||||
|
||||
describe("MockClimateEntity", () => {
|
||||
it.each([
|
||||
["heat", 18, 21, "heating"],
|
||||
["heat", 21, 21, "idle"],
|
||||
["cool", 25, 21, "cooling"],
|
||||
["cool", 20, 21, "idle"],
|
||||
["dry", 20, 21, "drying"],
|
||||
["fan_only", 20, 21, "fan"],
|
||||
["off", 18, 21, "off"],
|
||||
])(
|
||||
"in %s at %d° with a target of %d° is %s",
|
||||
(state, current, target, action) => {
|
||||
expect(hvacAction(state, current, target)).toBe(action);
|
||||
}
|
||||
);
|
||||
|
||||
it.each([
|
||||
["heat", 18, "heating"],
|
||||
["heat", 25, "idle"],
|
||||
["cool", 25, "cooling"],
|
||||
["cool", 18, "idle"],
|
||||
["heat_cool", 18, "heating"],
|
||||
["heat_cool", 25, "cooling"],
|
||||
["auto", 22, "idle"],
|
||||
])(
|
||||
"in %s at %d° with a range of 20° to 24° is %s",
|
||||
(state, current, action) => {
|
||||
expect(rangeHvacAction(state, current)).toBe(action);
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,109 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { Condition } from "../../src/data/automation";
|
||||
import type { MockHomeAssistant } from "../../src/fake_data/provide_hass";
|
||||
import { provideHass } from "../../src/fake_data/provide_hass";
|
||||
|
||||
type Host = HTMLElement & { hass?: Partial<MockHomeAssistant> };
|
||||
|
||||
// `ownUpdateHass` replaces updateHass as the full demo does, see
|
||||
// demo/src/ha-demo.ts
|
||||
const setup = (ownUpdateHass = false) => {
|
||||
const host: Host = document.createElement("div");
|
||||
|
||||
const overrides: Partial<MockHomeAssistant> = ownUpdateHass
|
||||
? {
|
||||
updateHass: (update: Partial<MockHomeAssistant>) => {
|
||||
host.hass = { ...host.hass, ...update };
|
||||
},
|
||||
}
|
||||
: {};
|
||||
|
||||
const hass = provideHass(host, overrides);
|
||||
|
||||
hass.addEntities([
|
||||
{ entity_id: "light.kitchen", state: "on", attributes: {} },
|
||||
{ entity_id: "light.hallway", state: "off", attributes: {} },
|
||||
]);
|
||||
|
||||
return hass;
|
||||
};
|
||||
|
||||
const subscribe = async (hass: MockHomeAssistant, condition: Condition) => {
|
||||
const messages: unknown[] = [];
|
||||
|
||||
await hass.connection.subscribeMessage(
|
||||
(message) => {
|
||||
messages.push(message);
|
||||
},
|
||||
{ type: "subscribe_condition", condition }
|
||||
);
|
||||
|
||||
return messages;
|
||||
};
|
||||
|
||||
const kitchenOn: Condition = {
|
||||
condition: "state",
|
||||
entity_id: "light.kitchen",
|
||||
state: "on",
|
||||
};
|
||||
|
||||
const hallwayOn: Condition = {
|
||||
condition: "state",
|
||||
entity_id: "light.hallway",
|
||||
state: "on",
|
||||
};
|
||||
|
||||
describe("subscribe_condition in the mock backend", () => {
|
||||
it.each([
|
||||
["its own", false],
|
||||
["the host's", true],
|
||||
])(
|
||||
"checks a condition again when a state changes, with %s updateHass",
|
||||
async (_name, ownUpdateHass) => {
|
||||
const hass = setup(ownUpdateHass);
|
||||
const messages = await subscribe(hass, hallwayOn);
|
||||
|
||||
hass.addEntities({
|
||||
entity_id: "light.hallway",
|
||||
state: "on",
|
||||
attributes: {},
|
||||
});
|
||||
|
||||
expect(messages).toEqual([{ result: false }, { result: true }]);
|
||||
}
|
||||
);
|
||||
|
||||
it("passes a not only when none of its conditions pass, as in Core", async () => {
|
||||
const hass = setup();
|
||||
|
||||
expect(
|
||||
await subscribe(hass, {
|
||||
condition: "not",
|
||||
conditions: [kitchenOn, hallwayOn],
|
||||
})
|
||||
).toEqual([{ result: false }]);
|
||||
});
|
||||
|
||||
it("skips disabled conditions", async () => {
|
||||
const hass = setup();
|
||||
|
||||
expect(
|
||||
await subscribe(hass, {
|
||||
condition: "and",
|
||||
conditions: [kitchenOn, { ...hallwayOn, enabled: false }],
|
||||
})
|
||||
).toEqual([{ result: true }]);
|
||||
});
|
||||
|
||||
it("answers a not around a template with an error", async () => {
|
||||
const hass = setup();
|
||||
|
||||
const [message] = await subscribe(hass, {
|
||||
condition: "not",
|
||||
conditions: [{ condition: "template", value_template: "{{ true }}" }],
|
||||
});
|
||||
|
||||
expect(message).toHaveProperty("error");
|
||||
});
|
||||
});
|
||||
@@ -43,10 +43,6 @@ vi.mock("../../../../src/components/ha-button", () => {
|
||||
customElements.define("ha-button", class extends HTMLElement {});
|
||||
return {};
|
||||
});
|
||||
vi.mock("../../../../src/components/chips/ha-assist-chip", () => {
|
||||
customElements.define("ha-assist-chip", class extends HTMLElement {});
|
||||
return {};
|
||||
});
|
||||
vi.mock("../../../../src/components/ha-icon-button", () => {
|
||||
customElements.define("ha-icon-button", class extends HTMLElement {});
|
||||
return {};
|
||||
|
||||
Reference in new issue
Block a user