Compare commits

..
89 Commits
Author SHA1 Message Date
Aidan Timson 9083641ae7 Let custom cards subscribe to visibility conditions (#56284)
* Let custom cards subscribe to visibility on any page

* Send the context entity to core-evaluated conditions
2026-11-30 18:12:32 +02:00
Rodrigo Roque 5fc4ad4e0c Highlight sidebar panels whose url_path has several segments (#56144) 2026-11-30 15:18:20 +00:00
Marcin BauerandClaude Fable 5.2 ba33d2897b 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 16:15:58 +01:00
Christian Wiedel 9484d51694 Flip dropdown menus away from safe areas (#56167)
Pass the safe-area insets to the popup's flip padding, so menus open on
the side with room instead of being squeezed against a navigation bar,
notch or home indicator.
2026-11-30 16:07:04 +01:00
Felipe Santos 55739f2666 Show which integrations use an integration and warn before deleting it (#56188) 2026-11-30 16:01:26 +01:00
Paul Bottein 483b8d1c76 Keep the camera stream details in sync with the player (#56286) 2026-11-30 15:50:41 +01:00
renovate[bot] f589ae2113 Update dependency maplibre-gl to v6.20.0 (#56281)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 15:36:06 +01:00
Maarten Lakerveld 1c01df1d6c Center cropped entity pictures in map markers (#56283)
Non-square entity pictures, such as the 16:9 vehicle renders from the
Skoda integration, were cropped from the top-left corner because the
marker background had no position set.
2026-11-30 14:33:21 +00:00
WendelinandClaude Opus 5.5 3216ebc19a 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 16:27:08 +02:00
Martin Salinas f18ccc28c6 Don't keep a cancelled circular slider drag as the target (#56152)
* Put the target back when a circular slider drag ends without a change

The climate, humidifier and water heater controls copy the value being dragged into their target. When the drag ended without a change, for example a cancelled touch, that value stayed: the control showed a target that was never sent, the +/- buttons stepped from it, and a change still waiting from the buttons sent it. Keep the target from before the drag and put it back when it ends; a committed drag sets its value right after.

* Drop the kept target when the entity state is synced

A state update during a drag replaced the target, but the target kept from before the drag was put back when the drag ended: a cancelled drag showed the older target, and a committed drag of one bound of a range sent the older other bound.

* Send the kept target while a drag is in progress

A change from the buttons whose debounce ran out during a drag sent the dragged value, which is only a preview, and a cancelled drag then showed the button's value instead of what was sent.

* Keep the dragged value apart from the target

Putting the target from before the drag back needed fixes for state updates, a pending change from the buttons and the buttons used during a drag. Keeping the dragged value apart and only showing it leaves the target to what was set or synced, so all of them work on it as they did before the drag.

* Drop the dragged value when the entity state is synced

The slider takes the synced value, so a keyboard change that a state update overtook committed that value while the dragged one was still shown, and a drag the entity's unavailable state interrupted could be shown after it came back.

* Drop the dragged value only when its synced target changed

The slider only takes a synced value that differs from the one it has. Dropping the dragged value on every state update showed the target while a keyboard change the slider kept was still sent.

* Drop the dragged value when the entity goes unavailable or changes

* Render the control anew when it switches to another entity

* Keep a committed low or high target within the other one

* Pass the shown temperature to the circular slider so a clamped commit moves its handle
2026-11-30 16:23:16 +02:00
WendelinandClaude Opus 5.5 483fb4093f 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 16:22:15 +02:00
WendelinandClaude Opus 5.5 0f54967037 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 16:22:14 +02:00
Martin Salinas 21ba8fbf79 Keep showing a circular slider's dragged value when its target changes during a drag (#56178)
Keep a circular slider drag's value when its value changes from outside
2026-11-30 16:14:06 +02:00
ChrisandClaude Fable 5.2 ad8cea50d7 Stop subscribing to core user data twice on page load (#56214)
Co-authored-by: Claude Fable 5.2 <[email protected]>
2026-11-30 14:06:51 +00:00
renovate[bot] 7df3f5ca88 Update formatjs (#56070)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 13:47:38 +00:00
Aidan Timson 50e61275d5 Fix the demo gaps found by the live demos in the docs (#56166)
* Give the demo's heating and cooling thermostats their action from the temperatures

* Answer state visibility conditions in the demo's mock backend

* Add the battery level icons of sensors to the demo

* Check demo visibility conditions as Core does, also with the demo's own updateHass

* Let a demo thermostat in heat or cool mode only heat or cool for its range
2026-11-30 14:39:16 +01:00
Aidan Timson 91a941475c Redraw the button row when hass changes (#56266) 2026-11-30 14:22:35 +01:00
renovate[bot] cf79aecca9 Update dependency eslint-config-prettier to v10.1.9 (#56264)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 14:25:26 +02:00
Paul Bottein a2dd10adee 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 13:18:04 +01:00
Aidan Timson e3adc4adb6 Give the large date card a bigger default size (#56267) 2026-11-30 12:27:58 +01:00
3defae4364 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 11:20:06 +00:00
262763a10e Align the database usage table with other tables on mobile (#56177)
* Align the database usage table with other tables on mobile

Show the table full width in the card, replace the column headers with a
"Sort by" chip on narrow screens, and show the sorted column's value next
to each entity there.

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

* Mock ha-assist-chip in storage section test

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Aidan Timson <[email protected]>
2026-11-30 12:23:55 +02:00
renovate[bot]andPetar Petrov db9a56cd4b Update dependency barcode-detector to v3.2.5 (#56210)
* Update dependency barcode-detector to v3.2.5

* Remove type-fest license override

zxing-wasm 3.1.8 no longer depends on type-fest, so no production
dependency ships it and the pinned override fails the build.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Petar Petrov <[email protected]>
2026-11-30 11:09:54 +01:00
WendelinandClaude Opus 5.5 dc874ffdb5 Size the section editor to its preview (#56263)
* Size the section editor to its preview

Clicking the title of the section editor made it fill the screen, but
nothing showed that this was possible. On desktop the dialog now takes
the width the preview needs next to the editor: wider for a section
spanning several columns in the desktop preview, narrower in the mobile
preview. The width animates when switching the preview or changing the
section width.

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

* Treat a non-numeric section width as one column

A column span that isn't a whole number of at least one, like text in
YAML mode, made the desktop preview's dialog width invalid.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 10:04:33 +00:00
Paulus Schoutsen ef6a1222b2 Open restart confirmation directly after Marketplace integration updates (#56212)
* Open restart confirmation directly from Marketplace

* Call restart confirmation directly from Marketplace
2026-11-30 09:54:48 +01:00
renovate[bot]andPetar Petrov a25a643a31 Update dependency @vvo/tzdb to v6.208.0 (#56261)
* Update dependency @vvo/tzdb to v6.208.0

* Exclude @vvo/tzdb 6.208.0 from pnpm trust policy

6.208.0 lacks the trusted-publisher record that 6.205.0-6.207.0 carry,
but its provenance still points to vvo/tzdb's release workflow on main.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Petar Petrov <[email protected]>
2026-11-30 09:33:10 +01:00
d7fbb1efac 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 09:32:31 +01:00
Petar Petrov 4d643b7133 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 09:29:13 +01:00
Eduardo Moreno c196356d05 Fix thermostat and humidifier dial size when the entity appears after load (#56260)
In a sections view the grid sizes the card, so the host doesn't resize
when the entity appears and the warning is replaced by the control. The
ResizeController observed only the host, so its value stayed undefined
and the control got no max-width. Observe the .container element instead.
2026-11-30 09:44:25 +02:00
Jonathan DilksandClaude Opus 5.5 53d9395b44 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 09:16:38 +02:00
darkrain-nl dc031d0566 Keep the startup progress in view while the list scrolls (#56213) 2026-11-30 09:03:18 +02:00
renovate[bot] 893daa8333 Update github/codeql-action action to v4.39.4 (#56258)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 08:31:41 +02:00
renovate[bot] bbc67bb9d6 Update actions/dependency-review-action action to v5.0.1 (#56257)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 08:31:30 +02:00
renovate[bot] 48b56c4653 Update dependency @codemirror/view to v6.44.2 (#56255)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 06:08:52 +00:00
renovate[bot] 9dd88a24ce Update dependency tar to v7.5.24 (#56253)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 20:49:13 +02:00
renovate[bot] 963711b8fd Update dependency cally to v0.10.0 (#56251)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 18:10:16 +00:00
renovate[bot] 55b43df5b5 Update dependency vite to v8.4.0 (#56250)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 17:25:02 +02:00
renovate[bot] 0481cfdde3 Update dependency @rslib/core to v1.1.0 (#56248)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 14:27:47 +02:00
renovate[bot] 2ce8646318 Update dependency @codemirror/view to v6.44.1 (#56247)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 11:02:38 +00:00
Lazizbek Ergashev 459a48b51f Keep picture glance icons visible when tap action is none (#56239) 2026-11-29 08:39:40 +02:00
renovate[bot] c148beafd3 Update dependency @versatiles/style to v9.1.3 (#56241)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 08:34:46 +02:00
renovate[bot] 696c3fb093 Update dependency @vvo/tzdb to v6.207.0 (#56242)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-29 08:34:36 +02:00
Paulus Schoutsen 12008d3a06 Distinguish Marketplace dialog alert icons (#56235)
Use icons specific to the required Home Assistant update, built-in integration replacement, and GitHub connection. These notices can appear alongside another alert with the same severity.
2026-11-28 20:33:48 +02:00
Paulus Schoutsen a2179425e0 Remove duplicate Marketplace repository icons (#56230)
* Remove duplicate Marketplace restart icon

The status already shows the restart icon beside its text. Use the button label alone to identify the action.

* Remove other repeated Marketplace repository icons

Use text-only labels for Install, Update, and the Community links. A package icon denotes an available repository and a separate download-count icon distinguishes the metric from the Install action in repository menus.
2026-11-28 20:32:44 +02:00
Lazizbek Ergashev 261debd0d9 Translate the voice satellite setup dialog title (#56233) 2026-11-28 20:31:10 +02:00
renovate[bot] 9a7d6c2892 Update dependency @types/node to v24.19.4 (#56223)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 17:38:22 +02:00
Norbert Rittel 90d9e3e87a Clarify configuration warning when recreating entity IDs (#56221)
Clarify configuration warning when recreating Entity IDs
2026-11-28 17:30:57 +02:00
renovate[bot] 1490f8ff12 Update dependency @lezer/common to v1.5.7 (#56220)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 17:28:05 +02:00
renovate[bot] 2cb6974ab7 Update dependency @types/leaflet to v1.9.23 (#56222)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 17:27:25 +02:00
renovate[bot] 53abe40f72 Update vitest monorepo to v5.1.2 (#56228)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 17:25:31 +02:00
renovate[bot] 0a63f12c50 Update dependency @html-eslint/eslint-plugin to v0.69.0 (#56229)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 17:24:22 +02:00
renovate[bot] 8f0a6539ac Update CodeMirror (#56219)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-28 15:53:06 +02:00
darkrain-nl 31678bba2d Keep the startup details dialog at a fixed height (#56209) 2026-11-27 19:46:01 +01:00
Lazizbek Ergashev 3a9f461e46 Show Home Assistant Link as the title of the signed out Link page (#56205) 2026-11-27 14:37:26 +02:00
renovate[bot] 6198a100f0 Update dependency @rspack/core to v2.3.4 (#56201)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-27 14:22:51 +02:00
Petar Petrov 6517d24017 Show the device tooltip when hovering a name in the energy devices chart (#56200) 2026-11-27 11:08:59 +01:00
Petar Petrov 1343ac5bc2 Add a Dismiss all button to energy meter suggestions (#56198) 2026-11-27 10:38:12 +01:00
github-actions[bot]andpiitaya 133dd06b07 Update sensor entity constants (#56195)
Co-authored-by: piitaya <[email protected]>
2026-11-27 08:56:20 +02:00
Lazizbek Ergashev bbc4d57fe8 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-27 08:40:36 +02:00
Jan-Philipp BeneckeandCopilot Autofix powered by AI 0d5588ae56 Use ha-control-select-menu for the run picker on the assist debug page (#56190)
* Use ha-control-select-menu for the run picker on the assist debug page

* Update min-width calculation for toolbar select menu

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
2026-11-27 08:35:21 +02:00
renovate[bot] 67d858b828 Update dependency marked to v18.3.0 (#56194)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-27 08:32:20 +02:00
renovate[bot] 95e00f1e36 Update dependency @versatiles/style to v9.1.2 (#56193)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-27 08:32:12 +02:00
WendelinandClaude Opus 5.5 01f9c5eb5b Add a button to enlarge the card and badge editors (#56186)
Replace the hidden title click with a visible button next to Help,
shown on desktop only. The width animates after a click and is not
animated when the code editor switches to full screen.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 20:31:41 +02:00
renovate[bot] 40a28525fb Update dependency typescript-eslint to v8.74.0 (#56187)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-26 20:25:40 +02:00
f80deb0240 Timer progress bar tile card feature (#55994)
* Timer progress bar tile card feature

* Fix Copilot issues

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Calculate remaining time only once

* Fix issues

* Switch willUpdate to update

* Update src/panels/lovelace/card-features/hui-timer-progress-card-feature.ts

Co-authored-by: Petar Petrov <[email protected]>

* Fix reduced motion

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Petar Petrov <[email protected]>
2026-11-26 19:59:29 +02:00
WendelinandClaude Opus 5.5 68313876d3 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 16:54:07 +01:00
Paul Bottein c3db90ae22 Swipe to open or close the tilt of tilt-only covers (#56182) 2026-11-26 16:52:38 +01:00
WendelinandClaude Opus 5.5 95e0988b93 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 16:08:31 +01:00
WendelinandClaude Opus 5.5 00312420d8 Remove clicking the title to enlarge the more info dialog (#56176)
Clicking the title of the more info dialog made it fill the screen, but
nothing showed that this was possible. For a camera it only added black
bars, since its info view already fits the picture. Cameras also no
longer open at the large width: their info view and the image's size the
dialog from the picture, and their other views are as wide as those of
any other entity. A large width passed by the caller still works.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 15:24:20 +01:00
WendelinandClaude Opus 5.5 f2116b61fc 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 14:19:49 +00:00
Bram KragtenandClaude Opus 5.5 2e872965f6 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 15:19:19 +01:00
Paul Bottein cbf745f38a Fix rows value bubble cut off in the card size editor (#56181) 2026-11-26 15:02:14 +01:00
WendelinandClaude Opus 5.5 fe7cedd04b Make the image more info as wide as its picture fits (#56141)
* Make the image more info as wide as its picture fits

The more info of an image was always 1024px wide. Like the camera, the
dialog now takes the width the picture needs to be as high as there is
room for, between 580px and 1920px, but never wider than the picture
itself, so small images keep the standard width. Images no longer open
at the large width before their picture is loaded. The camera's aspect
ratio event becomes media-size-changed, with an optional natural width,
and the dialog forgets the size whenever the entity changes, also when
going to a related entity or back.

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

* Keep the image size for cached views and leave room for the safe area

A picture that finished loading while the info view was detached by
cache() couldn't send its size, and it doesn't load again when the view
is shown, so more-info-image sends the size again when it's reattached.
The picture's height now also leaves out the safe area, like the
dialog's height limit, and the image info's bottom padding that grows
with it.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-26 13:39:58 +02:00
Paul Bottein 2e9d8a1788 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 12:24:41 +01:00
Martin Salinas 332d612956 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 12:16:58 +01:00
WendelinandClaude Opus 5.5 11ef852384 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 11:23:45 +01:00
394d5999b8 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 11:22:32 +01:00
Petar Petrov 384fdfdbc9 Group intl-messageformat with formatjs packages in Renovate (#56161)
Group intl-messageformat with the formatjs packages in Renovate
2026-11-26 10:14:17 +00:00
Martin Salinas 0cccdc5972 Don't set the max value when a circular slider is removed during a drag (#56163)
Cancel a circular slider drag when the slider is removed from the page
2026-11-26 11:49:09 +02:00
Aidan Timson 771eaa70ff Add a skill for browser checks and pull request screenshots (#56142)
* Add a skill for browser checks and pull request screenshots

* Point the screenshot reminder to the browser checks skill

* Cover light and dark, long text and recorded demos in the browser checks skill

* Check RTL with an RTL profile language in the browser checks skill

* Keep a before capture for every change to an existing screen

* Have agents add pull request screenshots themselves when they can
2026-11-26 11:02:29 +02:00
darkrain-nl aff47efe5e 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 09:50:16 +01:00
Erwin Douna f13470719c 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 08:50:27 +02:00
Martin Salinas 5f769d613c Show the entity's value in number controls after the device puts it back (#56148)
* Show the entity's value in number controls after the device puts it back

The numeric input card feature and the number entity row bound the state straight to the control's value. When the entity came back to the value it had, Lit skipped the unchanged binding and the control kept the requested value. Bind with live() so the control is compared with the entity's value on each render.

* Remove the number row tests

They only check that the template puts the entity's value back on the controls, which is a rendering test. The gallery reproduction in the PR covers the change.
2026-11-26 08:44:12 +02:00
renovate[bot] f214ef8667 Update dependency @versatiles/style to v9.1.1 (#56158)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-26 08:32:28 +02:00
renovate[bot] 528ebe6b27 Update dependency memoize-one to v7 (#56160)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-26 08:32:20 +02:00
Gerd Naschenweng 82e6f1106f Cap the bar width in the statistics graph (#56097) 2026-11-26 08:04:48 +02:00
Martin Salinas f02656da54 Keep the color wheel drawn when only the cold white value is set (#56149)
With cw set and ww undefined, the ww !== null check let undefined through to rgbww2rgb, which returned NaN and made addColorStop throw, leaving the wheel blank. Moving the cold white slider of an RGBWW light that is off or in another color mode did that.
2026-11-26 07:52:12 +02:00
Matthias de BaatandClaude Opus 5.5 25307e427d 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-25 22:17:03 +01:00
Paul Bottein 207cbcc585 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-25 19:44:23 +02:00
71 changed files with 2525 additions and 1280 deletions

No files matched your search

@@ -0,0 +1,43 @@
---
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, remind the user to add screenshots or a short video.
- 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.
- 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@33d7b85da1a04171e211befe2c739303b9a4c066'
- 'github/codeql-action@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea'
'.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@a1d282b36b6f3519aa1f3fc636f609c47dddb294'
- 'actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec'
- '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@a1d282b36b6f3519aa1f3fc636f609c47dddb294':
ref: 'v5.0.0'
commit: 'sha1-a1d282b36b6f3519aa1f3fc636f609c47dddb294'
'actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec':
ref: 'v5.0.1'
commit: 'sha1-bbc44d14a204704ccc493733616cd1e93a0321ec'
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@33d7b85da1a04171e211befe2c739303b9a4c066':
ref: 'v4.39.3'
commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066'
'github/codeql-action@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea':
ref: 'v4.39.4'
commit: 'sha1-1bd86f2fdb4b86187fa4059f16f31a3202acc9ea'
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@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
with:
languages: javascript-typescript
build-mode: none
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
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@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1
with:
license-check: false # Covered by pnpm lint:licenses
fail-on-severity: high
+2 -1
View File
@@ -53,10 +53,11 @@ 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, remind the user to add screenshots or a short video.
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.
## AI policy
+1 -7
View File
@@ -25,13 +25,7 @@ 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 = [
{
// 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",
},
// No entries currently needed.
];
// Locate the directory of an installed package matching an exact version.
+31 -31
View File
@@ -43,28 +43,28 @@
"@babel/runtime": "8.1.3",
"@braintree/sanitize-url": "7.1.2",
"@codemirror/autocomplete": "6.20.4",
"@codemirror/commands": "6.11.1",
"@codemirror/commands": "6.11.2",
"@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.2",
"@codemirror/search": "6.7.3",
"@codemirror/state": "6.7.6",
"@codemirror/view": "6.43.15",
"@codemirror/view": "6.44.2",
"@date-fns/tz": "1.5.0",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "8.0.3",
"@formatjs/intl-displaynames": "8.0.3",
"@formatjs/intl-durationformat": "0.13.0",
"@formatjs/intl-getcanonicallocales": "3.4.0",
"@formatjs/intl-listformat": "9.1.0",
"@formatjs/intl-locale": "5.5.0",
"@formatjs/intl-numberformat": "10.1.0",
"@formatjs/intl-pluralrules": "7.1.0",
"@formatjs/intl-relativetimeformat": "13.0.3",
"@formatjs/intl-datetimeformat": "8.2.2",
"@formatjs/intl-displaynames": "8.0.5",
"@formatjs/intl-durationformat": "0.13.2",
"@formatjs/intl-getcanonicallocales": "3.4.2",
"@formatjs/intl-listformat": "9.1.2",
"@formatjs/intl-locale": "5.5.2",
"@formatjs/intl-numberformat": "10.1.2",
"@formatjs/intl-pluralrules": "7.1.2",
"@formatjs/intl-relativetimeformat": "13.0.5",
"@home-assistant/webawesome": "3.14.0-ha.2",
"@lezer/common": "1.5.6",
"@lezer/common": "1.5.7",
"@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.0",
"@versatiles/style": "9.1.3",
"@vibrant/color": "4.0.4",
"@vvo/tzdb": "6.204.0",
"@vvo/tzdb": "6.208.0",
"@webcomponents/scoped-custom-element-registry": "0.0.11",
"barcode-detector": "3.2.4",
"cally": "0.9.2",
"barcode-detector": "3.2.5",
"cally": "0.10.0",
"color-name": "2.1.1",
"comlink": "4.4.2",
"core-js": "3.51.0",
@@ -102,15 +102,15 @@
"hls.js": "1.7.4",
"home-assistant-js-websocket": "9.9.0",
"idb-keyval": "6.3.0",
"intl-messageformat": "12.2.0",
"intl-messageformat": "12.2.1",
"js-yaml": "5.5.0",
"leaflet": "1.9.4",
"leaflet.markercluster": "1.5.3",
"lit": "3.3.3",
"lit-html": "3.3.3",
"maplibre-gl": "6.19.0",
"marked": "18.2.1",
"memoize-one": "6.0.0",
"maplibre-gl": "6.20.0",
"marked": "18.3.0",
"memoize-one": "7.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.68.0",
"@html-eslint/eslint-plugin": "0.69.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.3",
"@rspack/core": "2.3.4",
"@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.22",
"@types/leaflet": "1.9.23",
"@types/leaflet.markercluster": "1.5.6",
"@types/lodash.merge": "4.6.9",
"@types/node": "24.19.2",
"@types/node": "24.19.4",
"@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.1",
"@vitest/coverage-v8": "5.1.2",
"babel-loader": "10.1.1",
"babel-plugin-polyfill-corejs3": "1.0.0",
"browserslist": "4.29.6",
@@ -178,7 +178,7 @@
"core-js-compat": "3.51.0",
"del": "9.0.1",
"eslint": "10.15.0",
"eslint-config-prettier": "10.1.8",
"eslint-config-prettier": "10.1.9",
"eslint-import-resolver-webpack": "0.13.11",
"eslint-plugin-import-x": "4.18.1",
"eslint-plugin-lit": "2.3.1",
@@ -210,14 +210,14 @@
"rspack-manifest-plugin": "5.2.2",
"serve": "14.2.8",
"sinon": "22.1.0",
"tar": "7.5.23",
"tar": "7.5.24",
"terser-webpack-plugin": "5.6.1",
"ts-lit-plugin": "2.0.2",
"typescript": "6.0.3",
"typescript-eslint": "8.73.0",
"vite": "8.3.8",
"typescript-eslint": "8.74.0",
"vite": "8.4.0",
"vite-tsconfig-paths": "6.1.1",
"vitest": "5.1.1",
"vitest": "5.1.2",
"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.0.7",
"@rslib/core": "1.1.0",
"lit": "3.3.3",
"typescript": "6.0.3"
}
+784 -702
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -18,6 +18,8 @@ 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.2"
version = "20261125.0"
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 package",
"description": "Group formatjs monorepo packages",
"groupName": "formatjs",
"matchPackageNames": ["@formatjs/**"]
"matchPackageNames": ["@formatjs/**", "intl-messageformat"]
},
{
"description": "Group Playwright package and CI container updates",
@@ -0,0 +1,74 @@
import type { ReactiveControllerHost } from "@lit/reactive-element/reactive-controller";
import type {
ConditionContext,
VisibilityCondition,
} from "../../panels/lovelace/common/validate-condition";
import { addEntityToCondition } from "../../panels/lovelace/common/validate-condition";
import type { HomeAssistant } from "../../types";
import type { ConditionEvaluation } from "../controllers/condition-evaluator-controller";
import { ConditionEvaluatorController } from "../controllers/condition-evaluator-controller";
import { dropInvalidConditions } from "./sanitize";
export interface VisibilitySubscription {
/** Pass each new hass object so client-side conditions check again. */
update(hass: HomeAssistant): void;
/** Close the subscriptions. `onChange` is not called again. */
unsubscribe(): void;
}
/**
* Live visibility of a list of dashboard visibility conditions, for code
* without a Lit host, such as custom cards and plugins. Conditions core
* evaluates are subscribed to; the rest are checked locally. Reports
* `unknown` until core replies.
*/
export const subscribeVisibility = (
hass: HomeAssistant,
conditions: VisibilityCondition[],
onChange: (result: ConditionEvaluation, error?: string) => void,
context: ConditionContext = {}
): VisibilitySubscription => {
// The controller only needs a host to register with and to re-render.
const host: ReactiveControllerHost = {
addController: () => undefined,
removeController: () => undefined,
requestUpdate: () => undefined,
updateComplete: Promise.resolve(true),
};
let active = true;
const controller = new ConditionEvaluatorController(host, {
resubscribeDelay: 0,
onResult: (result, error) => {
if (active) {
onChange(result, error);
}
},
});
const sanitized = dropInvalidConditions(conditions);
const { entity_id: entityId } = context;
// Core-evaluated conditions never see the context, so fold its entity in
// first, as the dashboard mixin does.
const validConditions = entityId
? sanitized.map((condition) => addEntityToCondition(condition, entityId))
: sanitized;
const getContext = () => context;
controller.hostConnected();
controller.observe(validConditions, hass, getContext);
return {
update: (newHass) => {
if (active) {
controller.observe(validConditions, newHass, getContext);
}
},
unsubscribe: () => {
active = false;
controller.hostDisconnected();
},
};
};
+3 -2
View File
@@ -245,7 +245,7 @@ export class HaCameraPlayer extends LitElement {
const aspectRatio = this._aspectRatio();
if (aspectRatio !== this._firedAspectRatio) {
this._firedAspectRatio = aspectRatio;
fireEvent(this, "camera-aspect-ratio-changed", { aspectRatio });
fireEvent(this, "media-size-changed", { aspectRatio });
}
if (changedProps.has("keepAwake")) {
if (this.keepAwake) {
@@ -1282,6 +1282,7 @@ declare global {
"ha-camera-player": HaCameraPlayer;
}
interface HASSDomEvents {
"camera-aspect-ratio-changed": { aspectRatio: number };
/** The natural width limits the picture's width when it is set */
"media-size-changed": { aspectRatio: number; naturalWidth?: number };
}
}
@@ -328,6 +328,11 @@ 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";
+23 -10
View File
@@ -139,12 +139,17 @@ export class HaControlCircularSlider extends LitElement {
protected updated(changedProps: PropertyValues): void {
super.updated(changedProps);
const activeValue = this._getActiveValue();
if (
this._activeSlider &&
activeValue != null &&
changedProps.has(this._activeSlider) &&
this[this._activeSlider] !== this._lastChanging
) {
this._lastChanging = undefined;
this._lastChanging = this._steppedValue(activeValue);
fireEvent(this, `${this._activeSlider}-changing`, {
value: this._lastChanging,
});
}
if (!this._activeSlider) {
if (changedProps.has("value")) {
@@ -179,6 +184,10 @@ export class HaControlCircularSlider extends LitElement {
disconnectedCallback(): void {
super.disconnectedCallback();
this._destroyListeners();
if (this._activeSlider) {
this._cancelInteraction();
}
}
private _managers: HammerManager[] = [];
@@ -248,6 +257,18 @@ 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) => {
@@ -279,15 +300,7 @@ export class HaControlCircularSlider extends LitElement {
mc.add(new Tap({ event: "singletap" }));
const 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;
this._cancelInteraction();
if (pressToActivate) {
panRecognizer.set({ enable: false });
}
+9
View File
@@ -73,6 +73,15 @@ export class HaDropdown extends Dropdown {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/naming-convention
private override async showMenu() {
// Flip away from the safe areas instead of opening into them, where the
// max-height below would squeeze the menu.
const styles = getComputedStyle(this);
// @ts-ignore flipPadding is typed as a number, floating-ui accepts sides
this.popup.flipPadding = {
top: parseFloat(styles.getPropertyValue("--safe-area-inset-top")) || 0,
bottom:
parseFloat(styles.getPropertyValue("--safe-area-inset-bottom")) || 0,
};
// @ts-ignore
await super.showMenu();
const triggerElement = this.getTrigger();
+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,
+47 -15
View File
@@ -23,6 +23,7 @@ import {
getPanelIcon,
getPanelIconPath,
getPanelTitle,
getSelectedPanelUrlPath,
} from "../data/panel";
import type { PersistentNotification } from "../data/persistent_notification";
import { subscribeNotifications } from "../data/persistent_notification";
@@ -231,12 +232,36 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
return nothing;
}
const selectedPanel = this.hass.panelUrl;
// prettier-ignore
return html`
${this._renderHeader()}
${this._renderAllPanels(selectedPanel)}`;
${this._renderAllPanels()}`;
}
private _computeSidebarPanels(): [PanelInfo[], PanelInfo[]] | undefined {
if (!this._panelOrder || !this._hiddenPanels) {
return undefined;
}
return computePanels(
this.hass.panels,
getDefaultPanelUrlPath(this.hass),
this._panelOrder,
this._hiddenPanels,
this.hass.locale
);
}
private _computeSelectedPanel(
sidebarPanels: [PanelInfo[], PanelInfo[]] | undefined,
route: Route | undefined
): string {
if (!route) {
return this.hass.panelUrl;
}
const urlPaths = (sidebarPanels ?? [[], []])
.flat()
.map((panel) => panel.url_path);
return getSelectedPanelUrlPath(urlPaths, route.path);
}
protected shouldUpdate(changedProps: PropertyValues): boolean {
@@ -254,7 +279,20 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
) {
return true;
}
if (!this.hass || !changedProps.has("hass")) {
if (!this.hass) {
return false;
}
if (changedProps.has("route")) {
const sidebarPanels = this._computeSidebarPanels();
const oldRoute = changedProps.get("route") as Route | undefined;
if (
this._computeSelectedPanel(sidebarPanels, oldRoute) !==
this._computeSelectedPanel(sidebarPanels, this.route)
) {
return true;
}
}
if (!changedProps.has("hass")) {
return false;
}
const oldHass = changedProps.get("hass") as HomeAssistant;
@@ -355,7 +393,9 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
</div>`;
}
private _renderAllPanels(selectedPanel: string) {
private _renderAllPanels() {
const sidebarPanels = this._computeSidebarPanels();
const selectedPanel = this._computeSelectedPanel(sidebarPanels, this.route);
const renderList = (content, cls: string, scrollable: boolean) =>
html`<ha-list-nav
class=${classMap({
@@ -365,7 +405,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
>${content}</ha-list-nav
>`;
if (!this._panelOrder || !this._hiddenPanels) {
if (!sidebarPanels) {
return html`<div class="panels-list">
<div class="wrapper">
${renderList(
@@ -390,15 +430,7 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
</div>`;
}
const defaultPanel = getDefaultPanelUrlPath(this.hass);
const [beforeSpacer, afterSpacer] = computePanels(
this.hass.panels,
defaultPanel,
this._panelOrder,
this._hiddenPanels,
this.hass.locale
);
const [beforeSpacer, afterSpacer] = sidebarPanels;
// prettier-ignore
return html`<div class="panels-list">
+1
View File
@@ -200,6 +200,7 @@ class HaEntityMarker extends LitElement {
}
.entity-picture {
background-size: cover;
background-position: center;
height: 100%;
width: 100%;
}
+15
View File
@@ -196,6 +196,21 @@ export const getPanelIconPath = (panel: PanelInfo): string | undefined => {
export const FIXED_PANELS = [PROFILE_PANEL, "config", NOT_FOUND_PANEL];
// A panel's url_path can span several segments (e.g. "config/logs"), so the
// most specific url_path matching the path wins over its first segment.
export const getSelectedPanelUrlPath = (
urlPaths: string[],
path: string
): string =>
urlPaths.reduce(
(selected, urlPath) =>
urlPath.length > selected.length &&
(path === `/${urlPath}` || path.startsWith(`/${urlPath}/`))
? urlPath
: selected,
path.split("/")[1] ?? ""
);
export interface PanelMutableParams {
title?: string | null;
icon?: string | null;
+2
View File
@@ -223,6 +223,7 @@ 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",
@@ -399,6 +400,7 @@ export const SENSOR_DEVICE_CLASS_CONVERTIBLE_UNITS: Record<
voltage: ["kV", "MV", "mV", "V", "μV"],
volume: ["CCF", "fl. oz.", "ft³", "gal", "L", "MCF", "mL", "m³"],
volume_flow_rate: [
"ft³/h",
"ft³/min",
"gal/d",
"gal/h",
@@ -2,6 +2,8 @@ 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";
@@ -28,6 +30,17 @@ 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;
@@ -39,16 +52,28 @@ 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);
}
`;
}
+69 -47
View File
@@ -149,10 +149,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
@property({ type: Boolean, reflect: true }) public large = false;
@state() private _fill = false;
// The dialog grows with the camera's or image's picture, as high as there
// is room for
@state() private _mediaAspectRatio?: number;
// The dialog grows with the camera's picture, as high as there is room for
@state() private _cameraAspectRatio?: number;
// An image is not shown larger than it is
@state() private _mediaNaturalWidth?: number;
// Height of the controls the camera's info shows below the picture
@state() private _cameraControlsHeight?: string;
@@ -196,12 +198,6 @@ 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();
@@ -219,7 +215,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
this._detailsYamlMode = false;
this.large = params.large ?? false;
this._fill = false;
this._open = true;
this._loadEntityRegistryEntry();
}
@@ -265,8 +260,6 @@ 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);
@@ -691,30 +684,32 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
`
: nothing;
// Also when the camera was opened from a smaller entity's related view
const cameraAspectRatio =
domain === "camera" && isDefaultView
? this._cameraAspectRatio
// Also when it was opened from a smaller entity's related view
const mediaAspectRatio =
(domain === "camera" || domain === "image") && isDefaultView
? this._mediaAspectRatio
: 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._fill
? "full"
: this.large || cameraAspectRatio
? "large"
: "medium"
}
class=${classMap({ camera: domain === "camera" })}
.width=${this.large || mediaAspectRatio ? "large" : "medium"}
class=${classMap({
camera: domain === "camera",
image: domain === "image",
})}
style=${styleMap({
"--more-info-camera-controls-height": this._cameraControlsHeight,
"--ha-dialog-width-lg": cameraAspectRatio
? `clamp(var(--ha-dialog-width-md, 580px), calc(var(--video-max-height) * ${cameraAspectRatio}), 1920px)`
"--ha-dialog-width-lg": mediaAspectRatio
? `clamp(var(--ha-dialog-width-md, 580px), calc(${mediaPictureWidth} + var(--more-info-media-inline-padding, 0px)), 1920px)`
: undefined,
})}
@camera-aspect-ratio-changed=${this._cameraAspectRatioChanged}
@media-size-changed=${this._mediaSizeChanged}
@camera-controls-height-changed=${this._cameraControlsHeightChanged}
.accessibleLabel=${title}
@closed=${this._dialogClosed}
@@ -747,7 +742,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
></ha-icon-button-prev>
`
}
<span slot="headerTitle" @click=${this._enlarge} class="title">
<span slot="headerTitle" class="title">
${
breadcrumb.length > 0
? !__DEMO__ && isAdmin
@@ -1071,6 +1066,17 @@ 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());
@@ -1140,10 +1146,11 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
this._entry = ev.detail;
}
private _cameraAspectRatioChanged(
ev: HASSDomEvent<HASSDomEvents["camera-aspect-ratio-changed"]>
private _mediaSizeChanged(
ev: HASSDomEvent<HASSDomEvents["media-size-changed"]>
) {
this._cameraAspectRatio = ev.detail.aspectRatio;
this._mediaAspectRatio = ev.detail.aspectRatio;
this._mediaNaturalWidth = ev.detail.naturalWidth;
}
private _cameraControlsHeightChanged(
@@ -1152,12 +1159,6 @@ 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);
@@ -1216,12 +1217,14 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
--dialog-content-padding: 0;
}
/* 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)
/* 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)
);
/* Along with the height of the picture */
--ha-dialog-width-transition:
@@ -1232,14 +1235,33 @@ 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 {
--video-max-height: calc(
100svh - var(--ha-space-20) -
68px - var(--more-info-camera-controls-height, 0px)
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 {
--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;
+32 -118
View File
@@ -13,7 +13,6 @@ 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";
@@ -21,10 +20,6 @@ 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,
@@ -36,14 +31,14 @@ import {
shutdownHost,
} from "../../data/hassio/host";
import { haStyle, haStyleDialog } from "../../resources/styles";
import type { HomeAssistant, ServiceCallRequest } from "../../types";
import type { HomeAssistant } from "../../types";
import { HOST_ACTION_TOAST_ID, showToast } from "../../util/toast";
import { showAlertDialog } from "../generic/show-dialog-box";
import {
showAlertDialog,
showConfirmationDialog,
} from "../generic/show-dialog-box";
import { showRestartWaitDialog } from "./show-dialog-restart";
import "./automation-restart-status";
confirmRestartAction,
showRestartConfirmation,
type RestartAction,
} from "./show-restart-confirmation";
@customElement("dialog-restart")
class DialogRestart extends LitElement {
@@ -74,15 +69,6 @@ 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 {
@@ -273,45 +259,16 @@ class DialogRestart extends LitElement {
duration: 1000,
});
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 "";
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,
});
}
}
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, {
@@ -343,75 +300,32 @@ class DialogRestart extends LitElement {
};
private async _handleAction(
ev: HASSDomCurrentTargetEvent<
HaListItemButton & {
action: "restart" | "reboot" | "shutdown" | "restart-safe-mode";
}
>
ev: HASSDomCurrentTargetEvent<HaListItemButton & { action: RestartAction }>
) {
if (this._loadingBackupInfo) {
return;
}
this._loadingBackupInfo = true;
const action = ev.currentTarget.action;
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;
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;
}
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 {
@@ -0,0 +1,96 @@
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,7 +145,9 @@ export class HaVoiceAssistantSetupDialog extends LitElement {
return html`
<ha-dialog
.open=${this._open}
header-title="Voice Satellite setup"
header-title=${this.hass.localize(
"ui.panel.config.voice_assistants.satellite_wizard.title"
)}
prevent-scrim-close
@closed=${this._dialogClosed}
>
+6
View File
@@ -2,4 +2,10 @@ import "@webcomponents/scoped-custom-element-registry/scoped-custom-element-regi
import "../resources/scoped-registry-ready";
import "../layouts/home-assistant";
// Custom cards and plugins can reach the helpers on any page, not only once a
// dashboard has loaded.
Object.assign(window, {
loadCardHelpers: () => import("../panels/lovelace/custom-card-helpers"),
});
import("../resources/append-ha-style");
-2
View File
@@ -11,7 +11,6 @@ import {
import { loadTokens, saveTokens } from "../common/auth/token_storage";
import { hassUrl } from "../data/auth";
import { isExternal } from "../data/external";
import { subscribeFrontendUserData } from "../data/frontend";
import { fetchConfig } from "../data/lovelace/config/types";
import { fetchResources } from "../data/lovelace/resource";
import { MAIN_WINDOW_NAME } from "../data/main_window";
@@ -188,7 +187,6 @@ window.hassConnection.then(({ conn }) => {
subscribePanels(conn, noop);
subscribeThemes(conn, noop);
subscribeUser(conn, noop);
subscribeFrontendUserData(conn, "core", noop);
subscribeRepairsIssueRegistry(conn, noop);
const preloadWindow = window as WindowWithPreloads;
+14 -19
View File
@@ -1,21 +1,9 @@
import { supportsFeatureFromAttributes } from "../../common/entity/supports-feature";
import {
CLIMATE_HVAC_ACTION_TO_MODE,
ClimateEntityFeature,
} from "../../data/climate";
import { ClimateEntityFeature } from "../../data/climate";
import type { HvacAction } from "../../data/climate";
import { MockBaseEntity } from "./base-entity";
import type { EntityAttributes } from "./types";
// Reverse mapping: mode → action (e.g. "cool" → "cooling")
const HVAC_MODE_TO_ACTION: Partial<Record<string, HvacAction>> =
Object.fromEntries(
Object.entries(CLIMATE_HVAC_ACTION_TO_MODE).map(([action, mode]) => [
mode,
action as HvacAction,
])
);
export class MockClimateEntity extends MockBaseEntity {
public async handleService(
domain: string,
@@ -243,10 +231,13 @@ export class MockClimateEntity extends MockBaseEntity {
return "off";
}
// Use the reverse mapping for direct mode → action (e.g. "fan_only" → "fan", "dry" → "drying")
const directAction = HVAC_MODE_TO_ACTION[state];
if (directAction && directAction !== "idle" && directAction !== "off") {
return directAction;
// Heat and cool get their action from the temperatures below
if (state === "dry") {
return "drying";
}
if (state === "fan_only") {
return "fan";
}
if (
@@ -276,13 +267,17 @@ export class MockClimateEntity extends MockBaseEntity {
const current = attrs.current_temperature;
const lowTarget = attrs.target_temp_low;
const highTarget = attrs.target_temp_high;
// Heat mode can only heat and cool mode only cool, while auto and
// heat_cool use both ends of the range
if (current != null) {
if (lowTarget != null && lowTarget > current) {
if (state !== "cool" && lowTarget != null && lowTarget > current) {
return "heating";
}
if (highTarget != null && highTarget < current) {
if (state !== "heat" && highTarget != null && highTarget < current) {
return "cooling";
}
return "idle";
}
}
+16
View File
@@ -607,6 +607,22 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
atmospheric_pressure: {
default: "mdi:thermometer-lines",
},
battery: {
default: "mdi:battery-unknown",
range: {
"0": "mdi:battery-alert",
"10": "mdi:battery-10",
"20": "mdi:battery-20",
"30": "mdi:battery-30",
"40": "mdi:battery-40",
"50": "mdi:battery-50",
"60": "mdi:battery-60",
"70": "mdi:battery-70",
"80": "mdi:battery-80",
"90": "mdi:battery-90",
"100": "mdi:battery",
},
},
carbon_dioxide: {
default: "mdi:molecule-co2",
},
+71
View File
@@ -27,6 +27,12 @@ import {
import { updateHassGroups } from "../data/context/updateContext";
import type { IconCategory } from "../data/icons";
import type { EntityRegistryDisplayEntry } from "../data/entity/entity_registry";
import { evaluateConditionsLocally } from "../common/condition/evaluate-locally";
import {
isLogicalCondition,
logicalChildren,
} from "../common/condition/translate";
import type { VisibilityCondition } from "../panels/lovelace/common/validate-condition";
import {
DateFormat,
FirstWeekday,
@@ -53,6 +59,24 @@ import type { EntityInput } from "./entities/types";
const ensureArray = <T>(val: T | T[]): T[] =>
Array.isArray(val) ? val : [val];
// Core's `not` passes when none of its conditions pass, and the frontend's
// unless all of them pass, so each `not` gets one `or` of its conditions
const withCoreNot = (condition: VisibilityCondition): VisibilityCondition => {
if (!isLogicalCondition(condition) || condition.conditions === undefined) {
return condition;
}
const conditions = logicalChildren(condition).map(withCoreNot);
return {
...condition,
conditions:
condition.condition === "not"
? [{ condition: "or", conditions }]
: conditions,
};
};
type MockServiceCallback = (
data: Record<string, any> | undefined,
target: Record<string, any> | undefined,
@@ -221,6 +245,8 @@ export const provideHass = (
return lazyLoaderPromise;
};
const eventListeners: Record<string, ((event) => void)[]> = {};
// Checks each subscribed condition again, for when the states change.
const conditionChecks = new Set<() => void>();
const entities = {};
let localResources: Resources = {};
@@ -664,6 +690,51 @@ export const provideHass = (
resources: category === "entity_component" ? ENTITY_COMPONENT_ICONS : {},
}));
// Core answers the visibility conditions of cards and rows that depend on
// states. Here they are checked against the mock states, as the frontend
// does itself before Core answers, and again each time the states change.
// A condition only Core can check, such as a template, gets an error, so
// a `not` around it can't show the card.
hassObj.mockWS(
"subscribe_condition",
({ condition }: { condition: VisibilityCondition }, _hass, onChange) => {
const check = () => {
const result = evaluateConditionsLocally(
[withCoreNot(condition)],
hass(),
{}
);
onChange?.(
result === undefined
? {
error: {
code: "not_supported",
message: "The demo can't check this condition",
},
}
: { result }
);
};
conditionChecks.add(check);
check();
return () => conditionChecks.delete(check);
}
);
// Check the conditions again after each state update, also when the host
// passed its own updateHass, as the demo does
const applyUpdate = hassObj.updateHass;
hassObj.updateHass = (obj: Partial<MockHomeAssistant>) => {
applyUpdate(obj);
if (obj.states) {
conditionChecks.forEach((check) => check());
}
};
// Set hass if required
if (setHassProperty) {
elements.forEach((el) => {
@@ -26,6 +26,7 @@ import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one";
import { navigate } from "../../../common/navigate";
import { formatListWithAnds } from "../../../common/string/format-list";
import { copyToClipboard } from "../../../common/util/copy-clipboard";
import "../../../components/ha-dropdown";
import type { HaDropdownSelectEvent } from "../../../components/ha-dropdown";
@@ -95,6 +96,9 @@ export class HaConfigEntryRow extends LitElement {
@property({ attribute: false }) public data!: ConfigEntryData;
/** The loaded integrations that lose this integration with this entry. */
@property({ attribute: false }) public dependents?: IntegrationManifest[];
@state() private _expanded = true;
@state() private _devicesExpanded = true;
@@ -812,14 +816,33 @@ export class HaConfigEntryRow extends LitElement {
const applicationCredentialsId =
await this._applicationCredentialForRemove(entryId);
const text = this.hass.localize(
"ui.panel.config.integrations.config_entry.delete_confirm_text"
);
const confirmed = await showConfirmationDialog(this, {
title: this.hass.localize(
"ui.panel.config.integrations.config_entry.delete_confirm_title",
{ title: this.data.entry.title }
),
text: this.hass.localize(
"ui.panel.config.integrations.config_entry.delete_confirm_text"
),
text: this.dependents?.length
? html`${text}<br /><br />${this.hass.localize(
"ui.panel.config.integrations.config_entry.delete_confirm_dependents",
{
count: this.dependents.length,
integrations: formatListWithAnds(
this.hass.locale,
this.dependents.map((manifest) =>
domainToName(this.hass.localize, manifest.domain, manifest)
)
),
name: domainToName(
this.hass.localize,
this.data.entry.domain,
this.manifest
),
}
)}`
: text,
confirmText: this.hass!.localize("ui.common.delete"),
dismissText: this.hass!.localize("ui.common.cancel"),
destructive: true,
@@ -21,7 +21,7 @@ import memoizeOne from "memoize-one";
import { ensureArray } from "../../../common/array/ensure-array";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { QueryParamsController } from "../../../common/controllers/query-params-controller";
import { ContextSubscriptionController } from "../../../common/decorators/consume";
import { consume } from "../../../common/decorators/consume";
import type { HASSDomTargetEvent } from "../../../common/dom/fire_event";
import { computeDeviceNameDisplay } from "../../../common/entity/compute_device_name";
import {
@@ -176,9 +176,9 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
@state() private _manifest?: IntegrationManifest;
/** The manifests of all loaded integrations, to find the dependents. */
@state() private _loadedManifests?: DomainManifestLookup;
private _manifestsConsumer?: ContextSubscriptionController<DomainManifestLookup>;
@consume({ context: manifestsContext, subscribe: true })
@state()
private _loadedManifests?: DomainManifestLookup;
@state() private _extraConfigEntries?: ConfigEntry[];
@@ -432,17 +432,23 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
this.domain
);
const dependents = this._getDependents(
this.domain,
this._loadedManifests,
this.hass.localize,
this.hass.locale.language
);
// Without the dependents, a dependency looks like a YAML integration.
const dependents =
this._manifest && !this._manifest.config_flow
? this._getDependents(
this.domain,
this._loadedManifests,
this.hass.localize,
this.hass.locale.language
)
: [];
const showDependents = normalEntries.length === 0 && dependents.length > 0;
const dependencyOnly =
normalEntries.length === 0 &&
dependents.length > 0 &&
!this._manifest?.config_flow;
// Deleting the last entry in use leaves the dependents without it.
const entriesInUse = configEntries.filter(
(entry) => entry.source !== "ignore" && !entry.disabled_by
);
const lastEntryId =
entriesInUse.length === 1 ? entriesInUse[0].entry_id : undefined;
// Hold back the YAML texts and "Add entry" until the manifest and the
// dependents are known. Entries do not wait, so a failed request cannot
// hide them.
@@ -461,7 +467,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
const showAddEntry =
this._manifest?.integration_type !== "hardware" &&
!showDependents &&
!dependencyOnly &&
!dependentsLoading &&
!setUpInPanel &&
(!this._manifest?.single_config_entry ||
@@ -653,7 +659,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
}
${
normalEntries.length === 0 &&
!showDependents &&
!dependencyOnly &&
!dependentsLoading &&
!setUpInPanel &&
this._manifest &&
@@ -1010,6 +1016,11 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
.diagnosticHandler=${this._diagnosticHandler}
.entities=${this._entities}
.data=${data}
.dependents=${
data.entry.entry_id === lastEntryId
? dependents
: undefined
}
data-entry-id=${data.entry.entry_id}
></ha-config-entry-row>`
)}
@@ -1018,19 +1029,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
: nothing
}
${
showDependents
? html`<div class="section">
<h3 class="section-header">
${this.hass.localize(
"ui.panel.config.integrations.integration_page.used_by"
)}
</h3>
${this._renderDependents(dependents)}
</div>`
: nothing
}
${
showDependents ||
dependencyOnly ||
dependentsLoading ||
(setUpInPanel && normalEntries.length === 0)
? nothing
@@ -1077,6 +1076,11 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
.diagnosticHandler=${this._diagnosticHandler}
.entities=${this._entities}
.data=${data}
.dependents=${
data.entry.entry_id === lastEntryId
? dependents
: undefined
}
data-entry-id=${data.entry.entry_id}
></ha-config-entry-row>`
)}
@@ -1084,26 +1088,23 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
}
</div>`
}
${
dependents.length
? html`<div class="section">
<h3 class="section-header">
${this.hass.localize(
"ui.panel.config.integrations.integration_page.used_by"
)}
</h3>
${this._renderDependents(dependents)}
</div>`
: nothing
}
</div>
</hass-subpage>
`;
}
// Only an integration without a config flow needs the loaded manifests, so
// other integration pages do not make the context fetch them.
private _watchLoadedManifests(): void {
if (this._manifestsConsumer) {
return;
}
this._manifestsConsumer = new ContextSubscriptionController(
this,
manifestsContext,
(manifests) => {
this._loadedManifests = manifests;
}
);
}
private _getDependents = memoizeOne(
(
domain: string,
@@ -1199,9 +1200,6 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
return;
}
this._manifest = await fetchIntegrationManifest(this.hass, this.domain);
if (!this._manifest.config_flow) {
this._watchLoadedManifests();
}
if (
this._manifest.integration_type &&
!["device", "hub", "service"].includes(this._manifest.integration_type)
@@ -1,3 +1,4 @@
import { mdiArrowDown, mdiArrowUp, mdiMenuDown } from "@mdi/js";
import type { TemplateResult } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
@@ -8,7 +9,10 @@ import { formatDateTime } from "../../../common/datetime/format_date_time";
import { consume } from "../../../common/decorators/consume";
import { consumeLocalize } from "../../../common/decorators/consume-context-entry";
import { transform } from "../../../common/decorators/transform";
import type { HASSDomCurrentTargetEvent } from "../../../common/dom/fire_event";
import type {
HASSDomCurrentTargetEvent,
HASSDomEvent,
} from "../../../common/dom/fire_event";
import { fireEvent } from "../../../common/dom/fire_event";
import { computeStateName } from "../../../common/entity/compute_state_name";
import { formatNumber } from "../../../common/number/format_number";
@@ -17,13 +21,20 @@ import "../../../components/data-table/ha-data-table";
import type {
DataTableColumnContainer,
DataTableRowData,
SortingChangedEvent,
SortingDirection,
} from "../../../components/data-table/ha-data-table";
import "../../../components/chips/ha-assist-chip";
import "../../../components/ha-alert";
import "../../../components/ha-button";
import "../../../components/ha-card";
import "../../../components/ha-dropdown";
import type { HaDropdownSelectEvent } from "../../../components/ha-dropdown";
import "../../../components/ha-dropdown-item";
import "../../../components/ha-segmented-bar";
import type { Segment } from "../../../components/ha-segmented-bar";
import "../../../components/ha-spinner";
import "../../../components/ha-svg-icon";
import {
configContext,
fullEntitiesContext,
@@ -167,6 +178,10 @@ export class StorageDatabaseCard extends LitElement {
@consume({ context: fullEntitiesContext, subscribe: true })
private _entityRegistry: EntityRegistryEntry[] = [];
@state() private _sortColumn?: string;
@state() private _sortDirection: SortingDirection = null;
protected render(): TemplateResult {
const usage = this.usage;
return html`
@@ -204,6 +219,7 @@ export class StorageDatabaseCard extends LitElement {
: nothing
}
</div>
${usage ? this._renderTable(usage) : nothing}
<div class="card-actions">
<ha-button
appearance="plain"
@@ -270,15 +286,25 @@ export class StorageDatabaseCard extends LitElement {
></ha-segmented-bar>`
: nothing
}
`;
}
private _renderTable(usage: RecorderDatabaseUsage) {
const columns = this._columns(
this._localize,
this._locale,
this.narrow,
usage.tables !== null,
this._sortColumn
);
return html`
<div class="table">
<ha-data-table
.narrow=${this.narrow}
.columns=${this._columns(
this._localize,
this._locale,
this.narrow,
usage.tables !== null
)}
.columns=${columns}
.sortColumn=${this._sortColumn}
.sortDirection=${this._sortDirection}
@sorting-changed=${this._sortingChanged}
.data=${this._rows(usage, this._entityRegistry, this._localize)}
.searchLabel=${this._localize(
"ui.panel.config.storage.database.search"
@@ -286,7 +312,9 @@ export class StorageDatabaseCard extends LitElement {
.noDataText=${this._localize(
"ui.panel.config.storage.database.no_entities"
)}
></ha-data-table>
>
${this.narrow ? this._renderSortMenu(columns) : nothing}
</ha-data-table>
</div>
`;
}
@@ -371,85 +399,158 @@ export class StorageDatabaseCard extends LitElement {
localize: LocalizeFunc,
locale: FrontendLocaleData,
narrow: boolean,
hasSizes: boolean
): DataTableColumnContainer<EntityUsageRow> => ({
name: {
title: localize("ui.panel.config.storage.database.columns.entity"),
main: true,
sortable: true,
filterable: true,
flex: 3,
template: (row) => {
const content = html`${row.name}
${
row.id !== UNKNOWN_ROW_ID && row.name !== row.id
? html`<div class="secondary">${row.id}</div>`
: nothing
}`;
// Rendered inside the data table, which styles .row-button.
return row.hasSettings
? html`<button
type="button"
class="row-button"
data-entity-id=${row.id}
@click=${this._openSettings}
>
${content}
</button>`
: content;
hasSizes: boolean,
sortColumn: string | undefined
): DataTableColumnContainer<EntityUsageRow> => {
// Narrow screens show one number beside the name: the sorted one.
const narrowColumn =
sortColumn && sortColumn !== "name"
? sortColumn
: hasSizes
? "bytes"
: "states";
return {
name: {
title: localize("ui.panel.config.storage.database.columns.entity"),
main: true,
sortable: true,
filterable: true,
flex: 3,
template: (row) => {
const content = html`${row.name}
${
row.id !== UNKNOWN_ROW_ID && row.name !== row.id
? html`<div class="secondary">${row.id}</div>`
: nothing
}`;
// Rendered inside the data table, which styles .row-button.
return row.hasSettings
? html`<button
type="button"
class="row-button"
data-entity-id=${row.id}
@click=${this._openSettings}
>
${content}
</button>`
: content;
},
},
},
id: {
title: localize("ui.panel.config.storage.database.columns.entity_id"),
filterable: true,
hidden: true,
},
states: {
title: localize("ui.panel.config.storage.database.columns.states"),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
// Without sizes the rows are sorted by states instead.
direction: hasSizes ? undefined : "desc",
hidden: narrow && hasSizes,
showNarrow: !hasSizes,
template: (row) => formatNumber(row.states, locale),
},
statistics: {
title: localize("ui.panel.config.storage.database.columns.statistics"),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
hidden: narrow,
template: (row) => formatNumber(row.statistics, locale),
},
statistics_short_term: {
title: localize(
"ui.panel.config.storage.database.columns.statistics_short_term"
),
type: "numeric",
minWidth: "130px",
maxWidth: "130px",
sortable: true,
hidden: narrow,
template: (row) => formatNumber(row.statistics_short_term, locale),
},
bytes: {
title: localize("ui.panel.config.storage.database.columns.size"),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
direction: hasSizes ? "desc" : undefined,
hidden: !hasSizes,
showNarrow: hasSizes,
template: (row) => bytesToString(row.bytes ?? 0),
},
})
id: {
title: localize("ui.panel.config.storage.database.columns.entity_id"),
filterable: true,
hidden: true,
},
states: {
title: localize("ui.panel.config.storage.database.columns.states"),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
// Without sizes the rows are sorted by states instead.
direction: hasSizes ? undefined : "desc",
showNarrow: narrow && narrowColumn === "states",
template: (row) => formatNumber(row.states, locale),
},
statistics: {
title: localize(
"ui.panel.config.storage.database.columns.statistics"
),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
showNarrow: narrow && narrowColumn === "statistics",
template: (row) => formatNumber(row.statistics, locale),
},
statistics_short_term: {
title: localize(
"ui.panel.config.storage.database.columns.statistics_short_term"
),
type: "numeric",
minWidth: "130px",
maxWidth: "130px",
sortable: true,
showNarrow: narrow && narrowColumn === "statistics_short_term",
template: (row) => formatNumber(row.statistics_short_term, locale),
},
bytes: {
title: localize("ui.panel.config.storage.database.columns.size"),
type: "numeric",
minWidth: "100px",
maxWidth: "100px",
sortable: true,
direction: hasSizes ? "desc" : undefined,
hidden: !hasSizes,
showNarrow: narrow && narrowColumn === "bytes",
template: (row) => bytesToString(row.bytes ?? 0),
},
};
}
);
// Replaces the column headers on narrow screens, like the list pages do.
private _renderSortMenu(columns: DataTableColumnContainer<EntityUsageRow>) {
const sortColumn = this._sortColumn ? columns[this._sortColumn] : undefined;
return html`
<div slot="header-row" class="narrow-header-row">
<ha-dropdown @wa-select=${this._handleSortBy}>
<ha-assist-chip
slot="trigger"
.label=${this._localize(
"ui.components.subpage-data-table.sort_by",
{
sortColumn: sortColumn ? ` ${sortColumn.title}` : "",
}
)}
>
<ha-svg-icon
slot="trailing-icon"
.path=${mdiMenuDown}
></ha-svg-icon>
</ha-assist-chip>
${Object.entries(columns).map(([id, column]) =>
column.sortable && !column.hidden
? html`<ha-dropdown-item
.value=${id}
.selected=${id === this._sortColumn}
>
${
id === this._sortColumn
? html`<ha-svg-icon
slot="details"
.path=${
this._sortDirection === "desc"
? mdiArrowDown
: mdiArrowUp
}
></ha-svg-icon>`
: nothing
}
${column.title}
</ha-dropdown-item>`
: nothing
)}
</ha-dropdown>
</div>
`;
}
private _sortingChanged(ev: HASSDomEvent<SortingChangedEvent>) {
this._sortDirection = ev.detail.direction;
this._sortColumn = ev.detail.direction ? ev.detail.column : undefined;
}
private _handleSortBy(ev: HaDropdownSelectEvent) {
ev.preventDefault(); // keep the dropdown open
const column = ev.detail.item.value;
this._sortDirection =
column === this._sortColumn && this._sortDirection === "asc"
? "desc"
: "asc";
this._sortColumn = column;
}
private _analyze() {
fireEvent(this, "database-analyze");
}
@@ -508,6 +609,17 @@ export class StorageDatabaseCard extends LitElement {
--data-table-row-height: 44px;
height: 100%;
}
.narrow-header-row {
display: flex;
align-items: center;
height: 100%;
padding-inline: var(--ha-space-4);
}
ha-assist-chip {
--ha-assist-chip-container-shape: 10px;
--ha-assist-chip-container-color: var(--card-background-color);
--ha-assist-chip-trailing-space: 8px;
}
`;
}
@@ -6,9 +6,13 @@ import {
import type { PropertyValues } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { repeat } from "lit/directives/repeat";
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import type { HassConfig, UnsubscribeFunc } from "home-assistant-js-websocket";
import memoizeOne from "memoize-one";
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,
@@ -79,20 +83,20 @@ export class AssistPipelineDebug extends LitElement {
@click=${this._pickOlderRun}
.path=${mdiRayEndArrow}
></ha-icon-button>
<select .value=${this._runId} @change=${this._pickRun}>
${repeat(
this._runs,
(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>`
<ha-control-select-menu
.label=${this.hass.localize(
"ui.panel.config.voice_assistants.debug.run"
)}
</select>
hide-label
show-arrow
.value=${this._runId}
.options=${this._runOptions(
this._runs,
this.hass.locale,
this.hass.config
)}
@wa-select=${this._pickRun}
></ha-control-select-menu>
<ha-icon-button
.disabled=${this._runs[0].pipeline_run_id === this._runId}
.label=${this.hass.localize(
@@ -254,8 +258,27 @@ export class AssistPipelineDebug extends LitElement {
this._runId = this._runs![curIndex - 1].pipeline_run_id;
}
private _pickRun(ev) {
this._runId = ev.target.value;
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;
}
}
static styles = [
@@ -270,6 +293,13 @@ 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,6 +2,7 @@ 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,
@@ -139,7 +140,7 @@ class HuiNumericInputCardFeature
return html`
<ha-control-number-buttons
.label=${label}
.value=${value}
.value=${live(value)}
.min=${stateObj.attributes.min}
.max=${stateObj.attributes.max}
.step=${stateObj.attributes.step}
@@ -153,7 +154,7 @@ class HuiNumericInputCardFeature
return html`
<ha-control-slider
.label=${label}
.value=${value}
.value=${live(value)}
.min=${stateObj.attributes.min}
.max=${stateObj.attributes.max}
.step=${stateObj.attributes.step}
@@ -0,0 +1,145 @@
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,6 +43,7 @@ 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";
@@ -110,6 +111,7 @@ export const UI_FEATURE_TYPES = [
"target-temperature",
"timer-actions",
"timer-presets",
"timer-progress",
"toggle",
"update-actions",
"vacuum-commands",
@@ -169,6 +171,7 @@ 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,6 +237,10 @@ export interface TimerPresetsCardFeatureConfig {
style?: "buttons" | "dropdown";
}
export interface TimerProgressCardFeatureConfig {
type: "timer-progress";
}
export interface WaterHeaterOperationModesCardFeatureConfig {
type: "water-heater-operation-modes";
style?: "dropdown" | "icons";
@@ -406,6 +410,7 @@ 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: [TILE_VARIANT, ["timer-actions"], ["timer-progress"]],
input_select: SELECT_VARIANTS,
select: SELECT_VARIANTS,
input_number: NUMERIC_INPUT_VARIANTS,
+2 -2
View File
@@ -89,10 +89,10 @@ export class HuiDateCard extends LitElement implements LovelaceCard {
case "large":
return {
min_rows: 2,
rows: 2,
rows: 3,
max_rows: 4,
min_columns: 6,
columns: 6,
columns: 12,
};
default:
return {
@@ -2,7 +2,7 @@ import { ResizeController } from "@lit-labs/observers/resize-controller";
import { mdiDotsVertical } from "@mdi/js";
import type { PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { customElement, property, query, 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, {
callback: (entries) => {
const container = entries[0]?.target.shadowRoot?.querySelector(
".container"
) as HTMLElement | undefined;
return container?.clientHeight;
},
target: null,
callback: () => this._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">
<div class="container" ${this._resizeController.target()}>
<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;
--disabled-text-color: currentColor;
--ha-color-on-disabled-quiet: 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, state } from "lit/decorators";
import { customElement, property, query, 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, {
callback: (entries) => {
const container = entries[0]?.target.shadowRoot?.querySelector(
".container"
) as HTMLElement | undefined;
return container?.clientHeight;
},
target: null,
callback: () => this._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">
<div class="container" ${this._resizeController.target()}>
${
domain === "water_heater"
? html` <ha-state-control-water_heater-temperature
@@ -38,6 +38,7 @@ 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";
@@ -104,6 +105,7 @@ const TYPES = new Set<LovelaceCardFeatureConfig["type"]>([
"temperature-forecast",
"timer-actions",
"timer-presets",
"timer-progress",
"toggle",
"update-actions",
"vacuum-commands",
@@ -9,6 +9,8 @@ export {
showPromptDialog,
} from "../../dialogs/generic/show-dialog-box";
export { importMoreInfoControl } from "../../dialogs/more-info/state_more_info_control";
export { subscribeVisibility } from "../../common/condition/subscribe-visibility";
export { createBadgeElement } from "./create-element/create-badge-element";
export { createCardElement } from "./create-element/create-card-element";
export { createHeaderFooterElement } from "./create-element/create-header-footer-element";
@@ -1,4 +1,9 @@
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
import {
mdiClose,
mdiFullscreen,
mdiFullscreenExit,
mdiHelpCircleOutline,
} from "@mdi/js";
import deepFreeze from "deep-freeze";
import type { CSSResultGroup, PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
@@ -68,6 +73,8 @@ export class HuiDialogEditBadge
@state() private _open = false;
@state() private _animateWidth = false;
@state() private _badgeConfig?: LovelaceBadgeConfig;
@state() private _saving = false;
@@ -195,6 +202,8 @@ export class HuiDialogEditBadge
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${this._animateWidth ? "animate-width" : ""}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed}
@@ -205,12 +214,18 @@ export class HuiDialogEditBadge
.label=${this.hass.localize("ui.common.close")}
.path=${mdiClose}
></ha-icon-button>
<span
slot="headerTitle"
class="title-enlargeable"
@click=${this._enlarge}
>${heading}</span
>
<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>
${
this._documentationURL !== undefined
? html`
@@ -304,10 +319,14 @@ export class HuiDialogEditBadge
`;
}
private _enlarge() {
withViewTransition(() => {
this.large = !this.large;
});
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 _ignoreKeydown(ev: KeyboardEvent) {
@@ -494,8 +513,18 @@ export class HuiDialogEditBadge
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
.title-enlargeable {
display: block;
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;
}
}
`,
];
@@ -1,4 +1,9 @@
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
import {
mdiClose,
mdiFullscreen,
mdiFullscreenExit,
mdiHelpCircleOutline,
} from "@mdi/js";
import deepFreeze from "deep-freeze";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
@@ -76,6 +81,8 @@ export class HuiDialogEditCard
@state() private _open = false;
@state() private _animateWidth = false;
@state() private _cardConfig?: LovelaceCardConfig;
@state() private _sectionConfig?: LovelaceSectionConfig;
@@ -207,6 +214,8 @@ export class HuiDialogEditCard
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${this._animateWidth ? "animate-width" : ""}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed}
@@ -217,12 +226,18 @@ export class HuiDialogEditCard
.label=${this.hass.localize("ui.common.close")}
.path=${mdiClose}
></ha-icon-button>
<span
slot="headerTitle"
class="title-enlargeable"
@click=${this._enlarge}
>${heading}</span
>
<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>
${
this._documentationURL !== undefined
? html`
@@ -330,10 +345,14 @@ export class HuiDialogEditCard
`;
}
private _enlarge() {
withViewTransition(() => {
this.large = !this.large;
});
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 _ignoreKeydown(ev: KeyboardEvent) {
@@ -576,8 +595,18 @@ export class HuiDialogEditCard
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
.title-enlargeable {
display: block;
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;
}
}
`,
];
@@ -67,6 +67,7 @@ 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";
@@ -136,6 +137,7 @@ const UI_FEATURE_TYPES = [
"temperature-forecast",
"timer-actions",
"timer-presets",
"timer-progress",
"toggle",
"update-actions",
"vacuum-commands",
@@ -239,6 +241,7 @@ 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,8 +96,6 @@ 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;
@@ -114,6 +112,8 @@ 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.large = false;
this._animateWidth = false;
this._yamlMode = false;
this._config = undefined;
this._currTab = TABS[0];
@@ -202,8 +202,14 @@ 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(
this._config.column_span ?? DEFAULT_SECTION_COLUMN_SPAN,
typeof configColumnSpan === "number" &&
Number.isInteger(configColumnSpan) &&
configColumnSpan >= 1
? configColumnSpan
: DEFAULT_SECTION_COLUMN_SPAN,
this._viewConfig?.max_columns || DEFAULT_MAX_COLUMNS
);
const singleColumn = columnSpan === 1;
@@ -258,7 +264,10 @@ export class HuiDialogEditSection
<ha-dialog
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
width="large"
class=${this._animateWidth ? "animate-width" : ""}
style=${styleMap({ "--preview-column-span": previewColumnSpan })}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isDirtyState}
@keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed}
@@ -269,12 +278,7 @@ export class HuiDialogEditSection
.label=${this.hass.localize("ui.common.close")}
.path=${mdiClose}
></ha-icon-button>
<span
slot="headerTitle"
class="title-enlargeable"
@click=${this._enlarge}
>${heading}</span
>
<span slot="headerTitle">${heading}</span>
${
this._params.newSection
? nothing
@@ -454,6 +458,7 @@ export class HuiDialogEditSection
ev: ValueChangedEvent<LovelaceSectionRawConfig>
): void {
ev.stopPropagation();
this._animateWidth = true;
this._config = ev.detail.value;
this._updateDirtyState(this._config!);
}
@@ -494,15 +499,15 @@ export class HuiDialogEditSection
}
private _previewModeClicked(ev: Event) {
this._animateWidth = true;
this._storedPreviewMode = (
ev.currentTarget as HTMLElement & { mode: PreviewMode }
).mode;
}
private _enlarge() {
withViewTransition(() => {
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 _handleTabChanged(ev: CustomEvent): void {
@@ -737,6 +742,18 @@ export class HuiDialogEditSection
ha-dialog {
--dialog-content-padding: var(--ha-space-2);
--preview-column-width: 390px;
--preview-width: calc(
var(--preview-column-span) * var(--preview-column-width) +
(var(--preview-column-span) - 1) *
var(--ha-view-sections-column-gap, 32px)
);
}
ha-dialog.animate-width {
--ha-dialog-width-transition:
min-width var(--ha-animation-duration-normal) ease-out,
max-width var(--ha-animation-duration-normal) ease-out;
}
.content {
@@ -752,29 +769,18 @@ 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: calc(
var(--column-span) * var(--preview-column-width) +
(var(--column-span) - 1) *
var(--ha-view-sections-column-gap, 32px)
);
width: var(--preview-width);
}
.preview-header {
display: flex;
@@ -828,19 +834,28 @@ export class HuiDialogEditSection
}
@media (min-width: 1000px) {
ha-dialog {
--editor-column-width: 520px;
/* Plus the paddings of the preview and the dialog */
--ha-dialog-width-lg: calc(
var(--editor-column-width) + var(--preview-width) + 28px + 2 *
var(--dialog-content-padding)
);
}
.content {
flex-direction: row;
max-height: var(--code-mirror-max-height);
}
.content > .element-editor {
box-sizing: border-box;
flex: 0 1 var(--editor-column-width);
padding-inline-end: var(--ha-space-4);
max-width: 500px;
}
.content > .element-preview {
flex: 1 1 0;
}
.content > .element-editor,
.content > .element-preview {
flex-basis: 0;
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
height: auto;
}
@@ -889,9 +904,6 @@ export class HuiDialogEditSection
margin-inline-end: auto;
margin-inline-start: initial;
}
.title-enlargeable {
display: block;
}
`,
];
}
@@ -1,6 +1,7 @@
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";
@@ -88,7 +89,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
.step=${Number(stateObj.attributes.step)}
.min=${Number(stateObj.attributes.min)}
.max=${Number(stateObj.attributes.max)}
.value=${Number(stateObj.state)}
.value=${live(Number(stateObj.state))}
@change=${this._selectedValueChanged}
></ha-slider>
<span class="state">
@@ -111,7 +112,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
.step=${Number(stateObj.attributes.step)}
.min=${Number(stateObj.attributes.min)}
.max=${Number(stateObj.attributes.max)}
.value=${Number(stateObj.state).toString()}
.value=${live(Number(stateObj.state).toString())}
type="number"
@change=${this._selectedValueChanged}
>
@@ -1,6 +1,6 @@
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import { DOMAINS_TOGGLE } from "../../../common/const";
import { computeDomain } from "../../../common/entity/compute_domain";
import "../../../components/ha-button";
@@ -29,7 +29,7 @@ const EMPTY_STATE_OBJ = {
@customElement("hui-button-row")
export class HuiButtonRow extends LitElement implements LovelaceRow {
public hass?: HomeAssistant;
@property({ attribute: false }) public hass?: HomeAssistant;
@state() private _config?: ButtonRowConfig;
@@ -1,5 +1,5 @@
import type { ContextType } from "@lit/context";
import { mdiCheckCircle, mdiDownload, mdiStar } from "@mdi/js";
import { mdiCheckCircle, mdiDownloadMultiple, 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=${mdiDownload}></ha-svg-icon>
<ha-svg-icon .path=${mdiDownloadMultiple}></ha-svg-icon>
${formatNumber(repository.downloads, locale, compact)}
</span>`
: nothing
@@ -6,7 +6,7 @@ import {
mdiCheckCircleOutline,
mdiCompassOutline,
mdiDotsVertical,
mdiDownload,
mdiDownloadMultiple,
mdiLinkPlus,
mdiOpenInNew,
mdiStar,
@@ -674,7 +674,7 @@ export class HaMarketplaceDashboard extends LitElement {
return html`${
narrow
? html`<ha-svg-icon .path=${mdiDownload}></ha-svg-icon>`
? html`<ha-svg-icon .path=${mdiDownloadMultiple}></ha-svg-icon>`
: nothing
}${formatNumber(repository.downloads, this._i18n.locale, compact)}`;
},
@@ -3,12 +3,11 @@ import {
mdiAccountGroup,
mdiAlertCircleOutline,
mdiArrowUpBoldCircleOutline,
mdiBug,
mdiCheckCircle,
mdiCheckCircleOutline,
mdiDotsVertical,
mdiDownload,
mdiGithub,
mdiDownloadMultiple,
mdiPackageVariantClosed,
mdiRestart,
mdiStar,
mdiTestTube,
@@ -58,7 +57,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 { showRestartDialog } from "../../../dialogs/restart/show-dialog-restart";
import { showRestartConfirmation } from "../../../dialogs/restart/show-restart-confirmation";
import "../../../layouts/hass-error-screen";
import "../../../layouts/hass-loading-screen";
import "../../../layouts/hass-subpage";
@@ -175,6 +174,8 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
@consume({ context: connectionContext, subscribe: true })
private _connection!: ContextType<typeof connectionContext>;
@state() private _confirmingRestart = false;
@state() private _integrationCategoryIcons?: IntegrationCategoryIcons;
@state()
@@ -706,13 +707,12 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
if (!repository.installed) {
return {
kind: "available",
icon: mdiDownload,
icon: mdiPackageVariantClosed,
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,11 +734,7 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
installed: repository.installed_version,
version: repository.available_version,
}),
action: this._installButton(
mdiArrowUpBoldCircleOutline,
localize("ui.common.update"),
this._update
),
action: this._installButton(localize("ui.common.update"), this._update),
};
}
@@ -755,9 +751,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>`,
};
@@ -800,12 +796,10 @@ 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>`;
}
@@ -938,7 +932,6 @@ 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
@@ -947,7 +940,6 @@ 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>
@@ -1027,7 +1019,7 @@ type: module</pre>`,
}
if (repository.downloads) {
signals.push({
icon: mdiDownload,
icon: mdiDownloadMultiple,
text: localize("ui.panel.marketplace.repository.community.downloads", {
number: repository.downloads,
count: html`<strong
@@ -1092,8 +1084,20 @@ type: module</pre>`,
this._installRepositoryDialog();
}
private _restart() {
showRestartDialog(this);
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 _setUp() {
@@ -1,4 +1,5 @@
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";
@@ -10,6 +11,7 @@ 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";
@@ -79,6 +81,7 @@ 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,5 +1,6 @@
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";
@@ -21,6 +22,7 @@ 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";
@@ -259,6 +261,7 @@ 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 }
@@ -281,6 +284,7 @@ export class DialogMarketplaceInstall extends DialogMixin<MarketplaceInstallDial
${
tooNew
? html`<ha-alert alert-type="warning">
<ha-svg-icon slot="icon" .path=${mdiUpdate}></ha-svg-icon>
${installBlockedReason(this._i18n.localize, repository)}
${this._i18n.localize(
"ui.panel.marketplace.dialog_install.older_version_hint"
@@ -3,6 +3,7 @@ import { mdiMinus, mdiPlus, mdiWaterPercent } from "@mdi/js";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { styleMap } from "lit/directives/style-map";
import { consume } from "../../common/decorators/consume";
import type { HASSDomEvent } from "../../common/dom/fire_event";
@@ -52,6 +53,8 @@ export class HaStateControlClimateHumidity extends LitElement {
@state() private _targetHumidity?: number;
@state() private _changingHumidity?: number;
private _sizeController = createStateControlCircularSliderController(this);
private _pendingSync = new PendingValueSync();
@@ -61,7 +64,11 @@ export class HaStateControlClimateHumidity extends LitElement {
if (!changedProp.has("stateObj")) {
return;
}
if (this.stateObj.state === UNAVAILABLE) {
this._changingHumidity = undefined;
}
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
this._changingHumidity = undefined;
this._debouncedCallService.cancel();
this._pendingSync.reset();
this._syncTargetHumidity();
@@ -71,6 +78,9 @@ export class HaStateControlClimateHumidity extends LitElement {
}
private _syncTargetHumidity() {
if (this.stateObj.attributes.humidity !== this._targetHumidity) {
this._changingHumidity = undefined;
}
this._targetHumidity = this.stateObj.attributes.humidity;
}
@@ -96,8 +106,11 @@ export class HaStateControlClimateHumidity extends LitElement {
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
const { value } = ev.detail;
if (typeof value !== "number" || isNaN(value)) return;
this._targetHumidity = value;
if (typeof value !== "number" || isNaN(value)) {
this._changingHumidity = undefined;
return;
}
this._changingHumidity = value;
}
private _debouncedCallService = debounce(() => this._callService(), 1000);
@@ -212,6 +225,10 @@ export class HaStateControlClimateHumidity extends LitElement {
}
protected render() {
return keyed(this.stateObj.entity_id, this._renderControl());
}
private _renderControl() {
const supportsTargetHumidity = supportsFeature(
this.stateObj,
ClimateEntityFeature.TARGET_HUMIDITY
@@ -264,7 +281,8 @@ export class HaStateControlClimateHumidity extends LitElement {
>
</ha-control-circular-slider>
<div class="info">
${this._renderLabel()} ${this._renderTarget(targetHumidity)}
${this._renderLabel()}
${this._renderTarget(this._changingHumidity ?? targetHumidity)}
${this._renderCurrentHumidity(
this.stateObj.attributes.current_humidity
)}
@@ -4,6 +4,7 @@ import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { keyed } from "lit/directives/keyed";
import { styleMap } from "lit/directives/style-map";
import { consume } from "../../common/decorators/consume";
import { UNIT_F } from "../../common/const";
@@ -81,6 +82,8 @@ export class HaStateControlClimateTemperature extends LitElement {
@state() private _targetTemperature: Partial<Record<Target, number>> = {};
@state() private _changingTemperature: Partial<Record<Target, number>> = {};
@state() private _selectTargetTemperature: Target = "low";
private _sizeController = createStateControlCircularSliderController(this);
@@ -92,7 +95,11 @@ export class HaStateControlClimateTemperature extends LitElement {
if (!changedProp.has("stateObj")) {
return;
}
if (this.stateObj.state === UNAVAILABLE) {
this._changingTemperature = {};
}
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
this._changingTemperature = {};
this._debouncedCallService.cancel();
this._pendingSync.reset();
this._syncTargetTemperature();
@@ -102,11 +109,20 @@ export class HaStateControlClimateTemperature extends LitElement {
}
private _syncTargetTemperature() {
this._targetTemperature = {
const targetTemperature: Partial<Record<Target, number>> = {
value: this.stateObj.attributes.temperature,
low: this.stateObj.attributes.target_temp_low,
high: this.stateObj.attributes.target_temp_high,
};
if (
(Object.keys(this._changingTemperature) as Target[]).some(
(target) =>
targetTemperature[target] !== this._targetTemperature[target]
)
) {
this._changingTemperature = {};
}
this._targetTemperature = targetTemperature;
}
private get _step() {
@@ -127,27 +143,31 @@ export class HaStateControlClimateTemperature extends LitElement {
private _valueChanged(ev: HASSDomEvent<HASSDomEvents["value-changed"]>) {
const { value } = ev.detail;
if (typeof value !== "number" || isNaN(value)) return;
const target = ev.type.replace("-changed", "");
const target = ev.type.replace("-changed", "") as Target;
this._targetTemperature = {
...this._targetTemperature,
[target]: value,
[target]: this._clampToRange(target, value),
};
this._selectTargetTemperature = target as Target;
this._selectTargetTemperature = target;
this._debouncedCallService.cancel();
this._callService(target);
}
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
const { value } = ev.detail;
if (typeof value !== "number" || isNaN(value)) return;
if (typeof value !== "number" || isNaN(value)) {
this._changingTemperature = {};
return;
}
const target = ev.type.replace("-changing", "");
this._targetTemperature = {
...this._targetTemperature,
[target]: value,
};
this._changingTemperature = { [target]: value };
this._selectTargetTemperature = target as Target;
}
private get _displayedTemperature() {
return { ...this._targetTemperature, ...this._changingTemperature };
}
private _debouncedCallService = debounce(
(target: Target) => this._callService(target),
1000
@@ -180,21 +200,25 @@ export class HaStateControlClimateTemperature extends LitElement {
let temp = this._targetTemperature[target] ?? defaultValue;
temp += step;
temp = clamp(temp, this._min, this._max);
if (target === "high" && this._targetTemperature.low != null) {
temp = clamp(temp, this._targetTemperature.low, this._max);
}
if (target === "low" && this._targetTemperature.high != null) {
temp = clamp(temp, this._min, this._targetTemperature.high);
}
this._targetTemperature = {
...this._targetTemperature,
[target]: temp,
[target]: this._clampToRange(target, temp),
};
this._pendingSync.schedule();
this._debouncedCallService(target);
}
private _clampToRange(target: Target, temp: number) {
if (target === "high" && this._targetTemperature.low != null) {
return clamp(temp, this._targetTemperature.low, this._max);
}
if (target === "low" && this._targetTemperature.high != null) {
return clamp(temp, this._min, this._targetTemperature.high);
}
return temp;
}
private _handleSelectTemp(ev) {
const target = ev.currentTarget.target as Target;
this._selectTargetTemperature = target;
@@ -354,7 +378,7 @@ export class HaStateControlClimateTemperature extends LitElement {
}
if (this._supportsTargetTemperature && !this.showCurrentAsPrimary) {
return this._renderTarget(this._targetTemperature.value!, "big");
return this._renderTarget(this._displayedTemperature.value!, "big");
}
if (this._supportsTargetTemperatureRange && !this.showCurrentAsPrimary) {
@@ -374,7 +398,7 @@ export class HaStateControlClimateTemperature extends LitElement {
"target_temp_low"
)}
</span>
${this._renderTarget(this._targetTemperature.low!, "big")}
${this._renderTarget(this._displayedTemperature.low!, "big")}
</button>
<button
@click=${this._handleSelectTemp}
@@ -390,7 +414,7 @@ export class HaStateControlClimateTemperature extends LitElement {
"target_temp_high"
)}
</span>
${this._renderTarget(this._targetTemperature.high!, "big")}
${this._renderTarget(this._displayedTemperature.high!, "big")}
</button>
</div>
`;
@@ -427,7 +451,7 @@ export class HaStateControlClimateTemperature extends LitElement {
return html`
<p class="label secondary">
<ha-svg-icon .path=${mdiThermostat}></ha-svg-icon>
${this._renderTarget(this._targetTemperature.value!, "normal")}
${this._renderTarget(this._displayedTemperature.value!, "normal")}
</p>
`;
}
@@ -450,7 +474,7 @@ export class HaStateControlClimateTemperature extends LitElement {
"target_temp_low"
)}
</span>
${this._renderTarget(this._targetTemperature.low!, "normal", true)}
${this._renderTarget(this._displayedTemperature.low!, "normal", true)}
</button>
<span>·</span>
<button
@@ -467,7 +491,7 @@ export class HaStateControlClimateTemperature extends LitElement {
"target_temp_high"
)}
</span>
${this._renderTarget(this._targetTemperature.high!, "normal", true)}
${this._renderTarget(this._displayedTemperature.high!, "normal", true)}
</button>
</p>
`;
@@ -503,6 +527,10 @@ export class HaStateControlClimateTemperature extends LitElement {
}
protected render() {
return keyed(this.stateObj.entity_id, this._renderControl());
}
private _renderControl() {
const mode = this.stateObj.state;
const action = this.stateObj.attributes.hvac_action;
const active = stateActive(this.stateObj);
@@ -549,7 +577,7 @@ export class HaStateControlClimateTemperature extends LitElement {
.preventInteractionOnScroll=${this.preventInteractionOnScroll}
.inactive=${!active}
.mode=${sliderMode}
.value=${this._targetTemperature.value}
.value=${this._displayedTemperature.value}
.min=${this._min}
.max=${this._max}
.step=${this._step}
@@ -585,8 +613,8 @@ export class HaStateControlClimateTemperature extends LitElement {
.preventInteractionOnScroll=${this.preventInteractionOnScroll}
.inactive=${!active}
dual
.low=${this._targetTemperature.low}
.high=${this._targetTemperature.high}
.low=${this._displayedTemperature.low}
.high=${this._displayedTemperature.high}
.min=${this._min}
.max=${this._max}
.step=${this._step}
@@ -3,6 +3,7 @@ import { mdiMinus, mdiPlus, mdiThermostat, mdiWaterPercent } from "@mdi/js";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { styleMap } from "lit/directives/style-map";
import { consume } from "../../common/decorators/consume";
import { consumeLocalize } from "../../common/decorators/consume-context-entry";
@@ -57,6 +58,8 @@ export class HaStateControlHumidifierHumidity extends LitElement {
@state() private _targetHumidity?: number;
@state() private _changingHumidity?: number;
private _sizeController = createStateControlCircularSliderController(this);
private _pendingSync = new PendingValueSync();
@@ -66,7 +69,11 @@ export class HaStateControlHumidifierHumidity extends LitElement {
if (!changedProp.has("stateObj")) {
return;
}
if (this.stateObj.state === UNAVAILABLE) {
this._changingHumidity = undefined;
}
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
this._changingHumidity = undefined;
this._debouncedCallService.cancel();
this._pendingSync.reset();
this._syncTargetHumidity();
@@ -76,6 +83,9 @@ export class HaStateControlHumidifierHumidity extends LitElement {
}
private _syncTargetHumidity() {
if (this.stateObj.attributes.humidity !== this._targetHumidity) {
this._changingHumidity = undefined;
}
this._targetHumidity = this.stateObj.attributes.humidity;
}
@@ -101,8 +111,11 @@ export class HaStateControlHumidifierHumidity extends LitElement {
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
const { value } = ev.detail;
if (typeof value !== "number" || isNaN(value)) return;
this._targetHumidity = value;
if (typeof value !== "number" || isNaN(value)) {
this._changingHumidity = undefined;
return;
}
this._changingHumidity = value;
}
private _debouncedCallService = debounce(() => this._callService(), 1000);
@@ -200,7 +213,10 @@ export class HaStateControlHumidifierHumidity extends LitElement {
}
if (this._targetHumidity != null && !this.showCurrentAsPrimary) {
return this._renderTarget(this._targetHumidity!, "big");
return this._renderTarget(
this._changingHumidity ?? this._targetHumidity,
"big"
);
}
if (this.stateObj.state !== UNAVAILABLE) {
@@ -234,7 +250,10 @@ export class HaStateControlHumidifierHumidity extends LitElement {
return html`
<p class="label">
<ha-svg-icon .path=${mdiThermostat}></ha-svg-icon>
${this._renderCurrent(this._targetHumidity, "normal")}
${this._renderCurrent(
this._changingHumidity ?? this._targetHumidity,
"normal"
)}
</p>
`;
}
@@ -299,6 +318,10 @@ export class HaStateControlHumidifierHumidity extends LitElement {
}
protected render() {
return keyed(this.stateObj.entity_id, this._renderControl());
}
private _renderControl() {
const stateColor = stateColorCss(this.stateObj);
const active = stateActive(this.stateObj);
@@ -3,6 +3,7 @@ import { mdiMinus, mdiPlus } from "@mdi/js";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { styleMap } from "lit/directives/style-map";
import { consume } from "../../common/decorators/consume";
import { UNIT_F } from "../../common/const";
@@ -60,6 +61,8 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
@state() private _targetTemperature?: number;
@state() private _changingTemperature?: number;
private _sizeController = createStateControlCircularSliderController(this);
private _pendingSync = new PendingValueSync();
@@ -69,7 +72,11 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
if (!changedProp.has("stateObj")) {
return;
}
if (this.stateObj.state === UNAVAILABLE) {
this._changingTemperature = undefined;
}
if (changedProp.get("stateObj")?.entity_id !== this.stateObj.entity_id) {
this._changingTemperature = undefined;
this._debouncedCallService.cancel();
this._pendingSync.reset();
this._syncTargetTemperature();
@@ -79,6 +86,9 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
}
private _syncTargetTemperature() {
if (this.stateObj.attributes.temperature !== this._targetTemperature) {
this._changingTemperature = undefined;
}
this._targetTemperature = this.stateObj.attributes.temperature;
}
@@ -107,8 +117,11 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
private _valueChanging(ev: HASSDomEvent<HASSDomEvents["value-changing"]>) {
const { value } = ev.detail;
if (typeof value !== "number" || isNaN(value)) return;
this._targetTemperature = value;
if (typeof value !== "number" || isNaN(value)) {
this._changingTemperature = undefined;
return;
}
this._changingTemperature = value;
}
private _debouncedCallService = debounce(() => this._callService(), 1000);
@@ -231,6 +244,10 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
}
protected render() {
return keyed(this.stateObj.entity_id, this._renderControl());
}
private _renderControl() {
const supportsTargetTemperature = supportsFeature(
this.stateObj,
WaterHeaterEntityFeature.TARGET_TEMPERATURE
@@ -271,7 +288,9 @@ export class HaStateControlWaterHeaterTemperature extends LitElement {
</ha-control-circular-slider>
<div class="info">
${this._renderLabel()}
${this._renderTargetTemperature(this._targetTemperature)}
${this._renderTargetTemperature(
this._changingTemperature ?? this._targetTemperature
)}
${this._renderCurrentTemperature(
this.stateObj.attributes.current_temperature
)}
+1 -10
View File
@@ -1,7 +1,6 @@
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,
@@ -12,8 +11,6 @@ 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 {
@@ -47,13 +44,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
{
entityId: ev.detail.entityId,
view,
large:
ev.detail.large ??
(ev.detail.entityId
? LARGE_MORE_INFO_DOMAINS.includes(
computeDomain(ev.detail.entityId)
)
: false),
large: ev.detail.large,
data: ev.detail.data,
returnUrl,
},
+10 -1
View File
@@ -2423,7 +2423,7 @@
},
"recreate_entity_ids": {
"confirm_rename_title": "Are you sure you want to recreate your entity IDs?",
"confirm_rename_warning": "This will not 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!",
"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!",
"will_rename": "{count} {count, plural,\n one {entity ID}\n other {entity IDs}\n} will be renamed",
"new": "New",
"old": "Old",
@@ -5800,6 +5800,7 @@
"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": {
@@ -8265,6 +8266,7 @@
"delete": "Delete",
"delete_confirm_title": "Delete {title}?",
"delete_confirm_text": "Its devices and entities will be permanently deleted.",
"delete_confirm_dependents": "{integrations} {count, plural,\n one {depends}\n other {depend}\n} on {name} and may stop working.",
"enable_debug_logging": "Enable debug logging",
"reconfigure": "Reconfigure",
"reload": "Reload",
@@ -10959,6 +10961,8 @@
"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",
@@ -11007,6 +11011,8 @@
"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%]",
@@ -12457,6 +12463,9 @@
"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%]",
@@ -0,0 +1,109 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { subscribeVisibility } from "../../../src/common/condition/subscribe-visibility";
import type { VisibilityCondition } from "../../../src/panels/lovelace/common/validate-condition";
import type { HomeAssistant } from "../../../src/types";
interface CapturedSubscription {
push: (message: { result?: boolean }) => void;
unsub: ReturnType<typeof vi.fn>;
condition: unknown;
}
let subs: CapturedSubscription[];
const tick = () =>
new Promise<void>((resolve) => {
setTimeout(resolve, 10);
});
const createHass = (userId = "user1"): HomeAssistant =>
({
connection: {
subscribeMessage: vi.fn(
(
onChange: CapturedSubscription["push"],
msg: { condition: unknown }
) => {
const unsub = vi.fn();
subs.push({ push: onChange, unsub, condition: msg.condition });
return Promise.resolve(unsub);
}
),
},
states: {},
user: { id: userId },
locale: { time_zone: "local" },
config: { time_zone: "America/New_York" },
}) as unknown as HomeAssistant;
describe("subscribeVisibility", () => {
beforeEach(() => {
subs = [];
});
it("checks client conditions again with each hass passed to update", async () => {
const onChange = vi.fn();
const conditions: VisibilityCondition[] = [
{ condition: "user", users: ["user1"] },
];
const subscription = subscribeVisibility(
createHass("user1"),
conditions,
onChange
);
await tick();
expect(onChange).toHaveBeenLastCalledWith("visible", undefined);
subscription.update(createHass("user2"));
expect(onChange).toHaveBeenLastCalledWith("hidden", undefined);
});
it("closes core subscriptions and stops reporting after unsubscribe", async () => {
const onChange = vi.fn();
const conditions: VisibilityCondition[] = [
{ condition: "state", entity: "light.kitchen", state: "on" },
];
const subscription = subscribeVisibility(
createHass(),
conditions,
onChange
);
await tick();
expect(subs).toHaveLength(1);
subs[0].push({ result: true });
expect(onChange).toHaveBeenLastCalledWith("visible", undefined);
onChange.mockClear();
subscription.unsubscribe();
await tick();
expect(subs[0].unsub).toHaveBeenCalled();
expect(onChange).not.toHaveBeenCalled();
});
it("sends the context entity to core for conditions without one", async () => {
const conditions: VisibilityCondition[] = [
{ condition: "state", state: "on" },
];
subscribeVisibility(createHass(), conditions, vi.fn(), {
entity_id: "light.kitchen",
});
await tick();
expect(subs).toHaveLength(1);
expect(subs[0].condition).toEqual({
condition: "state",
entity_id: "light.kitchen",
state: "on",
});
});
});
@@ -177,6 +177,7 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
"datasets": [
{
"animationDurationUpdate": 0,
"barMaxWidth": 50,
"color": "#4269d07F",
"cursor": "default",
"data": [
@@ -347,6 +348,7 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
},
{
"animationDurationUpdate": 0,
"barMaxWidth": 50,
"color": "#f4bd4a7F",
"cursor": "default",
"data": [
@@ -1380,6 +1382,7 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
"datasets": [
{
"animationDurationUpdate": 0,
"barMaxWidth": 50,
"color": "#4269d07F",
"cursor": "default",
"data": [
@@ -1444,6 +1447,7 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
},
{
"animationDurationUpdate": 0,
"barMaxWidth": 50,
"color": "#f4bd4a7F",
"cursor": "default",
"data": [
+44 -1
View File
@@ -1,5 +1,8 @@
import { describe, expect, it } from "vitest";
import { getConfigSubpageTitle } from "../../src/data/panel";
import {
getConfigSubpageTitle,
getSelectedPanelUrlPath,
} from "../../src/data/panel";
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
import type { HomeAssistant } from "../../src/types";
@@ -83,3 +86,43 @@ describe("getConfigSubpageTitle", () => {
).toBeUndefined();
});
});
describe("getSelectedPanelUrlPath", () => {
const urlPaths = ["lovelace", "history", "config/logs", "config/logs/raw"];
it("falls back to the first path segment", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/config/automation")).toBe(
"config"
);
expect(getSelectedPanelUrlPath(urlPaths, "/profile/general")).toBe(
"profile"
);
});
it("selects a panel whose url_path has several segments", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs")).toBe(
"config/logs"
);
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs/details")).toBe(
"config/logs"
);
});
it("prefers the most specific url_path", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/config/logs/raw")).toBe(
"config/logs/raw"
);
});
it("only matches whole segments", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/config/logsfoo")).toBe("config");
});
it("keeps matching single segment panels on their subpaths", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/lovelace/0")).toBe("lovelace");
});
it("returns an empty url_path for the root path", () => {
expect(getSelectedPanelUrlPath(urlPaths, "/")).toBe("");
});
});
@@ -0,0 +1,63 @@
import { describe, expect, it } from "vitest";
import { ClimateEntityFeature } from "../../../src/data/climate";
import { MockClimateEntity } from "../../../src/fake_data/entities/climate-entity";
const hvacAction = (state: string, current: number, target: number) =>
new MockClimateEntity({
entity_id: "climate.demo",
state,
attributes: {
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
current_temperature: current,
temperature: target,
},
}).toState().attributes.hvac_action;
// A range of 20° to 24° only, like climate.upstairs in the arsaboo demo
const rangeHvacAction = (state: string, current: number) =>
new MockClimateEntity({
entity_id: "climate.demo",
state,
attributes: {
supported_features:
ClimateEntityFeature.TARGET_TEMPERATURE +
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
current_temperature: current,
temperature: null,
target_temp_low: 20,
target_temp_high: 24,
},
}).toState().attributes.hvac_action;
describe("MockClimateEntity", () => {
it.each([
["heat", 18, 21, "heating"],
["heat", 21, 21, "idle"],
["cool", 25, 21, "cooling"],
["cool", 20, 21, "idle"],
["dry", 20, 21, "drying"],
["fan_only", 20, 21, "fan"],
["off", 18, 21, "off"],
])(
"in %s at %d° with a target of %d° is %s",
(state, current, target, action) => {
expect(hvacAction(state, current, target)).toBe(action);
}
);
it.each([
["heat", 18, "heating"],
["heat", 25, "idle"],
["cool", 25, "cooling"],
["cool", 18, "idle"],
["heat_cool", 18, "heating"],
["heat_cool", 25, "cooling"],
["auto", 22, "idle"],
])(
"in %s at %d° with a range of 20° to 24° is %s",
(state, current, action) => {
expect(rangeHvacAction(state, current)).toBe(action);
}
);
});
@@ -0,0 +1,109 @@
import { describe, expect, it } from "vitest";
import type { Condition } from "../../src/data/automation";
import type { MockHomeAssistant } from "../../src/fake_data/provide_hass";
import { provideHass } from "../../src/fake_data/provide_hass";
type Host = HTMLElement & { hass?: Partial<MockHomeAssistant> };
// `ownUpdateHass` replaces updateHass as the full demo does, see
// demo/src/ha-demo.ts
const setup = (ownUpdateHass = false) => {
const host: Host = document.createElement("div");
const overrides: Partial<MockHomeAssistant> = ownUpdateHass
? {
updateHass: (update: Partial<MockHomeAssistant>) => {
host.hass = { ...host.hass, ...update };
},
}
: {};
const hass = provideHass(host, overrides);
hass.addEntities([
{ entity_id: "light.kitchen", state: "on", attributes: {} },
{ entity_id: "light.hallway", state: "off", attributes: {} },
]);
return hass;
};
const subscribe = async (hass: MockHomeAssistant, condition: Condition) => {
const messages: unknown[] = [];
await hass.connection.subscribeMessage(
(message) => {
messages.push(message);
},
{ type: "subscribe_condition", condition }
);
return messages;
};
const kitchenOn: Condition = {
condition: "state",
entity_id: "light.kitchen",
state: "on",
};
const hallwayOn: Condition = {
condition: "state",
entity_id: "light.hallway",
state: "on",
};
describe("subscribe_condition in the mock backend", () => {
it.each([
["its own", false],
["the host's", true],
])(
"checks a condition again when a state changes, with %s updateHass",
async (_name, ownUpdateHass) => {
const hass = setup(ownUpdateHass);
const messages = await subscribe(hass, hallwayOn);
hass.addEntities({
entity_id: "light.hallway",
state: "on",
attributes: {},
});
expect(messages).toEqual([{ result: false }, { result: true }]);
}
);
it("passes a not only when none of its conditions pass, as in Core", async () => {
const hass = setup();
expect(
await subscribe(hass, {
condition: "not",
conditions: [kitchenOn, hallwayOn],
})
).toEqual([{ result: false }]);
});
it("skips disabled conditions", async () => {
const hass = setup();
expect(
await subscribe(hass, {
condition: "and",
conditions: [kitchenOn, { ...hallwayOn, enabled: false }],
})
).toEqual([{ result: true }]);
});
it("answers a not around a template with an error", async () => {
const hass = setup();
const [message] = await subscribe(hass, {
condition: "not",
conditions: [{ condition: "template", value_template: "{{ true }}" }],
});
expect(message).toHaveProperty("error");
});
});
@@ -43,6 +43,10 @@ vi.mock("../../../../src/components/ha-button", () => {
customElements.define("ha-button", class extends HTMLElement {});
return {};
});
vi.mock("../../../../src/components/chips/ha-assist-chip", () => {
customElements.define("ha-assist-chip", class extends HTMLElement {});
return {};
});
vi.mock("../../../../src/components/ha-icon-button", () => {
customElements.define("ha-icon-button", class extends HTMLElement {});
return {};