Compare commits

..
Author SHA1 Message Date
Bram Kragten 14034dda2d Bumped version to 20261125.2 2026-11-30 17:28:43 +01:00
Paul Bottein 47582923aa Keep the camera stream details in sync with the player (#56286) 2026-11-30 17:26:26 +01:00
WendelinandClaude Opus 5.5 75555390a1 Keep MJPEG picture in picture updating in Firefox (#56282)
Firefox only draws the first frame of an MJPEG image into a canvas, so
the picture in picture video froze. A bitmap of the image has the
current frame.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 17:26:25 +01:00
WendelinandClaude Opus 5.5 9e39b72de4 Show a placeholder instead of a broken image for cameras (#56271)
* Show a placeholder instead of a broken image for cameras

Picture cards show the camera placeholder instead of the broken image
when the camera is unavailable or its picture fails to load, and stop
requesting pictures while the camera is unavailable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Show the camera placeholder when a live MJPEG picture fails

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 17:26:24 +01:00
WendelinandClaude Opus 5.5 2ae815f1fd Simplify the camera stream badge and handle unavailable cameras (#56270)
* Simplify the camera stream badge and handle unavailable cameras

The badge only shows the state of the stream: Live, Connecting,
Unavailable or Disconnected. The protocol stays in the connection dialog.

Unavailable cameras don't start a stream. The player and the picture
cards show a camera-off placeholder instead of a broken image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move the picture card placeholder to its own pull request

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep the unavailable placeholder while Home Assistant is disconnected

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Skip the camera capabilities while unavailable and explain Disconnected

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 17:26:22 +01:00
Marcin BauerandClaude Fable 5.2 92045529e2 Replace brand titles in All brands with the brand name on each card (#56262)
Co-authored-by: Claude Fable 5.2 <[email protected]>
2026-11-30 17:26:21 +01:00
Jonathan DilksandClaude Opus 5.5 baaf5d1503 Fix pause button size in narrow media control card (#56256)
A missing comma in the narrow-layout selector meant the pause and stop
buttons never got the larger play-button size, so the card changed
height when switching between play and pause.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 17:26:19 +01:00
39b5f62cdb Use Marketplace icons for app install and uninstall (#56231)
The app info page now uses the same icons as the Marketplace:
mdiDownload for install and mdiDelete for uninstall. The previous
install icon filled its whole box and looked too large on the button.

Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 17:26:17 +01:00
Petar Petrov 77f2230f9b Open more-info from energy meter suggestion names (#56226)
* Open more-info from energy meter suggestion names

* Type the more-info handler's current target
2026-11-30 17:26:16 +01:00
darkrain-nl 2cab493aaa Keep the startup progress in view while the list scrolls (#56213) 2026-11-30 17:26:15 +01:00
darkrain-nl c024b4594a Keep the startup details dialog at a fixed height (#56209) 2026-11-30 17:26:14 +01:00
Lazizbek Ergashev b76650cb55 Show Home Assistant Link as the title of the signed out Link page (#56205) 2026-11-30 17:26:12 +01:00
Petar Petrov eae1d81471 Show the device tooltip when hovering a name in the energy devices chart (#56200) 2026-11-30 17:26:11 +01:00
Paul Bottein 99b9f2593c Fill the mobile more info with the camera picture (#56199)
* Fill the mobile more info with the camera picture

* Use the dialog's own mode for the camera fill
2026-11-30 17:26:09 +01:00
Petar Petrov 43b6d8a0ea Add a Dismiss all button to energy meter suggestions (#56198) 2026-11-30 17:26:08 +01:00
Lazizbek Ergashev caccbf3c59 Only add the entity name to energy devices when it tells them apart (#56192)
* Only add the entity name to energy devices when it tells them apart

* Keep entity names for same-named devices with several meters

* Keep entity names when a custom name shares the device label
2026-11-30 17:26:06 +01:00
e5f408fca0 Show wake word names in the voice setup wizard (#56035)
* Show wake word names in the voice setup wizard

The migration to ha-list-item-button left the wake word phrase in the
default slot, which ha-row-item does not render, so the "Change wake
word" step showed empty rows. Put the phrase in the headline slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Remove wake word step test

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Paul Bottein <[email protected]>
2026-11-30 17:26:05 +01:00
Bram Kragten 1c70897226 Bumped version to 20261125.1 2026-11-26 17:24:46 +01:00
WendelinandClaude Opus 5.5 3a27de8e0a Load Marketplace category icons only when they are shown (#56185)
The repository page loaded the integration category icons for every
repository, also for ones without integration categories. Load them once
a shown repository has categories, and only once per page.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:04:15 +01:00
WendelinandClaude Opus 5.5 bc21f2903d Only offer the tab's categories in the Marketplace filter (#56183)
The integration category filter offered every category on every tab, so
on the installed tab a category nothing installed is in emptied the
table. It now lists the categories of the tab's repositories, and a
category picked on another tab that this one doesn't list is left out
here but kept for that tab, like statuses.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:04:15 +01:00
WendelinandClaude Opus 5.5 b067ce5515 Remove two marketplace tests that only cover helpers (#56184)
Follow-up to #55130 review: the empty integration_category link test only
covered the query param decoder, and the filtersOfTab category test only
covered a spread.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:04:15 +01:00
Paul Bottein c95ed9f16c Swipe to open or close the tilt of tilt-only covers (#56182) 2026-11-26 17:01:38 +01:00
Paul Bottein 95eb2641e2 Fix rows value bubble cut off in the card size editor (#56181) 2026-11-26 17:01:36 +01:00
Bram KragtenandClaude Opus 5.5 4cb23b772a Draw the slats of tilt-only covers from their state (#56173)
* Draw the slats of tilt-only covers from their state

A tilt-only cover that only reports open or closed, without a tilt
position, was always drawn with half open slats. When the cover can't
move up or down, its state describes the slats, so draw them at the
closed tilt position when closed and at the open tilt position when
open. Covers that also move up and down keep the neutral slats, as
their state describes the position.

Add tilt-only blinds, open and closed, to the cover more-info gallery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Draw the slats from the state with the default tilt positions

Core only sends the open and closed tilt positions of covers that can
set their tilt position, so a tilt-only cover drawn from its state
always uses 0 and 100.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:01:35 +01:00
WendelinandClaude Opus 5.5 0bf5da2e09 Fix the Bluetooth adapter count on the dashboard (#56165)
* Fix the Bluetooth adapter count on the dashboard

The dashboard counted every bluetooth config entry that isn't disabled,
including ignored discoveries and entries without an adapter device, so
it could show more adapters than the adapters page lists. Move the
adapters page logic to a shared getBluetoothAdapters() helper and count
its enabled adapters on the dashboard. The count waits for the device
registry to load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Show skeletons while the Bluetooth adapters load

Don't report zero adapters and an offline network before the config
entries and the device registry have loaded. Add tests for the shared
adapter selection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Show an error with retry when the Bluetooth config entries fail to load

Otherwise the dashboard would keep showing its loading skeletons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep the Bluetooth adapters link named while it loads

A skeleton in the link made its accessible name only "Loading". Show
"Bluetooth adapters" until the count is known instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:01:34 +01:00
Erwin Douna c12ad32797 Restore dismissed energy meter suggestions (#56156)
* Restore dismissed energy meter suggestions

* Use a toolbar menu for dismissed meter suggestions and fix save races
2026-11-26 17:01:33 +01:00
2c03c2d74a Show Home Assistant Link label on WebRTC in camera stream info (#56153)
* Show Home Assistant Link label on WebRTC in camera stream info

The camera stream info dialog labels the WebRTC row with
"Enhanced by Home Assistant Link" when the cloud TURN servers are in
use. The dialog reads cloud/status and uses the same check as core:
logged in, active subscription, and cloud_ice_servers_enabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Wrap the Home Assistant Link tag on narrow screens

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:01:31 +01:00
darkrain-nl 2705e6da51 2026.12 beta - Fix add integration search focus (#56151)
* Focus autofocus elements slotted into an adaptive dialog

* Test focusing autofocus elements slotted into a dialog
2026-11-26 17:01:30 +01:00
Martin Salinas e3871d47de Give the tile icon's action its whole 48px area again (#56150)
* Give the tile icon's action its whole 48px area again

The tile container pads the icon by 6px so it is a 48px target, but the action handler was bound to the 36px circle inside it. A tap on that ring, around the circle or on a badge landed on the icon's host, which had no handler, and the container stopped it before the card's handler. Bind the action handler to the host instead.

* Let taps on the tile icon's badge reach the icon

With the action handler on the host, a tap on a badge in the default slot had the badge as its target, so a double tap across the badge and the rest of the icon fired two taps.

* Show the pointer cursor over the tile icon's whole area
2026-11-26 17:01:29 +01:00
Paul Bottein ead8c01926 Fix integration names and toast overlap in startup details (#56147)
* Fix integration names and toast overlap in startup details

* Track startup details opened from the completion toast
2026-11-26 17:01:28 +01:00
Paul Bottein 258cb6f8b9 Show the connection error when logged out and the server is offline (#56139)
* Show the connection error when logged out and the server is offline

* Show the connection error when the server responds with a 5xx

* Time out the server check before the login redirect

* Give the server check 10 seconds
2026-11-26 17:01:26 +01:00
Matthias de BaatandClaude Opus 5.5 72057cf504 Show when backup retention is paused for a location (#56088)
Automatic backup retention no longer deletes backups from locations
that are turned off for automatic backups (home-assistant/core#192788).
Show "Retention paused" in the locations list and an info alert on the
location page for those locations.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 17:01:25 +01:00
62 changed files with 1454 additions and 1742 deletions

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.
+1 -1
View File
@@ -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.
+8 -8
View File
@@ -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]':
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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
+1 -2
View File
@@ -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
+7 -1
View File
@@ -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.
+19 -19
View File
@@ -43,15 +43,15 @@
"@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.0.3",
@@ -64,7 +64,7 @@
"@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",
@@ -109,8 +109,8 @@
"lit": "3.3.3",
"lit-html": "3.3.3",
"maplibre-gl": "6.19.0",
"marked": "18.3.0",
"memoize-one": "7.0.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",
@@ -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"
+1 -1
View File
@@ -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"
}
+594 -684
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -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
View File
@@ -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
View File
@@ -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",
@@ -0,0 +1,33 @@
import { mdiVideoOffOutline } from "@mdi/js";
import { css, html, LitElement } from "lit";
import { customElement } from "lit/decorators";
import "../ha-svg-icon";
/**
* @element ha-camera-placeholder
*
* @summary Shows instead of a camera's picture when there is none, like
* while the camera is unavailable.
*/
@customElement("ha-camera-placeholder")
export class HaCameraPlaceholder extends LitElement {
protected render() {
return html`<ha-svg-icon .path=${mdiVideoOffOutline}></ha-svg-icon>`;
}
static styles = css`
:host {
display: flex;
align-items: center;
justify-content: center;
color: var(--secondary-text-color);
--mdc-icon-size: 40px;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"ha-camera-placeholder": HaCameraPlaceholder;
}
}
+110 -18
View File
@@ -22,12 +22,16 @@ import type { LocalizeFunc } from "../../common/translations/localize";
import { nextRender } from "../../common/util/render-status";
import type { CameraCapabilities, CameraEntity } from "../../data/camera";
import type { CameraStreamStatus } from "../../data/camera-streams";
import { showCameraStreamInfoDialog } from "../../dialogs/camera/show-dialog-camera-stream-info";
import {
showCameraStreamInfoDialog,
type CameraStreamInfo,
} from "../../dialogs/camera/show-dialog-camera-stream-info";
import "../ha-camera-stream";
import type { HaCameraStream } from "../ha-camera-stream";
import "../ha-icon-button";
import "../ha-spinner";
import "../ha-svg-icon";
import "./ha-camera-placeholder";
import "./ha-camera-stream-badge";
import {
fitPicture,
@@ -97,6 +101,9 @@ export class HaCameraPlayer extends LitElement {
@property({ type: Boolean, attribute: "keep-awake" })
public keepAwake = false;
/** Fills the height it is given, with the picture in the middle. */
@property({ type: Boolean, reflect: true }) public fill = false;
@state() private _status: CameraStreamStatus = {
connecting: true,
hasAudio: false,
@@ -104,6 +111,8 @@ export class HaCameraPlayer extends LitElement {
@state() private _capabilities?: CameraCapabilities;
private _streamInfoCallbacks = new Set<(info: CameraStreamInfo) => void>();
@state() private _video?: HTMLVideoElement;
@state() private _muted = false;
@@ -209,6 +218,7 @@ export class HaCameraPlayer extends LitElement {
);
clearTimeout(this._controlsTimeout);
clearTimeout(this._wheelHintTimeout);
this._streamInfoCallbacks.clear();
this._unbindVideo(this._video);
this._video = undefined;
this._pointers.clear();
@@ -235,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) {
@@ -248,6 +258,10 @@ export class HaCameraPlayer extends LitElement {
this._unbindVideo(changedProps.get("_video") as HTMLVideoElement);
this._bindVideo(this._video);
}
if (changedProps.has("_status") || changedProps.has("_capabilities")) {
const info = this._streamInfo();
this._streamInfoCallbacks.forEach((callback) => callback(info));
}
}
protected render() {
@@ -259,11 +273,12 @@ export class HaCameraPlayer extends LitElement {
// controls and zoom of this one can't reach, so it shows just the stream
const inApp = Boolean(status.inApp);
const zoomed = !inApp && isZoomed(this._zoom);
// Stays while the connection changes, so the user sees what happens
// Stays while not live, so the user sees what happens
const badgeVisible =
this._controlsVisible ||
status.connecting ||
status.upgrading !== undefined;
Boolean(status.unavailable) ||
Boolean(status.disconnected);
return html`
<div
@@ -284,9 +299,10 @@ export class HaCameraPlayer extends LitElement {
gesture: this._gesture,
})}
style=${styleMap({
aspectRatio: this._fullscreen
? undefined
: String(this._aspectRatio()),
aspectRatio:
this._fullscreen || this.fill
? undefined
: String(this._aspectRatio()),
})}
@pointerdown=${this._pointerDown}
@pointerup=${this._pointerUp}
@@ -303,6 +319,9 @@ export class HaCameraPlayer extends LitElement {
mjpeg-video
measure-poster
style=${styleMap({
"--picture-aspect-ratio": this.fill
? String(this._aspectRatio())
: undefined,
transform: zoomed
? `translate(${this._zoom.x}px, ${this._zoom.y}px) scale(${this._zoom.scale})`
: undefined,
@@ -312,6 +331,11 @@ export class HaCameraPlayer extends LitElement {
@camera-capabilities-changed=${this._capabilitiesChanged}
@camera-poster-size-changed=${this._posterSizeChanged}
></ha-camera-stream>
${
status.unavailable
? html`<ha-camera-placeholder></ha-camera-placeholder>`
: nothing
}
</div>
${inApp ? nothing : this._renderControls(status, zoomed, badgeVisible)}
</div>
@@ -325,7 +349,10 @@ export class HaCameraPlayer extends LitElement {
) {
return html`
${
this._paused && !status.connecting
this._paused &&
!status.connecting &&
!status.unavailable &&
!status.disconnected
? html`<ha-icon-button
class="control pinned play"
.label=${this._localize("ui.components.camera-player.play")}
@@ -536,15 +563,21 @@ export class HaCameraPlayer extends LitElement {
) {
const oldStatus = this._status;
this._status = ev.detail;
if (ev.detail.inApp) {
if (ev.detail.inApp || ev.detail.unavailable) {
this._zoom = ZOOM_PAN_IDENTITY;
}
if (
oldStatus.connecting !== ev.detail.connecting ||
oldStatus.unavailable !== ev.detail.unavailable ||
oldStatus.disconnected !== ev.detail.disconnected
) {
// Shows the new state for a moment
this._showControls();
}
if (
oldStatus.connecting !== ev.detail.connecting ||
oldStatus.type !== ev.detail.type
) {
// Shows the new connection for a moment
this._showControls();
this._updateVideo();
}
}
@@ -579,10 +612,26 @@ export class HaCameraPlayer extends LitElement {
this._posterSize = ev.detail.size;
}
private _showStreamInfo() {
showCameraStreamInfoDialog(this, {
private _streamInfo(): CameraStreamInfo {
return {
status: this._status,
supportedTypes: this._capabilities?.frontend_stream_types,
};
}
private _subscribeStreamInfo = (
callback: (info: CameraStreamInfo) => void
) => {
this._streamInfoCallbacks.add(callback);
callback(this._streamInfo());
return () => {
this._streamInfoCallbacks.delete(callback);
};
};
private _showStreamInfo() {
showCameraStreamInfoDialog(this, {
subscribe: this._subscribeStreamInfo,
});
}
@@ -813,12 +862,17 @@ export class HaCameraPlayer extends LitElement {
this._zoom = refitZoomPan(this._zoom, oldViewport, viewport);
};
// The app's own player and a camera without picture can't be zoomed
private _canZoom(): boolean {
return !this._status.inApp && !this._status.unavailable;
}
private _resetZoom() {
this._zoom = ZOOM_PAN_IDENTITY;
}
private _wheel(ev: WheelEvent) {
if (!this._viewport || this._status.inApp) {
if (!this._viewport || !this._canZoom()) {
return;
}
// A pinch on a touchpad scrolls with ctrl held
@@ -862,7 +916,7 @@ export class HaCameraPlayer extends LitElement {
}
private _doubleClick(ev: MouseEvent) {
if (!this._viewport || this._status.inApp) {
if (!this._viewport || !this._canZoom()) {
return;
}
if (isZoomed(this._zoom)) {
@@ -905,7 +959,8 @@ export class HaCameraPlayer extends LitElement {
this._showControls();
}
const pointer = this._pointers.get(ev.pointerId);
if (!pointer || !this._viewport) {
// Taps still toggle the controls when the picture can't be zoomed
if (!pointer || !this._viewport || !this._canZoom()) {
return;
}
const { rect, viewport } = this._measureViewport();
@@ -1030,6 +1085,38 @@ export class HaCameraPlayer extends LitElement {
cursor: none;
}
:host([fill]) {
position: relative;
flex: 1;
min-height: 0;
}
:host([fill]) .player {
position: absolute;
inset: 0;
}
:host([fill]) .viewport {
height: 100%;
max-height: none;
container-type: size;
--video-max-height: 100%;
}
/* As large as the picture fits in the middle, zoomed from the corner of
the viewport like a stream that fills it */
:host([fill]) ha-camera-stream {
--picture-width: min(100cqw, 100cqh * var(--picture-aspect-ratio));
--picture-height: min(100cqh, 100cqw / var(--picture-aspect-ratio));
position: absolute;
top: calc((100cqh - var(--picture-height)) / 2);
left: calc((100cqw - var(--picture-width)) / 2);
width: var(--picture-width);
height: var(--picture-height);
transform-origin: calc((var(--picture-width) - 100cqw) / 2)
calc((var(--picture-height) - 100cqh) / 2);
}
.viewport {
position: relative;
overflow: hidden;
@@ -1067,6 +1154,12 @@ export class HaCameraPlayer extends LitElement {
transition: transform var(--ha-animation-duration-fast) ease-out;
}
ha-camera-placeholder {
position: absolute;
inset: 0;
color: rgba(255, 255, 255, 0.5);
}
.viewport.gesture ha-camera-stream {
transition: none;
will-change: transform;
@@ -1189,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 };
}
}
+24 -51
View File
@@ -6,7 +6,6 @@ import type {
CameraStreamStatus,
CameraStreamType,
} from "../../data/camera-streams";
import "../ha-spinner";
/** Names of the protocols, the same in every language. */
export const CAMERA_STREAM_TYPE_NAMES: Record<CameraStreamType, string> = {
@@ -16,8 +15,10 @@ export const CAMERA_STREAM_TYPE_NAMES: Record<CameraStreamType, string> = {
};
/**
* Shows over a camera stream how it is connected. A faster stream that still
* connects in the background is shown next to the current one.
* @element ha-camera-stream-badge
*
* @summary Shows over a camera stream whether it is live. Selecting it
* shows how it is connected.
*/
@customElement("ha-camera-stream-badge")
export class HaCameraStreamBadge extends LitElement {
@@ -32,51 +33,27 @@ export class HaCameraStreamBadge extends LitElement {
if (!status) {
return nothing;
}
const connecting = status.connecting || !status.type;
const label = connecting
? this._localize("ui.components.camera-player.connecting")
: CAMERA_STREAM_TYPE_NAMES[status.type!];
const connection = status.disconnected
? "disconnected"
: status.unavailable
? "unavailable"
: status.connecting || !status.type
? "connecting"
: "live";
return html`
<button
type="button"
aria-label=${this._ariaLabel(status)}
class=${connecting ? "connecting" : "live"}
>
<button type="button" class=${connection} aria-describedby="details">
<span class="dot"></span>
<span class="label">${label}</span>
${
status.upgrading
? html`<span class="upgrading" aria-hidden="true">
<ha-spinner></ha-spinner>
${CAMERA_STREAM_TYPE_NAMES[status.upgrading]}
</span>`
: nothing
}
<span class="label"
>${this._localize(`ui.components.camera-player.${connection}`)}</span
>
</button>
<span id="details" hidden
>${this._localize("ui.components.camera-player.show_details")}</span
>
`;
}
private _ariaLabel(status: CameraStreamStatus): string {
if (status.connecting || !status.type) {
return this._localize(
"ui.components.camera-player.stream_info_connecting"
);
}
if (status.upgrading) {
return this._localize(
"ui.components.camera-player.stream_info_upgrading",
{
type: CAMERA_STREAM_TYPE_NAMES[status.type],
upgrading: CAMERA_STREAM_TYPE_NAMES[status.upgrading],
}
);
}
return this._localize("ui.components.camera-player.stream_info", {
type: CAMERA_STREAM_TYPE_NAMES[status.type],
});
}
static styles = css`
:host {
display: inline-flex;
@@ -120,16 +97,12 @@ export class HaCameraStreamBadge extends LitElement {
animation: pulse 1.2s ease-in-out infinite;
}
.upgrading {
display: inline-flex;
align-items: center;
gap: var(--ha-space-1);
padding-inline-start: var(--ha-space-1);
border-inline-start: 1px solid rgba(255, 255, 255, 0.3);
opacity: 0.7;
--ha-spinner-indicator-color: var(--ha-color-white);
--ha-spinner-size: 10px;
--ha-spinner-divider-color: rgba(255, 255, 255, 0.3);
.unavailable .dot {
background-color: rgba(255, 255, 255, 0.5);
}
.disconnected .dot {
background-color: var(--ha-color-red-60);
}
@keyframes pulse {
@@ -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";
+8 -2
View File
@@ -1,5 +1,6 @@
import { mdiClose } from "@mdi/js";
import type { ContextType } from "@lit/context";
import { createContext, provide } from "@lit/context";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { consume } from "../common/decorators/consume";
@@ -11,7 +12,10 @@ import "./ha-icon-button";
import "./ha-dialog";
import type { DialogWidth } from "./ha-dialog";
type DialogSheetMode = "dialog" | "bottom-sheet";
export type DialogSheetMode = "dialog" | "bottom-sheet";
export const adaptiveDialogModeContext =
createContext<DialogSheetMode>("adaptiveDialogMode");
export const ADAPTIVE_DIALOG_MEDIA_QUERY =
"(max-width: 870px), (max-height: 500px)";
@@ -125,7 +129,9 @@ export class HaAdaptiveDialog extends LitElement {
@property({ type: Boolean, reflect: true, attribute: "flexcontent" })
public flexContent = false;
@state() public mode: DialogSheetMode = "dialog";
@provide({ context: adaptiveDialogModeContext })
@state()
public mode: DialogSheetMode = "dialog";
@state()
@consume({ context: internationalizationContext, subscribe: true })
+116 -17
View File
@@ -34,6 +34,8 @@ import {
connectionContext,
formattersContext,
} from "../data/context";
import { UNAVAILABLE } from "../data/entity/entity";
import "./camera/ha-camera-placeholder";
import "./ha-hls-player";
import type { HaHLSPlayer } from "./ha-hls-player";
import "./ha-mjpeg-player";
@@ -111,6 +113,13 @@ export class HaCameraStream extends LitElement {
// The app plays the HLS stream in its own player, over the page
@state() private _hlsInApp = false;
// WebRTC is the only stream and failed, its player shows why
@state() private _webRtcFailed = false;
// The MJPEG image failed, it is tried again with the next access token or
// once Home Assistant reconnects
@state() private _mjpegImageFailed = false;
@query("ha-web-rtc-player") private _webRtcPlayer?: HaWebRtcPlayer;
@query("ha-mjpeg-player") private _mjpegPlayer?: HaMjpegPlayer;
@@ -153,9 +162,32 @@ export class HaCameraStream extends LitElement {
this._config.config.state === STATE_RUNNING &&
oldConfig.config?.state !== STATE_RUNNING;
if (entityChanged || backendStarted) {
this._getCapabilities();
this._getPosterUrl();
const oldStateObj = changedProps.get("stateObj") as
CameraEntity | undefined;
const becameAvailable =
!entityChanged &&
this.stateObj !== undefined &&
oldStateObj?.state === UNAVAILABLE &&
!this._unavailable;
if (entityChanged || backendStarted || becameAvailable) {
if (this._unavailable) {
// Core often doesn't know the camera then, as its integration
// didn't load. Its capabilities are fetched once it is back.
this._clearCapabilities();
} else {
this._getCapabilities();
this._getPosterUrl();
}
}
if (
oldStateObj &&
oldStateObj.attributes.access_token !==
this.stateObj?.attributes.access_token
) {
// A new token gives a new MJPEG address, worth another try
this._mjpegImageFailed = false;
}
const oldConnection = changedProps.get("_connection") as
@@ -170,6 +202,10 @@ export class HaCameraStream extends LitElement {
}
}
private get _unavailable(): boolean {
return this.stateObj?.state === UNAVAILABLE;
}
/** The microphone track sent to the camera, only on WebRTC streams. */
public get microphoneTrack(): MediaStreamTrack | undefined {
return this._webRtcPlayer?.microphoneTrack;
@@ -238,29 +274,63 @@ export class HaCameraStream extends LitElement {
this._visibleStreamType = visibleStreamType;
fireEvent(this, "stream-type-changed", { type: visibleStreamType });
}
const status: CameraStreamStatus = {
...computeCameraStreamStatus(
streams,
// Nothing plays while Home Assistant is disconnected
this._connection.connected ? this._loadedStreams : new Set(),
this._hlsStreams,
this._webRtcStreams
),
inApp: visibleStreamType === STREAM_TYPE_HLS && this._hlsInApp,
};
const status = this._computeStatus(streams, visibleStreamType);
if (
!this._status ||
status.type !== this._status.type ||
status.connecting !== this._status.connecting ||
status.upgrading !== this._status.upgrading ||
status.hasAudio !== this._status.hasAudio ||
status.inApp !== this._status.inApp
status.inApp !== this._status.inApp ||
status.unavailable !== this._status.unavailable ||
status.disconnected !== this._status.disconnected
) {
this._status = status;
fireEvent(this, "camera-stream-status-changed", status);
}
}
private _computeStatus(
streams: CameraStream[],
visibleStreamType?: CameraStreamType
): CameraStreamStatus {
// A playing WebRTC stream can come straight from the camera or an
// external go2rtc, it then keeps playing without Home Assistant
const playsWithoutHomeAssistant =
visibleStreamType === STREAM_TYPE_WEB_RTC &&
this._loadedStreams.has(STREAM_TYPE_WEB_RTC);
const inApp = visibleStreamType === STREAM_TYPE_HLS && this._hlsInApp;
if (!this._connection.connected && !playsWithoutHomeAssistant) {
// Kept so the player still shows its placeholder instead of nothing
return {
connecting: false,
hasAudio: false,
inApp,
disconnected: "home_assistant",
unavailable: this._unavailable,
};
}
if (this._unavailable) {
return { connecting: false, hasAudio: false, unavailable: true };
}
if (this._webRtcFailed) {
return {
connecting: false,
hasAudio: false,
disconnected: "stream_failed",
};
}
return {
...computeCameraStreamStatus(
streams,
this._loadedStreams,
this._hlsStreams,
this._webRtcStreams
),
inApp,
};
}
protected render() {
if (!this.stateObj) {
return nothing;
@@ -297,6 +367,11 @@ export class HaCameraStream extends LitElement {
@load=${this._handleMjpegLoad}
></ha-mjpeg-player>`;
}
if (this._mjpegImageFailed) {
return html`<ha-camera-placeholder
style=${styleMap({ aspectRatio: this.aspectRatio ?? 16 / 9 })}
></ha-camera-placeholder>`;
}
return html`<img
.src=${streamUrl}
style=${styleMap({
@@ -305,6 +380,7 @@ export class HaCameraStream extends LitElement {
})}
alt=${`Preview of the ${this._formatters?.formatEntityName(this.stateObj) ?? ""} camera.`}
@load=${this._handleImageLoad}
@error=${this._handleImageError}
/>`;
}
@@ -346,6 +422,9 @@ export class HaCameraStream extends LitElement {
}
private _currentStreams() {
if (this._unavailable) {
return [];
}
return this._streams(
this._capabilities?.frontend_stream_types,
this._hlsStreams,
@@ -353,10 +432,15 @@ export class HaCameraStream extends LitElement {
);
}
private async _getCapabilities() {
/** Returns the request number, so an older request can be dropped. */
private _clearCapabilities() {
this._capabilities = undefined;
this._resetStreams();
const request = ++this._capabilitiesRequest;
return ++this._capabilitiesRequest;
}
private async _getCapabilities() {
const request = this._clearCapabilities();
if (!supportsFeature(this.stateObj!, CameraEntityFeature.STREAM)) {
this._capabilities = {
frontend_stream_types: [],
@@ -379,11 +463,14 @@ export class HaCameraStream extends LitElement {
this._webRtcStreams = undefined;
this._loadedStreams = new Set();
this._hlsInApp = false;
this._webRtcFailed = false;
this._mjpegImageFailed = false;
this._mjpegPlayer?.restart();
}
private _restartMjpeg() {
this._setLoaded(MJPEG_STREAM, false);
this._mjpegImageFailed = false;
this._mjpegPlayer?.restart();
}
@@ -443,6 +530,11 @@ export class HaCameraStream extends LitElement {
fireEvent(this, "load");
}
private _handleImageError() {
this._mjpegImageFailed = true;
this._setLoaded(MJPEG_STREAM, false);
}
private _handleMjpegLoad() {
this._setLoaded(MJPEG_STREAM, true);
}
@@ -458,6 +550,7 @@ export class HaCameraStream extends LitElement {
}
private _handleWebRtcLoad() {
this._webRtcFailed = false;
this._setLoaded(STREAM_TYPE_WEB_RTC, true);
}
@@ -477,6 +570,7 @@ export class HaCameraStream extends LitElement {
) {
// Without another stream type, keep the player to show why it failed.
// Only a browser without WebRTC falls back to MJPEG.
this._webRtcFailed = true;
this._setLoaded(STREAM_TYPE_WEB_RTC, false);
return;
}
@@ -510,10 +604,15 @@ export class HaCameraStream extends LitElement {
display: block;
}
img {
img,
ha-camera-placeholder {
width: 100%;
}
ha-camera-placeholder {
background-color: var(--ha-color-fill-neutral-normal-resting);
}
ha-web-rtc-player {
width: 100%;
height: 100%;
-4
View File
@@ -1939,10 +1939,6 @@ export class HaCodeEditor extends ReactiveElement {
padding-top: var(--code-editor-toolbar-height);
}
:host(.fullscreen) {
--code-mirror-min-height: 100%;
}
:host(.fullscreen) .cm-editor {
height: 100% !important;
max-height: 100% !important;
+9 -17
View File
@@ -179,10 +179,6 @@ export class HaControlCircularSlider extends LitElement {
disconnectedCallback(): void {
super.disconnectedCallback();
this._destroyListeners();
if (this._activeSlider) {
this._cancelInteraction();
}
}
private _managers: HammerManager[] = [];
@@ -252,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) => {
@@ -295,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 });
}
+1 -1
View File
@@ -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,
+30 -14
View File
@@ -42,6 +42,8 @@ export class HaMjpegPlayer extends LitElement {
private _drawInterval?: number;
private _copyingFrame = false;
/** The video for picture in picture, undefined when it can't be shown. */
public get videoElement(): HTMLVideoElement | undefined {
return this._canCopy ? this._videoEl : undefined;
@@ -66,12 +68,13 @@ export class HaMjpegPlayer extends LitElement {
}
try {
if (!this._stream) {
this._drawFrame();
// The canvas already has a frame from the copy test
this._copyFrame();
// Captures a frame whenever the canvas is drawn
this._stream = this._canvas!.captureStream();
video.srcObject = this._stream;
this._drawInterval = window.setInterval(
() => this._drawFrame(),
() => this._copyFrame(),
1000 / PICTURE_IN_PICTURE_FRAME_RATE
);
}
@@ -178,32 +181,45 @@ export class HaMjpegPlayer extends LitElement {
/** An image from another origin can't be copied out of a canvas. */
private _testCopy(): boolean {
const image = this._imageEl!;
try {
this._drawFrame();
this._canvas?.getContext("2d")?.getImageData(0, 0, 1, 1);
return Boolean(this._canvas);
this._drawFrame(image, image.naturalWidth, image.naturalHeight);
this._canvas!.getContext("2d")?.getImageData(0, 0, 1, 1);
return true;
} catch (_err: unknown) {
return false;
}
}
private _drawFrame() {
// Firefox only draws the first frame of an MJPEG image, a bitmap of it
// has the current one
private async _copyFrame() {
const image = this._imageEl;
if (!image?.naturalWidth) {
if (this._copyingFrame || !image?.naturalWidth) {
return;
}
this._copyingFrame = true;
try {
const bitmap = await createImageBitmap(image);
this._drawFrame(bitmap, bitmap.width, bitmap.height);
bitmap.close();
} catch (_err: unknown) {
// The stream is between frames or restarting, the next copy tries again
} finally {
this._copyingFrame = false;
}
}
private _drawFrame(frame: CanvasImageSource, width: number, height: number) {
if (!this._canvas) {
this._canvas = document.createElement("canvas");
}
const canvas = this._canvas;
if (
canvas.width !== image.naturalWidth ||
canvas.height !== image.naturalHeight
) {
canvas.width = image.naturalWidth;
canvas.height = image.naturalHeight;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
}
canvas.getContext("2d")?.drawImage(image, 0, 0);
canvas.getContext("2d")?.drawImage(frame, 0, 0);
}
private _stopVideo = () => {
+6
View File
@@ -79,6 +79,8 @@ export const selectCameraStreams = ({
];
};
export type CameraStreamDisconnectReason = "home_assistant" | "stream_failed";
/** What the player tells the user about the connection of its stream. */
export interface CameraStreamStatus {
/** The stream that is shown, undefined until the camera's types are known */
@@ -91,6 +93,10 @@ export interface CameraStreamStatus {
hasAudio: boolean;
/** The app plays the shown stream in its own player, over the page */
inApp?: boolean;
/** The camera is unavailable, no stream is started */
unavailable?: boolean;
/** Home Assistant is disconnected, or the only stream failed */
disconnected?: CameraStreamDisconnectReason;
}
export const computeCameraStreamStatus = (
-2
View File
@@ -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",
@@ -28,7 +28,10 @@ import { fetchCloudStatus } from "../../data/cloud";
import { apiContext, configContext } from "../../data/context";
import { haStyleDialog, haStyleDialogFixedTop } from "../../resources/styles";
import { DialogMixin } from "../dialog-mixin";
import type { CameraStreamInfoDialogParams } from "./show-dialog-camera-stream-info";
import type {
CameraStreamInfo,
CameraStreamInfoDialogParams,
} from "./show-dialog-camera-stream-info";
// Ordered from the fastest to the most compatible
const STREAM_TYPES: { type: CameraStreamType; icon: string }[] = [
@@ -53,6 +56,23 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
@state() private _cloudIceServers = false;
@state() private _info?: CameraStreamInfo;
private _unsubscribe?: () => void;
public connectedCallback() {
super.connectedCallback();
this._unsubscribe = this.params?.subscribe((info) => {
this._info = info;
});
}
public disconnectedCallback() {
this._unsubscribe?.();
this._unsubscribe = undefined;
super.disconnectedCallback();
}
protected firstUpdated() {
this._fetchCloudIceServers();
}
@@ -74,10 +94,10 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
}
protected render() {
if (!this.params) {
if (!this._info) {
return nothing;
}
const { status, supportedTypes } = this.params;
const { status, supportedTypes } = this._info;
// Without a video stream, still images are all the camera has
const stillImagesOnly = supportedTypes?.length === 0;
// MJPEG is only the fallback, only worth explaining while it shows
@@ -106,6 +126,22 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
: "ui.dialogs.camera_stream_info.intro"
)}
</p>
${
status.disconnected
? html`<ha-alert alert-type="error">
${this._localize(
`ui.dialogs.camera_stream_info.disconnected.${status.disconnected}`
)}
</ha-alert>`
: nothing
}
${
status.unavailable
? html`<ha-alert alert-type="warning">
${this._localize("ui.dialogs.camera_stream_info.unavailable")}
</ha-alert>`
: nothing
}
${
mjpegInUse && !stillImagesOnly
? html`<ha-alert alert-type="info">
@@ -145,7 +181,7 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
type: CameraStreamType;
icon: string;
}) {
const { status } = this.params!;
const { status } = this._info!;
const current = !status.connecting && status.type === type;
const upgrading = status.upgrading === type;
return html`
@@ -1,12 +1,17 @@
import { fireEvent } from "../../common/dom/fire_event";
import type { CameraStreamStatus, StreamType } from "../../data/camera-streams";
export interface CameraStreamInfoDialogParams {
export interface CameraStreamInfo {
status: CameraStreamStatus;
/** The stream types the camera supports, undefined while unknown */
supportedTypes?: StreamType[];
}
export interface CameraStreamInfoDialogParams {
/** Calls back with the current info right away and on every change */
subscribe: (callback: (info: CameraStreamInfo) => void) => () => void;
}
export const showCameraStreamInfoDialog = (
element: HTMLElement,
params: CameraStreamInfoDialogParams
+1 -1
View File
@@ -46,7 +46,7 @@ export const DOMAINS_WITH_NEW_MORE_INFO = [
"media_player",
];
/** Domains with full height more info dialog */
export const DOMAINS_FULL_HEIGHT_MORE_INFO = ["update"];
export const DOMAINS_FULL_HEIGHT_MORE_INFO = ["camera", "update"];
/** Domains with separate more info dialog. */
export const DOMAINS_WITH_MORE_INFO = [
@@ -9,6 +9,10 @@ import { consumeLocalize } from "../../../common/decorators/consume-context-entr
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { fireEvent } from "../../../common/dom/fire_event";
import type { LocalizeFunc } from "../../../common/translations/localize";
import {
adaptiveDialogModeContext,
type DialogSheetMode,
} from "../../../components/ha-adaptive-dialog";
import "../../../components/ha-button";
import "../../../components/camera/ha-camera-player";
import type { HaCameraPlayer } from "../../../components/camera/ha-camera-player";
@@ -50,6 +54,10 @@ class MoreInfoCamera extends LitElement {
@state() private _attached = false;
@state()
@consume({ context: adaptiveDialogModeContext, subscribe: true })
private _dialogMode?: DialogSheetMode;
@state() private _microphoneState: WebRtcMicrophoneState = "off";
@state() private _streamType?: CameraStreamType;
@@ -133,6 +141,7 @@ class MoreInfoCamera extends LitElement {
.stateObj=${this.stateObj}
allow-exoplayer
keep-awake
?fill=${this._dialogMode === "bottom-sheet"}
@microphone-changed=${this._microphoneChanged}
@stream-type-changed=${this._streamTypeChanged}
@camera-capabilities-changed=${this._capabilitiesChanged}
@@ -315,6 +324,10 @@ class MoreInfoCamera extends LitElement {
ev: HASSDomEvent<HASSDomEvents["stream-type-changed"]>
) {
this._streamType = ev.detail.type;
// A removed WebRTC player can't tell that its microphone stopped
if (ev.detail.type !== STREAM_TYPE_WEB_RTC && !this._useAppMicrophone) {
this._microphoneState = "off";
}
}
private _capabilitiesChanged(
@@ -334,7 +347,9 @@ class MoreInfoCamera extends LitElement {
static styles = css`
:host {
display: block;
display: flex;
flex-direction: column;
flex: 1;
}
.buttons {
@@ -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);
}
`;
}
+47 -69
View File
@@ -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;
+118 -32
View File
@@ -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}
>
@@ -44,7 +44,7 @@ export class HaVoiceAssistantSetupStepChangeWakeWord extends LitElement {
@click=${this._wakeWordPicked}
.value=${wakeWord.id}
>
${wakeWord.wake_word}
<div slot="headline">${wakeWord.wake_word}</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>`
)}
@@ -514,8 +514,16 @@ class AddIntegrationDialog extends LitElement {
return [...integrations]
.filter((item) => !brand || item.domain === brand)
.sort(byName)
.flatMap((item) => this._brandRows(item))
.filter((row) => !brand || !row.is_header);
.flatMap((item) =>
this._brandRows(item)
.filter((row) => !row.is_header)
// The brand on the second line, so its entries read as a group
.map((row) =>
brand || !this._isBrand(item)
? row
: { ...row, description: item.name }
)
);
}
// A brand shows its integrations here, not itself, like the website
if (category) {
@@ -1207,17 +1215,11 @@ class AddIntegrationDialog extends LitElement {
})}
>
${
!this._stickyBrand
? nothing
: this._filter
? html`<ha-section-title class="sticky">
${this._stickyBrand}
</ha-section-title>`
: html`<ha-integration-list-title
class="sticky raised"
>
${this._stickyBrand}
</ha-integration-list-title>`
this._stickyBrand
? html`<ha-section-title class="sticky">
${this._stickyBrand}
</ha-section-title>`
: nothing
}
<ha-list-virtualized
.rows=${this._filter ? rows : this._withEndSpace(rows)}
@@ -1771,7 +1773,7 @@ class AddIntegrationDialog extends LitElement {
);
}
// The virtualizer positions rows, so CSS sticky can't hold the brand
// The virtualizer positions rows, so CSS sticky can't hold the section title
@eventOptions({ passive: true })
private _visibilityChanged(ev: HASSDomEvent<HaListVisibilityChangedDetail>) {
const rows = this._getRows();
@@ -1794,11 +1796,7 @@ class AddIntegrationDialog extends LitElement {
return html`<div style="height: var(--ha-space-2)"></div>`;
}
if (integration.is_header) {
return this._filter
? html`<ha-section-title>${integration.name}</ha-section-title>`
: html`<ha-integration-list-title>
${integration.name}
</ha-integration-list-title>`;
return html`<ha-section-title>${integration.name}</ha-section-title>`;
}
return html`
<ha-integration-list-item
@@ -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,
@@ -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
+90 -63
View File
@@ -11,6 +11,7 @@ import type {
} from "../../../common/dom/fire_event";
import { computeDomain } from "../../../common/entity/compute_domain";
import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
import "../../../components/camera/ha-camera-placeholder";
import "../../../components/ha-camera-stream";
import type { HaCameraStream } from "../../../components/ha-camera-stream";
import "../../../components/ha-spinner";
@@ -135,6 +136,12 @@ export class HuiImage extends LitElement {
if (this._shouldStartCameraUpdates(oldHass)) {
this._startIntersectionObserver();
} else if (
this._cameraBecameAvailable(oldHass) &&
this._imageVisible &&
this.cameraView !== "live"
) {
this._updateCameraImageSrc();
} else if (!this.hass!.connected) {
this._stopUpdateCameraInterval();
this._stopIntersectionObserver();
@@ -264,6 +271,13 @@ export class HuiImage extends LitElement {
// Snapshots load only once the card is on screen; skip the spinner until then.
const showSpinner = !this.cameraImage || this._imageVisible;
const cameraUnavailable = this._cameraUnavailable();
const placeholderHeight = !useRatio
? this._lastImageHeight
? `${this._lastImageHeight}px`
: "100%"
: undefined;
return html`
<div
style=${styleMap({
@@ -288,71 +302,66 @@ export class HuiImage extends LitElement {
})}"
>
${
this.cameraImage && this.cameraView === "live"
? html`
<ha-camera-stream
muted
.stateObj=${cameraObj}
.fitMode=${this.fitMode}
.aspectRatio=${
this._ratio ? this._ratio.w / this._ratio.h : undefined
}
@load=${this._onVideoLoad}
></ha-camera-stream>
`
: imageSrc === undefined
? nothing
: html`
<img
id="image"
src=${this._reconnectImg ? nothing : live(imageSrc)}
alt=${this.entity || ""}
@error=${this._onImageError}
@load=${this._onImageLoad}
style=${styleMap({
display:
useRatio || this._loadState === LoadState.Loaded
? "block"
: "none",
})}
/>
cameraUnavailable
? nothing
: this.cameraImage && this.cameraView === "live"
? html`
<ha-camera-stream
muted
.stateObj=${cameraObj}
.fitMode=${this.fitMode}
.aspectRatio=${
this._ratio ? this._ratio.w / this._ratio.h : undefined
}
@load=${this._onVideoLoad}
></ha-camera-stream>
`
: imageSrc === undefined
? nothing
: html`
<img
id="image"
src=${this._reconnectImg ? nothing : live(imageSrc)}
alt=${this.entity || ""}
@error=${this._onImageError}
@load=${this._onImageLoad}
style=${styleMap({
display:
useRatio || this._loadState === LoadState.Loaded
? "block"
: "none",
})}
/>
`
}
${
this._loadState === LoadState.Error
? html`<div
id="brokenImage"
style=${styleMap({
height: !useRatio
? this._lastImageHeight
? `${this._lastImageHeight}px`
: "100%"
: undefined,
})}
></div>`
: this.cameraView !== "live" &&
(imageSrc === undefined ||
this._loadState === LoadState.Loading)
this.cameraImage &&
(cameraUnavailable || this._loadState === LoadState.Error)
? html`<ha-camera-placeholder
style=${styleMap({ height: placeholderHeight })}
></ha-camera-placeholder>`
: this._loadState === LoadState.Error
? html`<div
class="progress-container"
style=${styleMap({
height: !useRatio
? this._lastImageHeight
? `${this._lastImageHeight}px`
: "100%"
: undefined,
})}
>
${
showSpinner
? html`<ha-spinner
class="render-spinner"
size="small"
></ha-spinner>`
: nothing
}
</div>`
: ""
id="brokenImage"
style=${styleMap({ height: placeholderHeight })}
></div>`
: this.cameraView !== "live" &&
(imageSrc === undefined ||
this._loadState === LoadState.Loading)
? html`<div
class="progress-container"
style=${styleMap({ height: placeholderHeight })}
>
${
showSpinner
? html`<ha-spinner
class="render-spinner"
size="small"
></ha-spinner>`
: nothing
}
</div>`
: ""
}
</div>
`;
@@ -366,6 +375,18 @@ export class HuiImage extends LitElement {
);
}
private _cameraUnavailable(hass = this.hass): boolean {
return Boolean(
this.cameraImage && hass?.states[this.cameraImage]?.state === UNAVAILABLE
);
}
private _cameraBecameAvailable(oldHass?: HomeAssistant): boolean {
return Boolean(
oldHass && this._cameraUnavailable(oldHass) && !this._cameraUnavailable()
);
}
private _startIntersectionObserver(): void {
if (!this._intersectionObserver) {
this._intersectionObserver = new IntersectionObserver(
@@ -434,7 +455,8 @@ export class HuiImage extends LitElement {
}
private async _updateCameraImageSrc(): Promise<void> {
if (!this.hass || !this.cameraImage) {
// Its picture can't load, a placeholder shows instead
if (!this.hass || !this.cameraImage || this._cameraUnavailable()) {
return;
}
@@ -525,7 +547,8 @@ export class HuiImage extends LitElement {
}
.ratio img,
.ratio div {
.ratio div,
.ratio ha-camera-placeholder {
position: absolute;
top: 0;
left: 0;
@@ -537,6 +560,10 @@ export class HuiImage extends LitElement {
visibility: hidden;
}
ha-camera-placeholder {
background-color: var(--ha-color-fill-neutral-normal-resting);
}
#brokenImage {
background: grey url("/static/images/image-broken.svg") center/36px
no-repeat;
@@ -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",
@@ -1,14 +1,8 @@
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";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
import { fireEvent } from "../../../../common/dom/fire_event";
import { ctrlOrCmdLabel } from "../../../../common/keyboard/ctrl-or-cmd";
@@ -74,10 +68,6 @@ export class HuiDialogEditBadge
@state() private _open = false;
@state() private _animateWidth = false;
private _largeBeforeCodeEditor = false;
@state() private _badgeConfig?: LovelaceBadgeConfig;
@state() private _saving = false;
@@ -102,7 +92,6 @@ export class HuiDialogEditBadge
this._badgeConfig = params.badgeConfig;
this.large = false;
this._animateWidth = false;
if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) {
this._badgeConfig = deepFreeze(this._badgeConfig);
}
@@ -206,11 +195,6 @@ export class HuiDialogEditBadge
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": !this._GUImode,
})}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed}
@@ -221,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`
@@ -326,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) {
@@ -352,21 +326,11 @@ export class HuiDialogEditBadge
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
ev.stopPropagation();
// Fired again on every error while staying in the same mode
if (ev.detail.guiMode !== this._GUImode) {
if (ev.detail.guiMode) {
this.large = this._largeBeforeCodeEditor;
} else {
this._largeBeforeCodeEditor = this.large;
this.large = true;
}
}
this._GUImode = ev.detail.guiMode;
this._guiModeAvailable = ev.detail.guiModeAvailable;
}
private _toggleMode(): void {
this._animateWidth = true;
withViewTransition(() => {
this._badgeEditorEl?.toggleMode();
});
@@ -530,29 +494,8 @@ export class HuiDialogEditBadge
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
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,14 +1,8 @@
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";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one";
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
import { fireEvent } from "../../../../common/dom/fire_event";
@@ -82,10 +76,6 @@ export class HuiDialogEditCard
@state() private _open = false;
@state() private _animateWidth = false;
private _largeBeforeCodeEditor = false;
@state() private _cardConfig?: LovelaceCardConfig;
@state() private _sectionConfig?: LovelaceSectionConfig;
@@ -114,7 +104,6 @@ export class HuiDialogEditCard
this._cardConfig = params.cardConfig;
this.large = false;
this._animateWidth = false;
if (this._cardConfig && !Object.isFrozen(this._cardConfig)) {
this._cardConfig = deepFreeze(this._cardConfig);
}
@@ -218,11 +207,6 @@ export class HuiDialogEditCard
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": !this._GUImode,
})}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed}
@@ -233,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`
@@ -352,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) {
@@ -378,21 +352,11 @@ export class HuiDialogEditCard
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
ev.stopPropagation();
// Fired again on every error while staying in the same mode
if (ev.detail.guiMode !== this._GUImode) {
if (ev.detail.guiMode) {
this.large = this._largeBeforeCodeEditor;
} else {
this._largeBeforeCodeEditor = this.large;
this.large = true;
}
}
this._GUImode = ev.detail.guiMode;
this._guiModeAvailable = ev.detail.guiModeAvailable;
}
private _toggleMode(): void {
this._animateWidth = true;
withViewTransition(() => {
this._cardEditorEl?.toggleMode();
});
@@ -612,29 +576,8 @@ export class HuiDialogEditCard
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
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,13 +258,7 @@ export class HuiDialogEditSection
<ha-dialog
.open=${this._open}
.accessibleLabel=${heading}
.width=${this._yamlMode ? "full" : "large"}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": this._yamlMode,
})}
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}
@@ -281,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
@@ -461,7 +454,6 @@ export class HuiDialogEditSection
ev: ValueChangedEvent<LovelaceSectionRawConfig>
): void {
ev.stopPropagation();
this._animateWidth = true;
this._config = ev.detail.value;
this._updateDirtyState(this._config!);
}
@@ -502,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 {
@@ -532,7 +524,6 @@ export class HuiDialogEditSection
private async _toggleMode(): Promise<void> {
if (this._yamlMode && this._yamlError) return;
this._animateWidth = true;
await withViewTransition(() => {
this._yamlMode = !this._yamlMode;
});
@@ -746,29 +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)
);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
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 {
@@ -784,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;
@@ -849,36 +828,19 @@ export class HuiDialogEditSection
}
@media (min-width: 1000px) {
ha-dialog {
--editor-column-width: 520px;
/* Plus the paddings of the preview */
--preview-column-total-width: calc(var(--preview-width) + 28px);
--ha-dialog-width-lg: calc(
var(--editor-column-width) + var(--preview-column-total-width) +
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;
}
ha-dialog.yaml-mode .content > .element-editor {
flex: 1 0 var(--editor-column-width);
}
ha-dialog.yaml-mode .content > .element-preview {
box-sizing: border-box;
flex: 0 1 var(--preview-column-total-width);
max-width: 500px;
}
.content > .element-editor,
.content > .element-preview {
flex-basis: 0;
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
height: auto;
}
@@ -927,6 +889,9 @@ export class HuiDialogEditSection
margin-inline-end: auto;
margin-inline-start: initial;
}
.title-enlargeable {
display: block;
}
`,
];
}
@@ -90,8 +90,6 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
@state() private _open = false;
@state() private _animateWidth = false;
get _type(): string {
return getViewType(this._config);
}
@@ -138,7 +136,6 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
this._params = undefined;
this._config = {};
this._yamlMode = false;
this._animateWidth = false;
this._currTab = TABS[0];
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -213,12 +210,10 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
<ha-dialog
.open=${this._open}
.accessibleLabel=${this._viewConfigTitle}
.width=${this._yamlMode ? "full" : "large"}
width="large"
.preventScrimClose=${this.isDirtyState}
@closed=${this._dialogClosed}
@dialog-set-fullscreen=${this._stopWidthAnimation}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": this._yamlMode,
})}
>
@@ -370,13 +365,7 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
}
}
// The code editor's fullscreen changes the height at once, so the width must not lag behind
private _stopWidthAnimation() {
this._animateWidth = false;
}
private async _toggleMode() {
this._animateWidth = true;
this._yamlMode = !this._yamlMode;
if (this._yamlMode) {
await this.updateComplete;
@@ -691,29 +680,6 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
ha-dialog.yaml-mode {
--dialog-content-padding: 0;
}
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* 80px - margin of the dialog
137px - header and footer */
--code-mirror-max-height: calc(100vh - 217px);
}
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
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;
}
h2 {
margin: 0;
font-size: inherit;
@@ -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,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"
-5
View File
@@ -305,11 +305,6 @@ export const haTheme = EditorView.theme({
".cm-scroller": { outline: "none" },
// On these instead of the editor, so that the gutter grows along
".cm-content, .cm-gutter": {
minHeight: "var(--code-mirror-min-height, 100%)",
},
".cm-content": {
caretColor: "var(--secondary-text-color)",
paddingTop: "16px",
+10 -1
View File
@@ -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,
},
+10 -12
View File
@@ -1394,9 +1394,10 @@
"reset_zoom": "Reset zoom",
"zoom_hint": "Use {modifier} + scroll to zoom",
"connecting": "Connecting",
"stream_info": "Streaming with {type}. Show connection details",
"stream_info_connecting": "Connecting to the camera. Show connection details",
"stream_info_upgrading": "Streaming with {type}, connecting with {upgrading} in the background. Show connection details"
"live": "Live",
"unavailable": "[%key:state::default::unavailable%]",
"disconnected": "Disconnected",
"show_details": "Show connection details"
},
"web-rtc-player": {
"not_supported": "WebRTC is not supported in this browser.",
@@ -2422,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",
@@ -2854,6 +2855,11 @@
"intro": "Home Assistant starts with the connection that works most reliably and switches to a faster one as soon as it is ready.",
"still_images_only": "This camera has no video stream, so it shows a series of still images.",
"fallback_in_use": "The video streams of this camera could not be started, so still images are shown instead.",
"unavailable": "The camera is unavailable, so no stream can start. It connects again as soon as the camera is back.",
"disconnected": {
"home_assistant": "The connection to Home Assistant was lost, so the stream stopped. It starts again as soon as Home Assistant is reachable.",
"stream_failed": "WebRTC could not connect, and this camera has no other stream to fall back to. The player shows what went wrong."
},
"in_use": "In use",
"connecting": "Connecting",
"not_supported_count": "Not supported by this camera ({count})",
@@ -5794,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": {
@@ -10954,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",
@@ -11004,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%]",
@@ -12456,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%]",
@@ -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": [