Compare commits

..
Author SHA1 Message Date
WendelinandClaude Opus 5.5 ac1aa4db75 Show the blueprint code in its own dialog on import
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 09:52:24 +01:00
WendelinandClaude Opus 5.5 57d73d236f Widen the dashboard editors in YAML mode (#56273)
* Widen the dashboard editors in YAML mode

Switching to the code editor now makes the card, badge, section and
view editors as wide as the screen allows, animated like the enlarge
button. The card and badge editors enlarge as if the button was
pressed, so Shrink undoes it, and switching back restores the width
from before. On desktop the code editor is also at least 500px high,
so a short config no longer gives a wide but flat dialog.

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

* Cap the view editor's code editor to the dialog height

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-12-01 09:55:01 +02:00
Rodrigo Roque 336259f6d2 Keep the weather temperature unit inside the card and more info dialog (#56146) 2026-12-01 07:24:45 +00:00
Lazizbek Ergashev 1882e154fe Don't report a dropped connection as a failed update (#56300) 2026-12-01 08:42:01 +02:00
renovate[bot] baa067caf0 Update pnpm to v12.24.0 (#56302)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-01 06:22:14 +00:00
renovate[bot] 07b5d9e98c Update babel monorepo to v8.1.4 (#56301)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-12-01 06:21:50 +00:00
Felipe Santos f2b2c92bdd Keep the whole dependents warning inside its plural (#56295) 2026-11-30 19:50:04 +01:00
renovate[bot] 33ef19dac1 Update dependency eslint to v10.16.0 (#56297)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-30 20:35:43 +02:00
Bram KragtenandClaude Opus 5.5 1e797c345c Fix the remote access card title and the webhooks help link (#56290)
Fix remote access card title and webhooks help link

The remote access card used "Remote connection" while its page, the
overview row and onboarding all say "Remote access". Use the page title
for the card and its switch, and drop the unused string.

The webhooks "Learn more" link pointed to nabucasa.com/config/webhooks
without a trailing slash, which returns a 404. Only the form with the
slash redirects to the support article, like the other Nabu Casa links.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-30 18:46:11 +01:00
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
26 changed files with 1020 additions and 746 deletions

No files matched your search

+5 -5
View File
@@ -40,7 +40,7 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "8.1.3",
"@babel/runtime": "8.1.4",
"@braintree/sanitize-url": "7.1.2",
"@codemirror/autocomplete": "6.20.4",
"@codemirror/commands": "6.11.2",
@@ -136,13 +136,13 @@
},
"devDependencies": {
"@ampproject/remapping": "2.3.0",
"@babel/core": "8.1.3",
"@babel/core": "8.1.4",
"@babel/helper-compilation-targets": "8.0.7",
"@babel/helper-define-polyfill-provider": "1.0.0",
"@babel/plugin-transform-class-properties": "8.0.1",
"@babel/plugin-transform-private-methods": "8.0.1",
"@babel/plugin-transform-runtime": "8.1.2",
"@babel/preset-env": "8.0.7",
"@babel/preset-env": "8.1.4",
"@bundle-stats/plugin-webpack-filter": "4.23.1",
"@eslint/js": "10.0.1",
"@gfx/zopfli": "1.0.15",
@@ -177,7 +177,7 @@
"browserslist-useragent-regexp": "4.1.4",
"core-js-compat": "3.51.0",
"del": "9.0.1",
"eslint": "10.15.0",
"eslint": "10.16.0",
"eslint-config-prettier": "10.1.9",
"eslint-import-resolver-webpack": "0.13.11",
"eslint-plugin-import-x": "4.18.1",
@@ -222,7 +222,7 @@
"webpackbar": "7.0.0",
"workbox-build": "7.4.1"
},
"packageManager": "[email protected]3.0",
"packageManager": "[email protected]4.0",
"volta": {
"node": "24.22.3"
}
+521 -526
View File
File diff suppressed because it is too large. Load diff
@@ -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();
},
};
};
-47
View File
@@ -1,47 +0,0 @@
/**
* How long after the full screen button the companion apps hide the page for
* the change, and after that how long they keep it hidden. A later hide ends
* streams as usual.
*/
export const FULLSCREEN_ENTER_TIME = 1000;
let enterStart = 0;
let enterId = 0;
// The last entering each stream let a hidden page through for
const claimedEnters = new WeakMap<object, number>();
/**
* Marks that the full screen button was pressed to enter full screen. The
* companion apps hide the page for a moment then, which shouldn't end a
* stream. Leaving full screen isn't marked, so locking the phone or leaving
* the app right after it always ends the streams.
*/
export const startEnteringFullscreen = () => {
enterId++;
enterStart = Date.now();
};
/** Ends it early, like when the browser denies full screen. */
export const cancelEnteringFullscreen = () => {
enterStart = 0;
};
export const isEnteringFullscreen = () =>
Date.now() - enterStart < FULLSCREEN_ENTER_TIME;
/**
* Whether the page is hidden by entering full screen, which hides it only
* once. Any later hiding is the user leaving, so each stream gets true only
* once per entering.
*/
export const claimFullscreenEnterHide = (stream: object): boolean => {
if (!isEnteringFullscreen() || claimedEnters.get(stream) === enterId) {
return false;
}
claimedEnters.set(stream, enterId);
// Counts from here, so the video still plays on when the page shows again
enterStart = Date.now();
return true;
};
+8 -40
View File
@@ -17,17 +17,11 @@ import { consumeLocalize } from "../../common/decorators/consume-context-entry";
import { storage } from "../../common/decorators/storage";
import { deepActiveElement } from "../../common/dom/deep-active-element";
import { fireEvent, type HASSDomEvent } from "../../common/dom/fire_event";
import {
cancelEnteringFullscreen,
isEnteringFullscreen,
startEnteringFullscreen,
} from "../../common/dom/entering-fullscreen";
import { ctrlOrCmdLabel } from "../../common/keyboard/ctrl-or-cmd";
import type { LocalizeFunc } from "../../common/translations/localize";
import { nextRender } from "../../common/util/render-status";
import type { CameraCapabilities, CameraEntity } from "../../data/camera";
import type { CameraStreamStatus } from "../../data/camera-streams";
import { isExternal } from "../../data/external";
import {
showCameraStreamInfoDialog,
type CameraStreamInfo,
@@ -148,10 +142,6 @@ export class HaCameraPlayer extends LitElement {
// full screen player
@state() private _paused = false;
// Playing when its button entered full screen, so a pause meanwhile is the
// companion app's
private _playingBeforeFullscreen = false;
@query("ha-camera-stream") private _stream?: HaCameraStream;
@query(".player") private _player?: HTMLElement;
@@ -205,7 +195,7 @@ export class HaCameraPlayer extends LitElement {
public connectedCallback() {
super.connectedCallback();
document.addEventListener("visibilitychange", this._visibilityChanged);
document.addEventListener("visibilitychange", this._requestWakeLock);
// The first update requests it, once keep-awake is set
if (this.hasUpdated) {
this._requestWakeLock();
@@ -219,7 +209,7 @@ export class HaCameraPlayer extends LitElement {
public disconnectedCallback() {
super.disconnectedCallback();
document.removeEventListener("visibilitychange", this._visibilityChanged);
document.removeEventListener("visibilitychange", this._requestWakeLock);
this._releaseWakeLock();
document.removeEventListener("fullscreenchange", this._fullscreenChanged);
document.removeEventListener(
@@ -495,11 +485,6 @@ export class HaCameraPlayer extends LitElement {
</div>`;
}
private _visibilityChanged = () => {
this._requestWakeLock();
this._resumeAfterEnteringFullscreen();
};
/**
* Browsers release the lock when the page is hidden, so it is requested
* again whenever the page shows.
@@ -735,7 +720,6 @@ export class HaCameraPlayer extends LitElement {
this._paused = Boolean(
video?.paused && (video.srcObject || video.currentSrc)
);
this._resumeAfterEnteringFullscreen();
};
private _toggleMute() {
@@ -787,26 +771,15 @@ export class HaCameraPlayer extends LitElement {
("webkitFullscreenElement" in document
? (document.webkitFullscreenElement as Element | null)
: null);
this._fullscreen = Boolean(
const fullscreen = Boolean(
this._player && fullscreenElement === this._player
);
this._resumeAfterEnteringFullscreen();
};
// The companion apps pause the video while entering full screen
private _resumeAfterEnteringFullscreen() {
if (
isExternal &&
this._playingBeforeFullscreen &&
this._paused &&
document.visibilityState === "visible" &&
isEnteringFullscreen()
) {
// Only once, so a pause in the iPhone's own full screen controls stays
this._playingBeforeFullscreen = false;
this._ensurePlaying();
if (fullscreen !== this._fullscreen) {
this._fullscreen = fullscreen;
// The size changes, so the zoomed in area would be off
this._zoom = ZOOM_PAN_IDENTITY;
}
}
};
private async _toggleFullscreen() {
const player = this._player;
@@ -822,10 +795,6 @@ export class HaCameraPlayer extends LitElement {
}
return;
}
this._playingBeforeFullscreen = Boolean(
this._video && !this._video.paused
);
startEnteringFullscreen();
if (player.requestFullscreen) {
await player.requestFullscreen();
} else if ("webkitRequestFullscreen" in player) {
@@ -839,7 +808,6 @@ export class HaCameraPlayer extends LitElement {
}
} catch (_err: unknown) {
// Denied by the browser
cancelEnteringFullscreen();
}
}
+4
View File
@@ -1939,6 +1939,10 @@ export class HaCodeEditor extends ReactiveElement {
padding-top: var(--code-editor-toolbar-height);
}
:host(.fullscreen) {
--code-mirror-min-height: 100%;
}
:host(.fullscreen) .cm-editor {
height: 100% !important;
max-height: 100% !important;
+5 -12
View File
@@ -9,10 +9,6 @@ import { consume } from "../common/decorators/consume";
import { isComponentLoaded } from "../common/config/is_component_loaded";
import { consumeLocalize } from "../common/decorators/consume-context-entry";
import { fireEvent } from "../common/dom/fire_event";
import {
claimFullscreenEnterHide,
FULLSCREEN_ENTER_TIME,
} from "../common/dom/entering-fullscreen";
import type { LocalizeFunc } from "../common/translations/localize";
import { nextRender } from "../common/util/render-status";
import { fetchStreamUrl } from "../data/camera";
@@ -105,19 +101,16 @@ export class HaHLSPlayer extends LitElement {
return;
}
if (document.hidden) {
if (isExternal && !claimFullscreenEnterHide(this)) {
if (isExternal) {
// The companion apps pause JavaScript timers while in the background,
// so a delayed clean up would not run until the app is opened again
this._cleanUp();
return;
}
this._hiddenCleanupTimeout = window.setTimeout(
() => {
this._hiddenCleanupTimeout = undefined;
this._cleanUp();
},
isExternal ? FULLSCREEN_ENTER_TIME : HIDDEN_CLEANUP_DELAY
);
this._hiddenCleanupTimeout = window.setTimeout(() => {
this._hiddenCleanupTimeout = undefined;
this._cleanUp();
}, HIDDEN_CLEANUP_DELAY);
} else if (this._hiddenCleanupTimeout) {
// stream was not cleaned up yet, just cancel the cleanup
clearTimeout(this._hiddenCleanupTimeout);
+5 -12
View File
@@ -8,10 +8,6 @@ import { styleMap } from "lit/directives/style-map";
import { consume } from "../common/decorators/consume";
import { consumeLocalize } from "../common/decorators/consume-context-entry";
import { fireEvent } from "../common/dom/fire_event";
import {
claimFullscreenEnterHide,
FULLSCREEN_ENTER_TIME,
} from "../common/dom/entering-fullscreen";
import type { LocalizeFunc } from "../common/translations/localize";
import {
addWebRtcCandidate,
@@ -246,19 +242,16 @@ export class HaWebRtcPlayer extends LitElement {
return;
}
if (document.hidden) {
if (isExternal && !claimFullscreenEnterHide(this)) {
if (isExternal) {
// The companion apps pause JavaScript timers while in the background,
// so a delayed clean up would not run until the app is opened again
this._cleanUp();
return;
}
this._hiddenCleanupTimeout = window.setTimeout(
() => {
this._hiddenCleanupTimeout = undefined;
this._cleanUp();
},
isExternal ? FULLSCREEN_ENTER_TIME : HIDDEN_CLEANUP_DELAY
);
this._hiddenCleanupTimeout = window.setTimeout(() => {
this._hiddenCleanupTimeout = undefined;
this._cleanUp();
}, HIDDEN_CLEANUP_DELAY);
} else if (this._hiddenCleanupTimeout) {
// stream was not cleaned up yet, just cancel the cleanup
clearTimeout(this._hiddenCleanupTimeout);
@@ -1,5 +1,6 @@
import type { ContextType } from "@lit/context";
import type { HassConfig, UnsubscribeFunc } from "home-assistant-js-websocket";
import { ERR_CONNECTION_LOST } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@@ -456,6 +457,11 @@ class MoreInfoUpdate extends LitElement {
false
);
} catch (err: any) {
// The update keeps running when the connection drops during a long install.
if (err?.error?.code === ERR_CONNECTION_LOST) {
return;
}
const message = await this._localizeInstallError(err);
if (this._isShown()) {
@@ -620,15 +620,14 @@ class MoreInfoWeather extends LitElement {
}
.temp-attribute .temp {
position: relative;
margin-right: var(--ha-space-6);
direction: ltr;
}
.temp-attribute .temp span {
position: absolute;
position: relative;
font-size: var(--ha-font-size-2xl);
top: 1px;
vertical-align: top;
}
.state,
+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");
@@ -0,0 +1,63 @@
import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { consumeLocalize } from "../../../common/decorators/consume-context-entry";
import type { LocalizeFunc } from "../../../common/translations/localize";
import "../../../components/ha-code-editor";
import "../../../components/ha-dialog";
import { DialogMixin } from "../../../dialogs/dialog-mixin";
import type { BlueprintContentDialogParams } from "./show-dialog-blueprint-content";
@customElement("dialog-blueprint-content")
class DialogBlueprintContent extends DialogMixin<BlueprintContentDialogParams>(
LitElement
) {
@state()
@consumeLocalize()
private _localize!: LocalizeFunc;
protected render() {
if (!this.params) {
return nothing;
}
return html`
<ha-dialog
open
width="full"
flexcontent
header-title=${this._localize(
"ui.panel.config.blueprint.add.raw_blueprint"
)}
header-subtitle=${this.params.name}
>
<ha-code-editor
mode="yaml"
.value=${this.params.content}
read-only
in-dialog
dir="ltr"
></ha-code-editor>
</ha-dialog>
`;
}
static styles = css`
ha-dialog {
--dialog-content-padding: 0;
}
/* A grid, so that the editor fills the height and scrolls inside */
ha-code-editor {
flex: 1;
min-height: 0;
display: grid;
grid-template-rows: minmax(0, 1fr);
grid-template-columns: minmax(0, 1fr);
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"dialog-blueprint-content": DialogBlueprintContent;
}
}
@@ -1,16 +1,14 @@
import { mdiClose, mdiOpenInNew } from "@mdi/js";
import "@home-assistant/components/card";
import { mdiClose, mdiCodeBraces, mdiOpenInNew } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import type { HASSDomTargetEvent } from "../../../common/dom/fire_event";
import { withViewTransition } from "../../../common/util/view-transition";
import "../../../components/ha-alert";
import "../../../components/ha-button";
import "../../../components/ha-code-editor";
import "../../../components/ha-dialog";
import "../../../components/ha-dialog-footer";
import "../../../components/ha-dialog-header";
import "../../../components/ha-expansion-panel";
import "../../../components/ha-markdown";
import "../../../components/ha-spinner";
import "../../../components/input/ha-input";
@@ -21,6 +19,7 @@ import { DirtyStateProviderMixin } from "../../../mixins/dirty-state-provider-mi
import { haStyleDialog } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import { showBlueprintContentDialog } from "./show-dialog-blueprint-content";
interface BlueprintImportState {
value: string;
@@ -33,8 +32,6 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
) {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ type: Boolean, reflect: true }) public large = false;
@state() private _params?;
@state() private _open = false;
@@ -58,7 +55,6 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
this._error = undefined;
this._url = this._params.url;
this._sourceUrlWarning = !this._isTrustedBlueprintUrl(this._url);
this.large = false;
this._open = true;
this._initDirtyTracking(
{ type: "shallow" },
@@ -88,7 +84,6 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
<ha-dialog
.open=${this._open}
.accessibleLabel=${heading}
width=${this.large ? "full" : "medium"}
.preventScrimClose=${this.isDirtyState}
@closed=${this._dialogClosed}
>
@@ -99,9 +94,7 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
.label=${this.hass.localize("ui.common.close")}
.path=${mdiClose}
></ha-icon-button>
<span slot="title" class="title-enlargeable" @click=${this._enlarge}>
${heading}
</span>
<span slot="title">${heading}</span>
</ha-dialog-header>
<div>
${
@@ -164,18 +157,37 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
></ha-input>
`
}
<ha-expansion-panel
.header=${this.hass.localize(
"ui.panel.config.blueprint.add.raw_blueprint"
)}
>
<ha-code-editor
mode="yaml"
.value=${this._result.raw_data}
read-only
dir="ltr"
></ha-code-editor>
</ha-expansion-panel>
<hac-card class="content-card">
<div class="content-row">
<div class="content-text">
<span>
${this.hass.localize(
"ui.panel.config.blueprint.add.raw_blueprint"
)}
</span>
<span class="content-description">
${this.hass.localize(
"ui.panel.config.blueprint.add.raw_blueprint_description"
)}
</span>
</div>
<ha-button
appearance="filled"
.accessibleLabel=${this.hass.localize(
"ui.panel.config.blueprint.add.view_raw_blueprint_label"
)}
@click=${this._showContent}
>
<ha-svg-icon
slot="start"
.path=${mdiCodeBraces}
></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.blueprint.add.view_raw_blueprint"
)}
</ha-button>
</div>
</hac-card>
${
this._result?.exists
? html`
@@ -275,9 +287,10 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
`;
}
private _enlarge() {
withViewTransition(() => {
this.large = !this.large;
private _showContent() {
showBlueprintContentDialog(this, {
name: this._result!.blueprint.metadata.name,
content: this._result!.raw_data,
});
}
@@ -384,11 +397,23 @@ class DialogImportBlueprint extends DirtyStateProviderMixin<BlueprintImportState
a ha-svg-icon {
--mdc-icon-size: 16px;
}
ha-expansion-panel {
--expansion-panel-content-padding: 0px;
.content-card {
margin: var(--ha-space-6) 0 var(--ha-space-2);
}
.title-enlargeable {
display: block;
.content-row {
display: flex;
align-items: center;
gap: var(--ha-space-4);
}
.content-text {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.content-description {
font-size: var(--ha-font-size-s);
color: var(--secondary-text-color);
}
`,
];
@@ -0,0 +1,20 @@
import { fireEvent } from "../../../common/dom/fire_event";
export interface BlueprintContentDialogParams {
name: string;
content: string;
}
export const loadBlueprintContentDialog = () =>
import("./dialog-blueprint-content");
export const showBlueprintContentDialog = (
element: HTMLElement,
dialogParams: BlueprintContentDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-blueprint-content",
dialogImport: loadBlueprintContentDialog,
dialogParams,
});
};
@@ -93,13 +93,13 @@ export class CloudRemotePref extends LitElement {
<ha-card
outlined
header=${this.hass.localize(
"ui.panel.config.cloud.account.remote.card_title"
"ui.panel.config.cloud.account.remote.title"
)}
>
<div class="header-actions">
<ha-switch
.accessibleLabel=${this.hass.localize(
"ui.panel.config.cloud.account.remote.card_title"
"ui.panel.config.cloud.account.remote.title"
)}
.checked=${remote_enabled}
@change=${this._toggleChanged}
@@ -104,7 +104,7 @@ export class CloudWebhooks extends LitElement {
<div class="card-actions">
<ha-button
appearance="plain"
href="https://www.nabucasa.com/config/webhooks"
href="https://www.nabucasa.com/config/webhooks/"
target="_blank"
rel="noreferrer"
>
@@ -820,15 +820,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
}
.temp-attribute .temp {
position: relative;
margin-right: 24px;
direction: ltr;
}
.temp-attribute .temp span {
position: absolute;
position: relative;
font-size: var(--ha-font-size-2xl);
top: 1px;
vertical-align: top;
}
.state,
@@ -1025,12 +1024,6 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
font-size: var(--ha-font-size-xl);
}
[class*="narrow"] .temp-attribute .temp {
margin-right: 16px;
margin-inline-end: 16px;
margin-inline-start: initial;
}
[class*="narrow"] .temp span {
top: 1px;
font-size: var(--ha-font-size-l);
@@ -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";
@@ -8,6 +8,7 @@ import deepFreeze from "deep-freeze";
import type { CSSResultGroup, PropertyValues } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
import { fireEvent } from "../../../../common/dom/fire_event";
import { ctrlOrCmdLabel } from "../../../../common/keyboard/ctrl-or-cmd";
@@ -75,6 +76,8 @@ export class HuiDialogEditBadge
@state() private _animateWidth = false;
private _largeBeforeCodeEditor = false;
@state() private _badgeConfig?: LovelaceBadgeConfig;
@state() private _saving = false;
@@ -99,6 +102,7 @@ export class HuiDialogEditBadge
this._badgeConfig = params.badgeConfig;
this.large = false;
this._animateWidth = false;
if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) {
this._badgeConfig = deepFreeze(this._badgeConfig);
}
@@ -202,7 +206,10 @@ export class HuiDialogEditBadge
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${this._animateWidth ? "animate-width" : ""}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": !this._GUImode,
})}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@@ -345,11 +352,21 @@ export class HuiDialogEditBadge
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
ev.stopPropagation();
// Fired again on every error while staying in the same mode
if (ev.detail.guiMode !== this._GUImode) {
if (ev.detail.guiMode) {
this.large = this._largeBeforeCodeEditor;
} else {
this._largeBeforeCodeEditor = this.large;
this.large = true;
}
}
this._GUImode = ev.detail.guiMode;
this._guiModeAvailable = ev.detail.guiModeAvailable;
}
private _toggleMode(): void {
this._animateWidth = true;
withViewTransition(() => {
this._badgeEditorEl?.toggleMode();
});
@@ -513,6 +530,17 @@ export class HuiDialogEditBadge
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
ha-dialog.animate-width {
--ha-dialog-width-transition:
min-width var(--ha-animation-duration-normal) ease-out,
@@ -8,6 +8,7 @@ import deepFreeze from "deep-freeze";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one";
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
import { fireEvent } from "../../../../common/dom/fire_event";
@@ -83,6 +84,8 @@ export class HuiDialogEditCard
@state() private _animateWidth = false;
private _largeBeforeCodeEditor = false;
@state() private _cardConfig?: LovelaceCardConfig;
@state() private _sectionConfig?: LovelaceSectionConfig;
@@ -111,6 +114,7 @@ export class HuiDialogEditCard
this._cardConfig = params.cardConfig;
this.large = false;
this._animateWidth = false;
if (this._cardConfig && !Object.isFrozen(this._cardConfig)) {
this._cardConfig = deepFreeze(this._cardConfig);
}
@@ -214,7 +218,10 @@ export class HuiDialogEditCard
.open=${this._open}
.accessibleLabel=${heading}
.width=${this.large ? "full" : "large"}
class=${this._animateWidth ? "animate-width" : ""}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": !this._GUImode,
})}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isEffectiveDirtyState}
@keydown=${this._ignoreKeydown}
@@ -371,11 +378,21 @@ export class HuiDialogEditCard
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
ev.stopPropagation();
// Fired again on every error while staying in the same mode
if (ev.detail.guiMode !== this._GUImode) {
if (ev.detail.guiMode) {
this.large = this._largeBeforeCodeEditor;
} else {
this._largeBeforeCodeEditor = this.large;
this.large = true;
}
}
this._GUImode = ev.detail.guiMode;
this._guiModeAvailable = ev.detail.guiModeAvailable;
}
private _toggleMode(): void {
this._animateWidth = true;
withViewTransition(() => {
this._cardEditorEl?.toggleMode();
});
@@ -595,6 +612,17 @@ export class HuiDialogEditCard
ha-dialog ha-icon-button[slot="headerActionItems"] {
color: var(--secondary-text-color);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
ha-dialog.animate-width {
--ha-dialog-width-transition:
min-width var(--ha-animation-duration-normal) ease-out,
@@ -264,8 +264,11 @@ export class HuiDialogEditSection
<ha-dialog
.open=${this._open}
.accessibleLabel=${heading}
width="large"
class=${this._animateWidth ? "animate-width" : ""}
.width=${this._yamlMode ? "full" : "large"}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": this._yamlMode,
})}
style=${styleMap({ "--preview-column-span": previewColumnSpan })}
@dialog-set-fullscreen=${this._stopWidthAnimation}
.preventScrimClose=${this.isDirtyState}
@@ -529,6 +532,7 @@ export class HuiDialogEditSection
private async _toggleMode(): Promise<void> {
if (this._yamlMode && this._yamlError) return;
this._animateWidth = true;
await withViewTransition(() => {
this._yamlMode = !this._yamlMode;
});
@@ -750,6 +754,17 @@ export class HuiDialogEditSection
);
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
ha-dialog.animate-width {
--ha-dialog-width-transition:
min-width var(--ha-animation-duration-normal) ease-out,
@@ -836,10 +851,11 @@ export class HuiDialogEditSection
@media (min-width: 1000px) {
ha-dialog {
--editor-column-width: 520px;
/* Plus the paddings of the preview and the dialog */
/* Plus the paddings of the preview */
--preview-column-total-width: calc(var(--preview-width) + 28px);
--ha-dialog-width-lg: calc(
var(--editor-column-width) + var(--preview-width) + 28px + 2 *
var(--dialog-content-padding)
var(--editor-column-width) + var(--preview-column-total-width) +
2 * var(--dialog-content-padding)
);
}
.content {
@@ -854,6 +870,13 @@ export class HuiDialogEditSection
.content > .element-preview {
flex: 1 1 0;
}
ha-dialog.yaml-mode .content > .element-editor {
flex: 1 0 var(--editor-column-width);
}
ha-dialog.yaml-mode .content > .element-preview {
box-sizing: border-box;
flex: 0 1 var(--preview-column-total-width);
}
.content > .element-editor,
.content > .element-preview {
min-width: 0;
@@ -90,6 +90,8 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
@state() private _open = false;
@state() private _animateWidth = false;
get _type(): string {
return getViewType(this._config);
}
@@ -136,6 +138,7 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
this._params = undefined;
this._config = {};
this._yamlMode = false;
this._animateWidth = false;
this._currTab = TABS[0];
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -210,10 +213,12 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
<ha-dialog
.open=${this._open}
.accessibleLabel=${this._viewConfigTitle}
width="large"
.width=${this._yamlMode ? "full" : "large"}
.preventScrimClose=${this.isDirtyState}
@closed=${this._dialogClosed}
@dialog-set-fullscreen=${this._stopWidthAnimation}
class=${classMap({
"animate-width": this._animateWidth,
"yaml-mode": this._yamlMode,
})}
>
@@ -365,7 +370,13 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
}
}
// The code editor's fullscreen changes the height at once, so the width must not lag behind
private _stopWidthAnimation() {
this._animateWidth = false;
}
private async _toggleMode() {
this._animateWidth = true;
this._yamlMode = !this._yamlMode;
if (this._yamlMode) {
await this.updateComplete;
@@ -680,6 +691,29 @@ export class HuiDialogEditView extends DirtyStateProviderMixin<LovelaceViewConfi
ha-dialog.yaml-mode {
--dialog-content-padding: 0;
}
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* 80px - margin of the dialog
137px - header and footer */
--code-mirror-max-height: calc(100vh - 217px);
}
}
@supports (min-height: min(1px, 2px)) {
@media (min-width: 1000px) {
ha-dialog.yaml-mode {
/* Minus the toolbar of the code editor */
--code-mirror-min-height: min(
500px,
var(--code-mirror-max-height, 100vh) - 28px
);
}
}
}
ha-dialog.animate-width {
--ha-dialog-width-transition:
min-width var(--ha-animation-duration-normal) ease-out,
max-width var(--ha-animation-duration-normal) ease-out;
}
h2 {
margin: 0;
font-size: inherit;
+5
View File
@@ -305,6 +305,11 @@ export const haTheme = EditorView.theme({
".cm-scroller": { outline: "none" },
// On these instead of the editor, so that the gutter grows along
".cm-content, .cm-gutter": {
minHeight: "var(--code-mirror-min-height, 100%)",
},
".cm-content": {
caretColor: "var(--secondary-text-color)",
paddingTop: "16px",
+4 -2
View File
@@ -7136,6 +7136,9 @@
"community_forums": "View blueprints on the community forums",
"url": "Blueprint address",
"raw_blueprint": "Blueprint content",
"raw_blueprint_description": "Check the code before you import it.",
"view_raw_blueprint": "View",
"view_raw_blueprint_label": "View blueprint content",
"importing": "Loading blueprint…",
"import_btn": "Preview",
"saving": "Importing blueprint…",
@@ -7616,7 +7619,6 @@
},
"remote": {
"title": "Remote access",
"card_title": "Remote connection",
"connected": "Connected",
"not_connected": "Not connected",
"reconnecting": "Not connected. Trying to reconnect.",
@@ -8266,7 +8268,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.",
"delete_confirm_dependents": "{integrations} {count, plural,\n one {depends on {name} and may stop working.}\n other {depend on {name} and may stop working.}\n}",
"enable_debug_logging": "Enable debug logging",
"reconfigure": "Reconfigure",
"reload": "Reload",
@@ -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",
});
});
});
@@ -1,49 +0,0 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
cancelEnteringFullscreen,
claimFullscreenEnterHide,
FULLSCREEN_ENTER_TIME,
isEnteringFullscreen,
startEnteringFullscreen,
} from "../../../src/common/dom/entering-fullscreen";
describe("entering-fullscreen", () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
it("lets each stream through one hidden page per entering", () => {
const streamA = {};
const streamB = {};
expect(claimFullscreenEnterHide(streamA)).toBe(false);
// Each stream once, and the window counts from the last claim
startEnteringFullscreen();
vi.advanceTimersByTime(FULLSCREEN_ENTER_TIME - 100);
expect(claimFullscreenEnterHide(streamA)).toBe(true);
expect(claimFullscreenEnterHide(streamA)).toBe(false);
vi.advanceTimersByTime(FULLSCREEN_ENTER_TIME - 100);
expect(claimFullscreenEnterHide(streamB)).toBe(true);
vi.advanceTimersByTime(FULLSCREEN_ENTER_TIME);
expect(isEnteringFullscreen()).toBe(false);
expect(claimFullscreenEnterHide({})).toBe(false);
// Expired before any claim
startEnteringFullscreen();
vi.advanceTimersByTime(FULLSCREEN_ENTER_TIME);
expect(claimFullscreenEnterHide(streamA)).toBe(false);
startEnteringFullscreen();
cancelEnteringFullscreen();
expect(claimFullscreenEnterHide(streamA)).toBe(false);
// A new entering lets the same stream through again
startEnteringFullscreen();
expect(claimFullscreenEnterHide(streamA)).toBe(true);
});
});