Compare commits

..
Author SHA1 Message Date
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
29 changed files with 598 additions and 542 deletions

No files matched your search

+26
View File
@@ -70,6 +70,32 @@ const ENTITIES = [
CoverEntityFeature.CLOSE_TILT,
},
},
{
entity_id: "cover.tilt_only_closed",
state: "closed",
attributes: {
friendly_name: "Tilt-only blind closed",
device_class: "blind",
assumed_state: true,
supported_features:
CoverEntityFeature.OPEN_TILT +
CoverEntityFeature.STOP_TILT +
CoverEntityFeature.CLOSE_TILT,
},
},
{
entity_id: "cover.tilt_only_open",
state: "open",
attributes: {
friendly_name: "Tilt-only blind open",
device_class: "blind",
assumed_state: true,
supported_features:
CoverEntityFeature.OPEN_TILT +
CoverEntityFeature.STOP_TILT +
CoverEntityFeature.CLOSE_TILT,
},
},
{
entity_id: "cover.tilt_slider_half",
state: "on",
+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",
+3 -2
View File
@@ -235,7 +235,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) {
@@ -1189,6 +1189,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 };
}
}
+17 -9
View File
@@ -179,6 +179,10 @@ export class HaControlCircularSlider extends LitElement {
disconnectedCallback(): void {
super.disconnectedCallback();
this._destroyListeners();
if (this._activeSlider) {
this._cancelInteraction();
}
}
private _managers: HammerManager[] = [];
@@ -248,6 +252,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 +295,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 });
}
+1
View File
@@ -238,6 +238,7 @@ export class HaGridSizeEditor extends LitElement {
grid-template-rows: auto auto;
grid-template-columns: auto 1fr;
gap: var(--ha-space-2);
padding-left: var(--ha-space-4);
}
.precise {
grid-area: precise;
+11 -3
View File
@@ -1,9 +1,9 @@
import type { TemplateResult } from "lit";
import type { PropertyValues, TemplateResult } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import type { ActionHandlerOptions } from "../../data/lovelace/action_handler";
import { actionHandler } from "../../panels/lovelace/common/directives/action-handler-directive";
import { actionHandlerBind } from "../../panels/lovelace/common/directives/action-handler-directive";
import "../ha-icon";
import "../ha-svg-icon";
@@ -56,6 +56,11 @@ export class HaTileIcon extends LitElement {
return nothing;
}
protected updated(changedProps: PropertyValues<this>): void {
super.updated(changedProps);
actionHandlerBind(this, this.actionHandlerOptions);
}
protected render(): TemplateResult {
const hasImage = Boolean(this.imageUrl);
@@ -67,7 +72,6 @@ export class HaTileIcon extends LitElement {
aria-label=${ifDefined(
this.interactive ? this.accessibleLabel : undefined
)}
.actionHandler=${actionHandler(this.actionHandlerOptions)}
>
<slot name="icon">${this._renderIcon()}</slot>
</div>
@@ -94,6 +98,7 @@ export class HaTileIcon extends LitElement {
:host([interactive]) {
-webkit-tap-highlight-color: transparent;
pointer-events: auto;
cursor: pointer;
}
:host([interactive]:active) {
transform: scale(1.2);
@@ -143,6 +148,9 @@ export class HaTileIcon extends LitElement {
transition: color 180ms ease-in-out;
pointer-events: none;
}
::slotted(:not([slot])) {
pointer-events: none;
}
.container img {
width: 100%;
height: 100%;
+51
View File
@@ -5,6 +5,9 @@ import {
} from "home-assistant-js-websocket";
import type { Store } from "home-assistant-js-websocket/dist/store";
import type { DataTableRowData } from "../components/data-table/ha-data-table";
import type { HomeAssistant } from "../types";
import type { ConfigEntry } from "./config_entries";
import type { DeviceRegistryEntry } from "./device/device_registry";
export interface BluetoothDeviceData extends DataTableRowData {
address: string;
@@ -74,6 +77,54 @@ export const isScannerStateMismatch = (state: BluetoothScannerState): boolean =>
state.requested_mode !== "auto" &&
state.current_mode !== state.requested_mode;
export interface BluetoothAdapterDevice {
device: DeviceRegistryEntry;
entry: ConfigEntry;
}
/**
* Splits the Bluetooth adapters into enabled and disabled ones. An adapter is
* a device with a Bluetooth connection that belongs to a `bluetooth` config
* entry. Config entries without such a device (for example ignored discoveries
* or removed proxies) are not adapters, unless they are disabled, so they can
* still be enabled again.
*/
export const getBluetoothAdapters = (
devices: HomeAssistant["devices"],
configEntries: ConfigEntry[]
) => {
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
const enabledDevices: BluetoothAdapterDevice[] = [];
const disabledDevices: BluetoothAdapterDevice[] = [];
const matchedEntryIds = new Set<string>();
for (const device of Object.values(devices)) {
const btConnection = device.connections.find((c) => c[0] === "bluetooth");
if (!btConnection) {
continue;
}
const entry = device.config_entries
.map((id) => entryMap.get(id))
.find((e) => e !== undefined);
if (!entry) {
continue;
}
matchedEntryIds.add(entry.entry_id);
if (entry.disabled_by !== null) {
disabledDevices.push({ device, entry });
} else {
enabledDevices.push({ device, entry });
}
}
const disabledEntriesWithoutDevice = configEntries.filter(
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
);
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
};
export const subscribeBluetoothScannersDetailsUpdates = (
conn: Connection,
store: Store<BluetoothScannersDetails>
+19 -5
View File
@@ -239,12 +239,29 @@ export interface CoverEntity extends HassEntityBase {
attributes: CoverEntityAttributes;
}
// For covers that report no value, the open or closed state tells where it is
const valueFromState = (stateObj: CoverEntity): number | undefined => {
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
return undefined;
}
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
};
export const coverCurrentValue = (
stateObj: CoverEntity,
mode: CoverControlMode
): number | undefined => {
if (mode === "tilt") {
return stateObj.attributes.current_tilt_position ?? undefined;
const tilt = stateObj.attributes.current_tilt_position;
// The state only describes the slats when the cover can't move up or down
if (
tilt != null ||
coverSupportsTiltPosition(stateObj) ||
coverHasPositionControls(stateObj)
) {
return tilt ?? undefined;
}
return valueFromState(stateObj);
}
const position = stateObj.attributes.current_position;
if (
@@ -253,10 +270,7 @@ export const coverCurrentValue = (
) {
return position ?? undefined;
}
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
return undefined;
}
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
return valueFromState(stateObj);
};
declare global {
@@ -3,8 +3,11 @@ import {
mdiImageMultipleOutline,
mdiLightningBolt,
} from "@mdi/js";
import type { ContextType } from "@lit/context";
import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { consume } from "../../common/decorators/consume";
import { consumeLocalize } from "../../common/decorators/consume-context-entry";
import type { LocalizeFunc } from "../../common/translations/localize";
import { CAMERA_STREAM_TYPE_NAMES } from "../../components/camera/ha-camera-stream-badge";
@@ -21,6 +24,8 @@ import {
type CameraStreamType,
type StreamType,
} from "../../data/camera-streams";
import { fetchCloudStatus } from "../../data/cloud";
import { apiContext, configContext } from "../../data/context";
import { haStyleDialog, haStyleDialogFixedTop } from "../../resources/styles";
import { DialogMixin } from "../dialog-mixin";
import type { CameraStreamInfoDialogParams } from "./show-dialog-camera-stream-info";
@@ -40,6 +45,34 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
@consumeLocalize()
private _localize!: LocalizeFunc;
@consume({ context: apiContext })
private _api!: ContextType<typeof apiContext>;
@consume({ context: configContext })
private _hassConfig!: ContextType<typeof configContext>;
@state() private _cloudIceServers = false;
protected firstUpdated() {
this._fetchCloudIceServers();
}
// The same check that core uses to add the cloud TURN servers
private async _fetchCloudIceServers() {
if (!isComponentLoaded(this._hassConfig.config, "cloud")) {
return;
}
try {
const status = await fetchCloudStatus(this._api.callWS);
this._cloudIceServers =
status.logged_in &&
status.active_subscription &&
status.prefs.cloud_ice_servers_enabled;
} catch (_err) {
// Without the cloud status the label stays hidden
}
}
protected render() {
if (!this.params) {
return nothing;
@@ -124,6 +157,18 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
wrap-supporting-text
>
<ha-svg-icon slot="start" .path=${icon}></ha-svg-icon>
${
type === STREAM_TYPE_WEB_RTC && this._cloudIceServers
? html`<span slot="headline" class="headline">
${CAMERA_STREAM_TYPE_NAMES[type]}
<span class="tag cloud"
>${this._localize(
"ui.dialogs.camera_stream_info.enhanced_by_cloud"
)}</span
>
</span>`
: nothing
}
${
current
? html`<span slot="end" class="tag current"
@@ -188,6 +233,20 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
color: var(--secondary-text-color);
}
.headline {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--ha-space-2);
/* The row keeps the headline on one line, but a long tag must wrap */
white-space: normal;
}
.tag.cloud {
background-color: var(--ha-color-fill-primary-quiet-resting);
color: var(--ha-color-on-primary-quiet);
}
.tag.current {
background-color: var(--ha-color-fill-success-quiet-resting);
color: var(--ha-color-on-success-quiet);
@@ -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;
@@ -95,6 +95,23 @@ class DialogStartupProgress extends DialogMixin(LitElement) {
.slice(0, MAX_SLOWEST);
});
}
if (changedProps.has("_progress") || changedProps.has("_setups")) {
this._loadTitles();
}
}
private _loadTitles() {
const progress = this._progress
? this._computeProgress(this._progress, this._config.config.state)
: undefined;
const domains = [
...(progress?.active.map(([domain]) => domain) ?? []),
...(progress?.failed ?? []),
...(this._setups?.map((setup) => setup.domain) ?? []),
];
if (domains.length) {
this._i18n.loadBackendTranslation("title", domains);
}
}
protected render() {
+19 -14
View File
@@ -1,9 +1,21 @@
import { supportsFeatureFromAttributes } from "../../common/entity/supports-feature";
import { ClimateEntityFeature } from "../../data/climate";
import {
CLIMATE_HVAC_ACTION_TO_MODE,
ClimateEntityFeature,
} from "../../data/climate";
import type { HvacAction } from "../../data/climate";
import { MockBaseEntity } from "./base-entity";
import type { EntityAttributes } from "./types";
// Reverse mapping: mode → action (e.g. "cool" → "cooling")
const HVAC_MODE_TO_ACTION: Partial<Record<string, HvacAction>> =
Object.fromEntries(
Object.entries(CLIMATE_HVAC_ACTION_TO_MODE).map(([action, mode]) => [
mode,
action as HvacAction,
])
);
export class MockClimateEntity extends MockBaseEntity {
public async handleService(
domain: string,
@@ -231,13 +243,10 @@ export class MockClimateEntity extends MockBaseEntity {
return "off";
}
// Heat and cool get their action from the temperatures below
if (state === "dry") {
return "drying";
}
if (state === "fan_only") {
return "fan";
// Use the reverse mapping for direct mode → action (e.g. "fan_only" → "fan", "dry" → "drying")
const directAction = HVAC_MODE_TO_ACTION[state];
if (directAction && directAction !== "idle" && directAction !== "off") {
return directAction;
}
if (
@@ -267,17 +276,13 @@ export class MockClimateEntity extends MockBaseEntity {
const current = attrs.current_temperature;
const lowTarget = attrs.target_temp_low;
const highTarget = attrs.target_temp_high;
// Heat mode can only heat and cool mode only cool, while auto and
// heat_cool use both ends of the range
if (current != null) {
if (state !== "cool" && lowTarget != null && lowTarget > current) {
if (lowTarget != null && lowTarget > current) {
return "heating";
}
if (state !== "heat" && highTarget != null && highTarget < current) {
if (highTarget != null && highTarget < current) {
return "cooling";
}
return "idle";
}
}
-16
View File
@@ -607,22 +607,6 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
atmospheric_pressure: {
default: "mdi:thermometer-lines",
},
battery: {
default: "mdi:battery-unknown",
range: {
"0": "mdi:battery-alert",
"10": "mdi:battery-10",
"20": "mdi:battery-20",
"30": "mdi:battery-30",
"40": "mdi:battery-40",
"50": "mdi:battery-50",
"60": "mdi:battery-60",
"70": "mdi:battery-70",
"80": "mdi:battery-80",
"90": "mdi:battery-90",
"100": "mdi:battery",
},
},
carbon_dioxide: {
default: "mdi:molecule-co2",
},
-71
View File
@@ -27,12 +27,6 @@ import {
import { updateHassGroups } from "../data/context/updateContext";
import type { IconCategory } from "../data/icons";
import type { EntityRegistryDisplayEntry } from "../data/entity/entity_registry";
import { evaluateConditionsLocally } from "../common/condition/evaluate-locally";
import {
isLogicalCondition,
logicalChildren,
} from "../common/condition/translate";
import type { VisibilityCondition } from "../panels/lovelace/common/validate-condition";
import {
DateFormat,
FirstWeekday,
@@ -59,24 +53,6 @@ import type { EntityInput } from "./entities/types";
const ensureArray = <T>(val: T | T[]): T[] =>
Array.isArray(val) ? val : [val];
// Core's `not` passes when none of its conditions pass, and the frontend's
// unless all of them pass, so each `not` gets one `or` of its conditions
const withCoreNot = (condition: VisibilityCondition): VisibilityCondition => {
if (!isLogicalCondition(condition) || condition.conditions === undefined) {
return condition;
}
const conditions = logicalChildren(condition).map(withCoreNot);
return {
...condition,
conditions:
condition.condition === "not"
? [{ condition: "or", conditions }]
: conditions,
};
};
type MockServiceCallback = (
data: Record<string, any> | undefined,
target: Record<string, any> | undefined,
@@ -245,8 +221,6 @@ export const provideHass = (
return lazyLoaderPromise;
};
const eventListeners: Record<string, ((event) => void)[]> = {};
// Checks each subscribed condition again, for when the states change.
const conditionChecks = new Set<() => void>();
const entities = {};
let localResources: Resources = {};
@@ -690,51 +664,6 @@ export const provideHass = (
resources: category === "entity_component" ? ENTITY_COMPONENT_ICONS : {},
}));
// Core answers the visibility conditions of cards and rows that depend on
// states. Here they are checked against the mock states, as the frontend
// does itself before Core answers, and again each time the states change.
// A condition only Core can check, such as a template, gets an error, so
// a `not` around it can't show the card.
hassObj.mockWS(
"subscribe_condition",
({ condition }: { condition: VisibilityCondition }, _hass, onChange) => {
const check = () => {
const result = evaluateConditionsLocally(
[withCoreNot(condition)],
hass(),
{}
);
onChange?.(
result === undefined
? {
error: {
code: "not_supported",
message: "The demo can't check this condition",
},
}
: { result }
);
};
conditionChecks.add(check);
check();
return () => conditionChecks.delete(check);
}
);
// Check the conditions again after each state update, also when the host
// passed its own updateHass, as the demo does
const applyUpdate = hassObj.updateHass;
hassObj.updateHass = (obj: Partial<MockHomeAssistant>) => {
applyUpdate(obj);
if (obj.states) {
conditionChecks.forEach((check) => check());
}
};
// Set hass if required
if (setHassProperty) {
elements.forEach((el) => {
@@ -16,12 +16,14 @@ import "../../../../../components/item/ha-list-item-base";
import "../../../../../components/item/ha-list-item-button";
import "../../../../../components/list/ha-list-base";
import type {
BluetoothAdapterDevice,
BluetoothAllocationsData,
BluetoothScannerState,
BluetoothScannersDetails,
HaScannerType,
} from "../../../../../data/bluetooth";
import {
getBluetoothAdapters,
isScannerStateMismatch,
subscribeBluetoothConnectionAllocations,
subscribeBluetoothScannerState,
@@ -176,52 +178,11 @@ export class BluetoothAdapterInfoPage extends LitElement {
}
}
private _getBluetoothDevices = memoizeOne(
(devices: HomeAssistant["devices"], configEntries: ConfigEntry[]) => {
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
const enabledDevices: {
device: DeviceRegistryEntry;
entry: ConfigEntry;
}[] = [];
const disabledDevices: {
device: DeviceRegistryEntry;
entry: ConfigEntry;
}[] = [];
const matchedEntryIds = new Set<string>();
for (const device of Object.values(devices)) {
const btConnection = device.connections.find(
(c) => c[0] === "bluetooth"
);
if (!btConnection) {
continue;
}
const entry = device.config_entries
.map((id) => entryMap.get(id))
.find((e) => e !== undefined);
if (!entry) {
continue;
}
matchedEntryIds.add(entry.entry_id);
if (entry.disabled_by !== null) {
disabledDevices.push({ device, entry });
} else {
enabledDevices.push({ device, entry });
}
}
const disabledEntriesWithoutDevice = configEntries.filter(
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
);
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
}
);
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
protected render(): TemplateResult {
const { enabledDevices, disabledDevices, disabledEntriesWithoutDevice } =
this._getBluetoothDevices(this.hass.devices, this._configEntries);
this._getBluetoothAdapters(this.hass.devices, this._configEntries);
return html`
<hass-subpage
@@ -301,9 +262,7 @@ export class BluetoothAdapterInfoPage extends LitElement {
`;
}
private _renderAdaptersList(
devices: { device: DeviceRegistryEntry; entry: ConfigEntry }[]
) {
private _renderAdaptersList(devices: BluetoothAdapterDevice[]) {
if (devices.length === 0) {
return html`<ha-list-item-base>
<div slot="headline">
@@ -11,18 +11,24 @@ import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import type { CSSResultGroup, TemplateResult } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import "../../../../../components/animation/ha-fade-in";
import "../../../../../components/ha-alert";
import "../../../../../components/ha-button";
import "../../../../../components/ha-card";
import "../../../../../components/ha-icon-next";
import "../../../../../components/ha-svg-icon";
import "../../../../../components/item/ha-list-item-button";
import "../../../../../components/list/ha-list-nav";
import "../../../../../components/skeleton/ha-skeleton";
import "../../../../../components/skeleton/ha-skeleton-text";
import type {
BluetoothAllocationsData,
BluetoothDeviceData,
BluetoothScannerState,
} from "../../../../../data/bluetooth";
import {
getBluetoothAdapters,
isScannerStateMismatch,
subscribeBluetoothAdvertisements,
subscribeBluetoothConnectionAllocations,
@@ -34,6 +40,7 @@ import "../../../../../layouts/hass-subpage";
import { haStyle } from "../../../../../resources/styles";
import type { HomeAssistant, Route } from "../../../../../types";
import { brandsUrl } from "../../../../../util/brands-url";
import { getWsErrorMessage } from "../../../../../util/ws-error";
@customElement("bluetooth-config-dashboard")
export class BluetoothConfigDashboard extends LitElement {
@@ -45,7 +52,9 @@ export class BluetoothConfigDashboard extends LitElement {
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
@state() private _configEntries: ConfigEntry[] = [];
@state() private _configEntries?: ConfigEntry[];
@state() private _configEntriesError?: string;
@state() private _connectionAllocationData: BluetoothAllocationsData[] = [];
@@ -69,11 +78,17 @@ export class BluetoothConfigDashboard extends LitElement {
}
}
private async _loadConfigEntries(): Promise<void> {
this._configEntries = await getConfigEntries(this.hass, {
domain: "bluetooth",
});
}
private _loadConfigEntries = async (): Promise<void> => {
this._configEntriesError = undefined;
try {
this._configEntries = await getConfigEntries(this.hass, {
domain: "bluetooth",
});
} catch (err: unknown) {
this._configEntriesError =
getWsErrorMessage(err) || this.hass.localize("ui.common.unknown_error");
}
};
private async _subscribeBluetoothConnectionAllocations(): Promise<void> {
if (this._unsubConnectionAllocations) {
@@ -131,11 +146,17 @@ export class BluetoothConfigDashboard extends LitElement {
}
}
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
protected render(): TemplateResult {
const enabledEntries = this._configEntries.filter(
(e) => e.disabled_by === null
);
const adapterCount = enabledEntries.length;
// The device registry is null until it has loaded.
const adapterCount =
this._configEntries && this.hass.devices
? this._getBluetoothAdapters(this.hass.devices, this._configEntries)
.enabledDevices.length
: undefined;
const error = this._configEntriesError;
const loading = adapterCount === undefined && !error;
const totalSlots = this._connectionAllocationData.reduce(
(sum, a) => sum + a.slots,
0
@@ -163,40 +184,67 @@ export class BluetoothConfigDashboard extends LitElement {
back-path="/config/connectivity"
>
<div class="container">
<ha-card class="content network-status">
<div class="card-content">
<div class="heading">
<div class="icon ${status}">
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
</div>
<div class="details">
${this.hass.localize(
`ui.panel.config.bluetooth.status_${status}`
)}<br />
<small>
${this.hass.localize(
"ui.panel.config.bluetooth.connections_summary",
{ used: usedSlots, total: totalSlots }
)}
</small>
</div>
<img
class="logo"
alt="Bluetooth"
crossorigin="anonymous"
referrerpolicy="no-referrer"
src=${brandsUrl(
{
domain: "bluetooth",
type: "icon",
darkOptimized: this.hass.themes?.darkMode,
},
this.hass.auth.data.hassUrl
)}
/>
</div>
</div>
</ha-card>
${
error
? html`<ha-alert alert-type="error" class="content">
${error}
<ha-button
slot="action"
appearance="plain"
@click=${this._loadConfigEntries}
>
${this.hass.localize("ui.common.retry")}
</ha-button>
</ha-alert>`
: html`<ha-card class="content network-status">
<div class="card-content">
<div class="heading">
${
loading
? html`<ha-fade-in .duration=${300} easing="ease-in">
<ha-skeleton
class="status-icon"
role="progressbar"
aria-label=${this.hass.localize("ui.common.loading")}
></ha-skeleton>
</ha-fade-in>`
: html`<div class="icon ${status}">
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
</div>`
}
<div class="details">
${
loading
? this._renderTextSkeleton()
: this.hass.localize(
`ui.panel.config.bluetooth.status_${status}`
)
}<br />
<small>
${this.hass.localize(
"ui.panel.config.bluetooth.connections_summary",
{ used: usedSlots, total: totalSlots }
)}
</small>
</div>
<img
class="logo"
alt="Bluetooth"
crossorigin="anonymous"
referrerpolicy="no-referrer"
src=${brandsUrl(
{
domain: "bluetooth",
type: "icon",
darkOptimized: this.hass.themes?.darkMode,
},
this.hass.auth.data.hassUrl
)}
/>
</div>
</div>
</ha-card>`
}
<ha-card class="network-card">
<div class="card-header">
@@ -224,10 +272,17 @@ export class BluetoothConfigDashboard extends LitElement {
.path=${mdiAccessPoint}
></ha-svg-icon>
<div slot="headline">
${this.hass.localize(
"ui.panel.config.bluetooth.adapters_count",
{ count: adapterCount }
)}
${
// A link needs its name, so no skeleton while loading
adapterCount === undefined
? this.hass.localize(
"ui.panel.config.bluetooth.adapter_info_title"
)
: this.hass.localize(
"ui.panel.config.bluetooth.adapters_count",
{ count: adapterCount }
)
}
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-list-item-button>
@@ -268,6 +323,15 @@ export class BluetoothConfigDashboard extends LitElement {
`;
}
private _renderTextSkeleton() {
return html`<ha-fade-in .duration=${300} easing="ease-in">
<ha-skeleton-text
role="progressbar"
aria-label=${this.hass.localize("ui.common.loading")}
></ha-skeleton-text>
</ha-fade-in>`;
}
static get styles(): CSSResultGroup {
return [
haStyle,
@@ -276,7 +340,9 @@ export class BluetoothConfigDashboard extends LitElement {
padding: var(--ha-space-2) var(--ha-content-gutter) var(--ha-space-4);
}
ha-card {
ha-card,
ha-alert {
display: block;
margin: 0px auto var(--ha-space-4);
max-width: var(--ha-content-width-narrow);
}
@@ -326,6 +392,13 @@ export class BluetoothConfigDashboard extends LitElement {
--icon-color: var(--primary-color);
}
.network-status div.heading .status-icon {
display: block;
width: var(--ha-space-10);
height: var(--ha-space-10);
--ha-skeleton-border-radius: var(--ha-border-radius-2xl);
}
.network-status div.heading .icon.online {
--icon-color: var(--success-color);
}
+1 -73
View File
@@ -1,8 +1,7 @@
import { ResizeController } from "@lit-labs/observers/resize-controller";
import type { HassConfig } from "home-assistant-js-websocket";
import type { PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, query, state } from "lit/decorators";
import { customElement, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { consume } from "../../../common/decorators/consume";
import { transform } from "../../../common/decorators/transform";
@@ -30,21 +29,8 @@ import {
isValidTimeZone,
} from "./hui-date-card-helpers";
// The smallest size the large date shrinks to, in pixels
const MIN_LARGE_DATE_FONT_SIZE = 12;
@customElement("hui-date-card")
export class HuiDateCard extends LitElement implements LovelaceCard {
// Each resize of the date updates the card, which fits the large date again.
// The card itself is inline, which a resize observer can't follow.
private _resizeController = new ResizeController(this, { target: null });
@query(".date-wrapper") private _wrapper?: HTMLElement;
@query(".date-title") private _title?: HTMLElement;
@query(".date-text") private _text?: HTMLElement;
public static async getConfigElement(): Promise<LovelaceCardEditor> {
await import("../editor/config-elements/hui-date-card-editor");
return document.createElement("hui-date-card-editor");
@@ -174,63 +160,6 @@ export class HuiDateCard extends LitElement implements LovelaceCard {
}
}
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
this._fitLargeDate();
}
// A long date at the large size can be wider and higher than the card, so
// it shrinks until it fits, as large as it can be
private _fitLargeDate() {
const wrapper = this._wrapper;
const text = this._text;
if (!wrapper || !text) {
return;
}
text.style.removeProperty("font-size");
if (this._config?.date_size !== "large") {
return;
}
const wrapperStyle = getComputedStyle(wrapper);
// The full height of the title, as a large date squeezes it
const availableHeight =
wrapper.clientHeight -
parseFloat(wrapperStyle.paddingTop) -
parseFloat(wrapperStyle.paddingBottom) -
(this._title
? this._title.scrollHeight + parseFloat(wrapperStyle.rowGap)
: 0);
const fits = () =>
text.scrollWidth <= text.clientWidth &&
text.scrollHeight <= availableHeight;
if (fits()) {
return;
}
let fitting = MIN_LARGE_DATE_FONT_SIZE;
let tooLarge = parseFloat(getComputedStyle(text).fontSize);
while (tooLarge - fitting > 0.5) {
const size = (fitting + tooLarge) / 2;
text.style.fontSize = `${size}px`;
if (fits()) {
fitting = size;
} else {
tooLarge = size;
}
}
text.style.fontSize = `${fitting}px`;
}
private _clearMidnightTimer() {
if (this._midnightTimer) {
clearTimeout(this._midnightTimer);
@@ -290,7 +219,6 @@ export class HuiDateCard extends LitElement implements LovelaceCard {
class="date-wrapper ${
this._config.date_size ? `size-${this._config.date_size}` : ""
}"
${this._resizeController.target()}
>
${
this._config.title !== undefined
@@ -504,7 +504,7 @@ export class HaGridLayoutSlider extends LitElement {
left 180ms ease-in-out,
bottom 180ms ease-in-out;
--handle-spacing: calc(2 * var(--handle-margin) + var(--handle-size));
--slider-tooltip-margin: 0px;
--slider-tooltip-margin: var(--ha-space-1);
--slider-tooltip-range: 100%;
--slider-tooltip-offset: 0px;
--slider-tooltip-position: calc(
@@ -420,7 +420,7 @@ export class HuiCardLayoutEditor extends LitElement {
}
ha-grid-size-picker {
display: block;
margin: 16px auto;
margin: var(--ha-space-4) auto;
direction: ltr;
}
`,
@@ -1,6 +1,6 @@
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { customElement, state } from "lit/decorators";
import { DOMAINS_TOGGLE } from "../../../common/const";
import { computeDomain } from "../../../common/entity/compute_domain";
import "../../../components/ha-button";
@@ -29,7 +29,7 @@ const EMPTY_STATE_OBJ = {
@customElement("hui-button-row")
export class HuiButtonRow extends LitElement implements LovelaceRow {
@property({ attribute: false }) public hass?: HomeAssistant;
public hass?: HomeAssistant;
@state() private _config?: ButtonRowConfig;
+21 -3
View File
@@ -28,12 +28,20 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
private _startupToastKey?: string;
private _startupDetailsOpen = false;
private _disconnectedTimeout?: number;
protected firstUpdated(changedProps: PropertyValues<this>) {
super.firstUpdated(changedProps);
// Need to load in advance because when disconnected, can't dynamically load code.
setTimeout(() => import("../managers/notification-manager"), 5000);
this.addEventListener("dialog-closed", (ev) => {
if (ev.detail.dialog === "dialog-startup-progress") {
this._startupDetailsOpen = false;
this._updateStartupProgress();
}
});
}
updated(changedProperties: PropertyValues<this>) {
@@ -135,6 +143,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
// Wait until the translations are available.
if (
!this._startupProgressVisible ||
this._startupDetailsOpen ||
!this.hass!.localize("ui.startup_progress.starting")
) {
return;
@@ -163,13 +172,19 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
? {
text: { translationKey: "ui.startup_progress.details" },
icon: mdiInformationOutline,
keepOpen: true,
action: () => showStartupProgressDialog(this),
action: () => this._showStartupDetails(),
}
: undefined,
});
}
// Toasts always show above dialogs, so the toast is hidden while the details are open.
private _showStartupDetails() {
this._startupDetailsOpen = true;
this._startupToastKey = undefined;
showStartupProgressDialog(this);
}
// Keeps the subscription, so the completion toast still reflects late failures.
private _hideStartupProgress() {
this._startupProgressVisible = false;
@@ -193,6 +208,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
);
this._hideStartupProgress();
this._unsubscribeBootstrapProgress();
if (this._startupDetailsOpen) {
return;
}
const issues = failed.length;
showToast(this, {
id: SERVER_STARTUP_TOAST_ID,
@@ -205,7 +223,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
action: this.hass!.user?.is_admin
? {
text: this.hass!.localize("ui.notification_toast.details"),
action: () => showStartupProgressDialog(this),
action: () => this._showStartupDetails(),
}
: undefined,
});
+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,
},
+1
View File
@@ -2857,6 +2857,7 @@
"in_use": "In use",
"connecting": "Connecting",
"not_supported_count": "Not supported by this camera ({count})",
"enhanced_by_cloud": "Enhanced by Home Assistant Link",
"description": {
"web_rtc": "Real-time video with the lowest delay, usually below a second. The video takes the most direct way from the camera to your device, which can need extra network setup when you are away from home. Needed to talk to the camera.",
"hls": "The video is sent in short pieces through Home Assistant. It works on almost every network and device, but is a few seconds behind. Used while WebRTC connects, or when WebRTC is not available.",
+57 -1
View File
@@ -1,7 +1,12 @@
import { describe, expect, it } from "vitest";
import type { BluetoothScannerState } from "../../src/data/bluetooth";
import { isScannerStateMismatch } from "../../src/data/bluetooth";
import {
getBluetoothAdapters,
isScannerStateMismatch,
} from "../../src/data/bluetooth";
import type { ConfigEntry } from "../../src/data/config_entries";
import type { DeviceRegistryEntry } from "../../src/data/device/device_registry";
const state = (
overrides: Partial<BluetoothScannerState>
@@ -63,3 +68,54 @@ describe("isScannerStateMismatch", () => {
).toBe(false);
});
});
describe("getBluetoothAdapters", () => {
const entry = (
entry_id: string,
overrides: Partial<ConfigEntry> = {}
): ConfigEntry =>
({
entry_id,
domain: "bluetooth",
source: "user",
disabled_by: null,
...overrides,
}) as ConfigEntry;
const device = (
id: string,
configEntries: string[],
connections: [string, string][] = [["bluetooth", id]]
): DeviceRegistryEntry =>
({
id,
config_entries: configEntries,
connections,
}) as DeviceRegistryEntry;
it("only counts entries with a Bluetooth device as adapters", () => {
const entries = [
entry("proxy"),
entry("ignored", { source: "ignore" }),
entry("removed"),
entry("disabled", { disabled_by: "user" }),
entry("disabled-without-device", { disabled_by: "user" }),
];
const devices = {
proxy: device("proxy", ["esphome", "proxy"]),
disabled: device("disabled", ["disabled"]),
"no-bluetooth": device("no-bluetooth", ["proxy"], [["mac", "x"]]),
other: device("other", ["other-integration"]),
};
const result = getBluetoothAdapters(devices, entries);
expect(result.enabledDevices.map((a) => a.device.id)).toEqual(["proxy"]);
expect(result.disabledDevices.map((a) => a.device.id)).toEqual([
"disabled",
]);
expect(result.disabledEntriesWithoutDevice.map((e) => e.entry_id)).toEqual([
"disabled-without-device",
]);
});
});
+66
View File
@@ -0,0 +1,66 @@
import { describe, expect, it } from "vitest";
import type { CoverEntity } from "../../src/data/cover";
import { CoverEntityFeature, coverCurrentValue } from "../../src/data/cover";
const TILT_FEATURES =
CoverEntityFeature.OPEN_TILT +
CoverEntityFeature.CLOSE_TILT +
CoverEntityFeature.STOP_TILT;
const cover = (
state: string,
supportedFeatures: number,
attributes: Partial<CoverEntity["attributes"]> = {}
): CoverEntity =>
({
entity_id: "cover.blind",
state,
attributes: { supported_features: supportedFeatures, ...attributes },
}) as CoverEntity;
describe("coverCurrentValue", () => {
it("uses the state for the tilt of a tilt-only cover without a tilt position", () => {
expect(coverCurrentValue(cover("closed", TILT_FEATURES), "tilt")).toBe(0);
expect(coverCurrentValue(cover("opening", TILT_FEATURES), "tilt")).toBe(0);
expect(coverCurrentValue(cover("open", TILT_FEATURES), "tilt")).toBe(100);
expect(coverCurrentValue(cover("closing", TILT_FEATURES), "tilt")).toBe(
100
);
});
it("has no tilt when the state of a tilt-only cover is unknown", () => {
expect(
coverCurrentValue(cover("unknown", TILT_FEATURES), "tilt")
).toBeUndefined();
expect(
coverCurrentValue(cover("unavailable", TILT_FEATURES), "tilt")
).toBeUndefined();
});
it("prefers the reported tilt position", () => {
expect(
coverCurrentValue(
cover("closed", TILT_FEATURES, { current_tilt_position: 30 }),
"tilt"
)
).toBe(30);
});
it("does not use the state for the tilt when the cover also moves up and down", () => {
expect(
coverCurrentValue(
cover("closed", TILT_FEATURES + CoverEntityFeature.OPEN),
"tilt"
)
).toBeUndefined();
});
it("does not use the state for the tilt when the cover can set its tilt position", () => {
expect(
coverCurrentValue(
cover("closed", TILT_FEATURES + CoverEntityFeature.SET_TILT_POSITION),
"tilt"
)
).toBeUndefined();
});
});
@@ -1,63 +0,0 @@
import { describe, expect, it } from "vitest";
import { ClimateEntityFeature } from "../../../src/data/climate";
import { MockClimateEntity } from "../../../src/fake_data/entities/climate-entity";
const hvacAction = (state: string, current: number, target: number) =>
new MockClimateEntity({
entity_id: "climate.demo",
state,
attributes: {
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
current_temperature: current,
temperature: target,
},
}).toState().attributes.hvac_action;
// A range of 20° to 24° only, like climate.upstairs in the arsaboo demo
const rangeHvacAction = (state: string, current: number) =>
new MockClimateEntity({
entity_id: "climate.demo",
state,
attributes: {
supported_features:
ClimateEntityFeature.TARGET_TEMPERATURE +
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
current_temperature: current,
temperature: null,
target_temp_low: 20,
target_temp_high: 24,
},
}).toState().attributes.hvac_action;
describe("MockClimateEntity", () => {
it.each([
["heat", 18, 21, "heating"],
["heat", 21, 21, "idle"],
["cool", 25, 21, "cooling"],
["cool", 20, 21, "idle"],
["dry", 20, 21, "drying"],
["fan_only", 20, 21, "fan"],
["off", 18, 21, "off"],
])(
"in %s at %d° with a target of %d° is %s",
(state, current, target, action) => {
expect(hvacAction(state, current, target)).toBe(action);
}
);
it.each([
["heat", 18, "heating"],
["heat", 25, "idle"],
["cool", 25, "cooling"],
["cool", 18, "idle"],
["heat_cool", 18, "heating"],
["heat_cool", 25, "cooling"],
["auto", 22, "idle"],
])(
"in %s at %d° with a range of 20° to 24° is %s",
(state, current, action) => {
expect(rangeHvacAction(state, current)).toBe(action);
}
);
});
@@ -1,109 +0,0 @@
import { describe, expect, it } from "vitest";
import type { Condition } from "../../src/data/automation";
import type { MockHomeAssistant } from "../../src/fake_data/provide_hass";
import { provideHass } from "../../src/fake_data/provide_hass";
type Host = HTMLElement & { hass?: Partial<MockHomeAssistant> };
// `ownUpdateHass` replaces updateHass as the full demo does, see
// demo/src/ha-demo.ts
const setup = (ownUpdateHass = false) => {
const host: Host = document.createElement("div");
const overrides: Partial<MockHomeAssistant> = ownUpdateHass
? {
updateHass: (update: Partial<MockHomeAssistant>) => {
host.hass = { ...host.hass, ...update };
},
}
: {};
const hass = provideHass(host, overrides);
hass.addEntities([
{ entity_id: "light.kitchen", state: "on", attributes: {} },
{ entity_id: "light.hallway", state: "off", attributes: {} },
]);
return hass;
};
const subscribe = async (hass: MockHomeAssistant, condition: Condition) => {
const messages: unknown[] = [];
await hass.connection.subscribeMessage(
(message) => {
messages.push(message);
},
{ type: "subscribe_condition", condition }
);
return messages;
};
const kitchenOn: Condition = {
condition: "state",
entity_id: "light.kitchen",
state: "on",
};
const hallwayOn: Condition = {
condition: "state",
entity_id: "light.hallway",
state: "on",
};
describe("subscribe_condition in the mock backend", () => {
it.each([
["its own", false],
["the host's", true],
])(
"checks a condition again when a state changes, with %s updateHass",
async (_name, ownUpdateHass) => {
const hass = setup(ownUpdateHass);
const messages = await subscribe(hass, hallwayOn);
hass.addEntities({
entity_id: "light.hallway",
state: "on",
attributes: {},
});
expect(messages).toEqual([{ result: false }, { result: true }]);
}
);
it("passes a not only when none of its conditions pass, as in Core", async () => {
const hass = setup();
expect(
await subscribe(hass, {
condition: "not",
conditions: [kitchenOn, hallwayOn],
})
).toEqual([{ result: false }]);
});
it("skips disabled conditions", async () => {
const hass = setup();
expect(
await subscribe(hass, {
condition: "and",
conditions: [kitchenOn, { ...hallwayOn, enabled: false }],
})
).toEqual([{ result: true }]);
});
it("answers a not around a template with an error", async () => {
const hass = setup();
const [message] = await subscribe(hass, {
condition: "not",
conditions: [{ condition: "template", value_template: "{{ true }}" }],
});
expect(message).toHaveProperty("error");
});
});
@@ -284,13 +284,6 @@ describe("browseLinkFromUrl", () => {
});
});
it("filters on no integration category for an empty one", () => {
expect(
browseLinkFromUrl("?integration_category=")?.filters
.integration_category ?? []
).toEqual([]);
});
it("keeps what was picked for a link that says nothing about browsing", () => {
expect(
browseLinkFromUrl("?owner=hacs&repository=integration")
@@ -299,13 +292,6 @@ describe("browseLinkFromUrl", () => {
});
describe("filtersOfTab", () => {
it("keeps the integration category on every tab", () => {
expect(
filtersOfTab({ integration_category: ["energy"] }, "installed")
.integration_category
).toEqual(["energy"]);
});
it("only offers statuses something installed can have on the installed tab", () => {
expect(statusesOfTab("installed")).toEqual([
"pending-restart",