Compare commits

..
Author SHA1 Message Date
Paul Bottein 9338b91f18 Show the integration type in the entity type list (#55958) 2026-11-19 10:00:51 +00:00
Jan Bouwhuis b41693b8d2 Move dragged network graph nodes without layout animation (#55993)
* Move dragged network graph nodes without layout animation

* Keep the position of a node dragged without layout animation on a new layout run
2026-11-19 09:55:22 +00:00
Chanelle 407cf9e6a4 Give the onboarding welcome cards a button role (#55999) 2026-11-19 09:45:16 +00:00
Petar Petrov 02aacd0c51 Recover from a used or expired auth callback URL (#55989)
Drop a stale auth callback instead of retrying it on every reload
2026-11-19 07:03:20 +01:00
renovate[bot] f80d578deb Update dependency lint-staged to v17.6.1 (#55995)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-18 19:20:34 +00:00
Bram KragtenandClaude Opus 5.5 67297d7806 Add the link My redirect for Home Assistant Link (#55954)
Home Assistant Cloud becomes Home Assistant Link in 2026.12, so the My
link gets the new key link. cloud stays for existing links and badges,
and for my.home-assistant.io, which keeps sending instances to cloud for
now. link comes first so the "m" shortcut creates links with the new key.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-18 20:13:32 +01:00
renovate[bot] 46204a1955 Update dependency barcode-detector to v3.2.4 (#55992)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-11-18 17:38:27 +02:00
Jan-Philipp BeneckeandCopilot Autofix powered by AI 04ab43929e Show update release notes messages in the more info dialog (#55388)
* Show update release notes messages in the more info dialog

* Replace message display with ha-markdown component

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

* Add RTL support for message display in ha-markdown component

* Add language parameter to updateReleaseNotes function

* Fix position

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
2026-11-18 06:47:54 +01:00
Erwin Douna 10b7f5ffb6 Move database analyze to the Storage page toolbar (#55982)
* Move database analyze to the Storage page toolbar

* Load the database report once recorder is available
2026-11-18 00:10:47 -05:00
16 changed files with 365 additions and 238 deletions

No files matched your search

+11 -2
View File
@@ -250,7 +250,16 @@ class DemoMoreInfoUpdate extends LitElement {
"update/release_notes",
(msg: { type: string; entity_id: string }) => {
if (msg.entity_id === "update.update16") {
return LONG_TEXT;
return {
release_notes: LONG_TEXT,
messages: [
{
severity: "warning",
message:
"Do not restart, remove power from, or otherwise interrupt the device while the update is in progress.",
},
],
};
}
if (msg.entity_id === "update.update17") {
return Promise.reject({
@@ -261,7 +270,7 @@ class DemoMoreInfoUpdate extends LitElement {
if (msg.entity_id === "update.update18") {
return undefined;
}
return null;
return { release_notes: null, messages: [] };
}
);
}
+2 -2
View File
@@ -83,7 +83,7 @@
"@vibrant/color": "4.0.4",
"@vvo/tzdb": "6.204.0",
"@webcomponents/scoped-custom-element-registry": "0.0.10",
"barcode-detector": "3.2.3",
"barcode-detector": "3.2.4",
"cally": "0.9.2",
"color-name": "2.1.1",
"comlink": "4.4.2",
@@ -199,7 +199,7 @@
"jszip": "3.10.2",
"license-checker-rseidelsohn": "5.0.1",
"lightningcss": "1.33.0",
"lint-staged": "17.6.0",
"lint-staged": "17.6.1",
"lit-analyzer": "2.0.3",
"lodash.merge": "4.6.2",
"lodash.template": "4.18.1",
+19 -19
View File
@@ -318,8 +318,8 @@ importers:
specifier: 0.0.10
version: 0.0.10
barcode-detector:
specifier: 3.2.3
version: 3.2.3
specifier: 3.2.4
version: 3.2.4
cally:
specifier: 0.9.2
version: 0.9.2
@@ -661,8 +661,8 @@ importers:
specifier: 1.33.0
version: 1.33.0
lint-staged:
specifier: 17.6.0
version: 17.6.0
specifier: 17.6.1
version: 17.6.1
lit-analyzer:
specifier: 2.0.3
version: 2.0.3
@@ -4245,8 +4245,8 @@ packages:
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
engines: {node: 18 || 20 || >=22}
[email protected].3:
resolution: {integrity: sha512-PLinpWGiOQoQH4X+YObWZ6iXeffXKDM3d4vnOD86481SvukIfvkf7jEE/tud9oI4HTDxtDdlHaFilA5Kn7Xa7A==}
[email protected].4:
resolution: {integrity: sha512-4tjallFXSratRbkzyccnfgL8w/3FtTexjWpQoPes3niFQ2DybGeaktH8w5ukc6wVUrOL7yNsoUUqmaRVn1YtJg==}
[email protected]:
resolution: {integrity: sha512-Z0oHEHAFDZkffN8Qc39zNZjQlMDkPJRyyyZieU1VH7u8c5S+qHZ2S8ixdKIAxEjfHO7FJxXmJWgteOghVanIsg==}
@@ -6064,8 +6064,8 @@ packages:
resolution: {integrity: sha512-wM1+Z03eypVAVUCE7QdSqpVIvelbOakn1M0bPDoA4SGWPx3sNDVUiMo3L6To6WWGClB7VyXnhQ4Sn7gxiJbE6A==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
[email protected].0:
resolution: {integrity: sha512-nOhBfYkZEwkFtNzD5pK9s9LkcWoxJ+whLzEnhqi9nl7zTB5n7tg8+9iYgMGx2Wm3VlLu8cbNj0RACzY+nWi5iQ==}
[email protected].1:
resolution: {integrity: sha512-3MXgVN7BERDR/6CXZs2fDHGc+r0+hlvGAa9wqMlVbIS6RVRuaPOnb5SnN6wMXulwfEy9DXVkMVUN/8cUlpPDnw==}
engines: {node: '>=22.22.1'}
hasBin: true
@@ -7259,9 +7259,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-1Yowhzjf0ivGMrTIkY9hav5TxobO9qIVqUE41fiCGMGgc3CLlf4MY+9AHmZqBWgDTue0fY9zWjYFVyf6Diuobw==}
string-argv@0.3.2:
resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==}
engines: {node: '>=0.6.19'}
string-argv@0.4.0:
resolution: {integrity: sha512-UOtaksJ3SK3KLHba2i9I27fvuZNfBlImDP5wKsCOxCDMRDNxlipCe8rmnUAaDpqlQ93upnA0SzF2pjWhttozSA==}
engines: {node: '>=16.20.0'}
[email protected]:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
@@ -8143,8 +8143,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-oEGMDB6pOP2S6OwRR4PdVv610zrjnA3Bh+JnSG12fYJlBKjtNAoEb5fSUoCOOINlH96I2fU38/A2UpRKs67xYQ==}
[email protected].6:
resolution: {integrity: sha512-mU7UNuvl+hOT+nlSOQTMHZ2tM8lRMsbjDIp5IO/+HmBl/FOq77q0OSZPJ3cm42A9c1MKU6Uve67FiGdkhsrT9g==}
[email protected].7:
resolution: {integrity: sha512-LI94ndlOY+xoqlkNcc0EwByrMpUXKrCX171EQ38kGWqpiRq/gcnC+ZrbRipvxI3uV4LaDtNlKo1p9Uayg1sesQ==}
peerDependencies:
'@types/emscripten': '>=1.39.6'
@@ -11992,9 +11992,9 @@ snapshots:
[email protected]: {}
[email protected].3:
[email protected].4:
dependencies:
zxing-wasm: 3.1.6
zxing-wasm: 3.1.7
[email protected]: {}
@@ -13964,10 +13964,10 @@ snapshots:
[email protected]: {}
[email protected].0:
[email protected].1:
dependencies:
picomatch: 4.0.7
string-argv: 0.3.2
string-argv: 0.4.0
tinyexec: 1.3.1
optionalDependencies:
yaml: 2.9.1
@@ -15370,7 +15370,7 @@ snapshots:
- bare-abort-controller
- react-native-b4a
string-argv@0.3.2: {}
string-argv@0.4.0: {}
[email protected]:
dependencies:
@@ -16333,7 +16333,7 @@ snapshots:
dependencies:
tslib: 2.9.1
[email protected].6:
[email protected].7:
dependencies:
'@types/emscripten': 1.41.6
type-fest: 5.10.0
+57
View File
@@ -95,6 +95,10 @@ const SELECTED_NODE_FIT_MARGIN = 72;
const FOLLOW_ROAM = "follow-selected-node";
type Displayable = ReturnType<
ReturnType<EChartsType["getZr"]>["storage"]["getDisplayList"]
>[number];
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/consistent-type-imports
let GraphChart: typeof import("echarts/lib/chart/graph/install");
@@ -152,6 +156,8 @@ export class HaNetworkGraph extends LitElement {
private _dragMoved = false;
private _dragTarget?: Displayable;
private _followSelectedNode = false;
private _followedChart?: EChartsType;
@@ -565,6 +571,7 @@ export class HaNetworkGraph extends LitElement {
private _handleChartSetup() {
const chart = this._baseChart?.chart;
chart?.on("mousedown", this._handleNodeMouseDown);
chart?.getZr().on("dragstart", this._handleDragStart);
chart?.getZr().on("drag", this._handleDrag);
chart?.getZr().on("dragend", this._handleDragEnd);
for (const event of LEGEND_SELECT_EVENTS) {
@@ -608,6 +615,54 @@ export class HaNetworkGraph extends LitElement {
this._dragMoved = false;
};
// The dragged element gets the drag before the ECharts handler of its node
private _handleDragStart = (ev: { target?: Displayable }) => {
this._dragTarget?.off("drag", this._handleNodeDrag);
this._dragTarget = ev.target;
this._dragTarget?.on("drag", this._handleNodeDrag);
};
// Without layout animation, the ECharts handler runs the whole force layout
// on every move, which puts the node back before it reads its position. So
// the node moves here, and the other nodes stay where they are.
private _handleNodeDrag = (ev: { cancelBubble?: boolean }) => {
const chart = this._baseChart?.chart;
const series = this._getGraphSeries(chart);
const node =
this._dragNode === undefined
? undefined
: series?.getGraph().getNodeById(this._dragNode);
if (
!chart ||
!node ||
!series.forceLayout ||
series.get(["force", "layoutAnimation"])
) {
return;
}
ev.cancelBubble = true;
const data = series.getData();
const el = data.getItemGraphicEl(node.dataIndex);
data.setItemLayout(node.dataIndex, [el.x, el.y]);
// A new layout run starts from here, e.g. after a legend change
if (series.preservedPoints) {
series.preservedPoints[node.id] = [el.x, el.y];
}
series.forceLayout.setFixed(node.dataIndex);
for (const edge of node.edges) {
const source: number[] | undefined = edge.node1.getLayout();
const target: number[] | undefined = edge.node2.getLayout();
// The nodes of hidden legend categories have no layout
if (source && target) {
edge.setLayout([[...source], [...target]]);
}
}
// @ts-ignore private method but no other way to draw the new layout
chart.getViewOfSeriesModel(series).updateLayout(series);
// The handlers of the chart miss the drag now
chart.getZr().handler.trigger("drag", ev);
};
private _handleDrag = () => {
this._dragMoved = true;
};
@@ -617,6 +672,8 @@ export class HaNetworkGraph extends LitElement {
const moved = this._dragMoved;
this._dragNode = undefined;
this._dragMoved = false;
this._dragTarget?.off("drag", this._handleNodeDrag);
this._dragTarget = undefined;
// A click also ends a drag, which releases a pinned node in ECharts
if (!id || (!moved && !this._pinnedNodes.includes(id))) {
return;
+2 -1
View File
@@ -1663,7 +1663,8 @@ export class HaDataTable extends LitElement {
}
.mdc-data-table__row ~ .mdc-data-table__row {
border-top: 1px solid var(--divider-color);
border-top: var(--data-table-row-border-width, 1px) solid
var(--divider-color);
}
.mdc-data-table__row.clickable:not(
+14 -2
View File
@@ -79,13 +79,25 @@ export const updateButtonIsDisabled = (entity: UpdateEntity): boolean =>
export const updateIsInstalling = (entity: UpdateEntity): boolean =>
!!entity.attributes.in_progress;
export interface UpdateReleaseNotesMessage {
severity: "info" | "warning" | "error";
message: string;
}
export interface UpdateReleaseNotes {
release_notes: string | null;
messages: UpdateReleaseNotesMessage[];
}
export const updateReleaseNotes = (
hass: Pick<HomeAssistant, "callWS">,
entityId: string
entityId: string,
language: string
) =>
hass.callWS<string | null>({
hass.callWS<UpdateReleaseNotes>({
type: "update/release_notes",
entity_id: entityId,
language,
});
const HOME_ASSISTANT_CORE_TITLE = "Home Assistant Core";
@@ -2,6 +2,7 @@ import type { ContextType } from "@lit/context";
import type { HassConfig, UnsubscribeFunc } 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";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { consume } from "../../../common/decorators/consume";
import { BINARY_STATE_OFF } from "../../../common/const";
@@ -13,6 +14,7 @@ import { transform } from "../../../common/decorators/transform";
import { supportsFeature } from "../../../common/entity/supports-feature";
import type { LocalizeFunc } from "../../../common/translations/localize";
import { sanitizeHttpUrl } from "../../../common/url/sanitize-http-url";
import { estimateDirection } from "../../../common/util/estimate-direction";
import { closestWithProperty } from "../../../common/dom/ancestors-with-property";
import "../../../components/ha-alert";
import "../../../components/ha-button";
@@ -31,7 +33,7 @@ import {
} from "../../../data/context";
import { UNAVAILABLE, UNKNOWN } from "../../../data/entity/entity";
import type { EntityRegistryDisplayEntry } from "../../../data/entity/entity_registry";
import type { UpdateEntity } from "../../../data/update";
import type { UpdateEntity, UpdateReleaseNotes } from "../../../data/update";
import {
latestVersionIsSkipped,
updateButtonIsDisabled,
@@ -97,7 +99,7 @@ class MoreInfoUpdate extends LitElement {
})
private _user?: CurrentUser;
@state() private _releaseNotes?: string | null;
@state() private _releaseNotes?: UpdateReleaseNotes;
@state() private _error?: string;
@@ -261,15 +263,41 @@ class MoreInfoUpdate extends LitElement {
<hr />
${this._markdownLoading ? this._renderLoader() : nothing}
`
: this._releaseNotes
: this._releaseNotes.messages.length ||
this._releaseNotes.release_notes
? html`
<hr />
<ha-markdown
@content-resize=${this._markdownLoaded}
.content=${this._releaseNotes}
class=${this._markdownLoading ? "hidden" : ""}
></ha-markdown>
${this._markdownLoading ? this._renderLoader() : nothing}
${this._releaseNotes.messages.map(
(message) => html`
<ha-alert
class="release-notes-message"
alert-type=${message.severity}
>
<ha-markdown
class=${classMap({
rtl: estimateDirection(message.message) === "rtl",
})}
.content=${message.message}
></ha-markdown>
</ha-alert>
`
)}
${
this._releaseNotes.release_notes
? html`
<ha-markdown
@content-resize=${this._markdownLoaded}
.content=${this._releaseNotes.release_notes}
class=${this._markdownLoading ? "hidden" : ""}
></ha-markdown>
${
this._markdownLoading
? this._renderLoader()
: nothing
}
`
: nothing
}
`
: nothing
: this.stateObj.attributes.release_summary
@@ -393,7 +421,8 @@ class MoreInfoUpdate extends LitElement {
try {
this._releaseNotes = await updateReleaseNotes(
this._api,
this.stateObj!.entity_id
this.stateObj!.entity_id,
this._i18n.language
);
} catch (err: any) {
this._error = err.message;
@@ -583,6 +612,11 @@ class MoreInfoUpdate extends LitElement {
margin-bottom: var(--ha-space-4);
}
.release-notes-message {
display: block;
margin-bottom: var(--ha-space-4);
}
.row {
margin: 0;
display: flex;
@@ -642,6 +676,12 @@ class MoreInfoUpdate extends LitElement {
padding-bottom: var(--ha-space-4);
box-sizing: border-box;
}
.release-notes-message ha-markdown {
padding-bottom: 0;
}
ha-markdown.rtl {
direction: rtl;
}
ha-markdown.hidden {
display: none;
}
+45 -19
View File
@@ -2,6 +2,7 @@ import type { Auth, Connection } from "home-assistant-js-websocket";
import {
createConnection,
ERR_INVALID_AUTH,
ERR_INVALID_AUTH_CALLBACK,
getAuth,
subscribeConfig,
subscribeEntities,
@@ -36,17 +37,30 @@ declare global {
}
}
const replaceUrlParams = (searchParams: URLSearchParams) => {
const search = searchParams.toString();
history.replaceState(
null,
"",
`${location.pathname}${search ? `?${search}` : ""}`
);
};
const deleteAuthCallbackParams = (searchParams: URLSearchParams) => {
// https://github.com/home-assistant/home-assistant-js-websocket/blob/master/lib/auth.ts
// Remove all data from QueryCallbackData type
searchParams.delete("auth_callback");
searchParams.delete("code");
searchParams.delete("state");
searchParams.delete("storeToken");
};
const clearUrlParams = () => {
const searchParams = new URLSearchParams(location.search);
let changed = false;
// Clear auth data from url if we have been able to establish a connection
if (location.search.includes("auth_callback=1")) {
// https://github.com/home-assistant/home-assistant-js-websocket/blob/master/lib/auth.ts
// Remove all data from QueryCallbackData type
searchParams.delete("auth_callback");
searchParams.delete("code");
searchParams.delete("state");
searchParams.delete("storeToken");
deleteAuthCallbackParams(searchParams);
changed = true;
}
// Remove the cache-busting param added by the stale-index recovery guard in
@@ -57,12 +71,30 @@ const clearUrlParams = () => {
changed = true;
}
if (changed) {
const search = searchParams.toString();
history.replaceState(
null,
"",
`${location.pathname}${search ? `?${search}` : ""}`
);
replaceUrlParams(searchParams);
}
};
const authOptions = {
hassUrl,
limitHassInstance: true,
saveTokens,
loadTokens: () => Promise.resolve(loadTokens()),
};
const getAuthDroppingStaleCallback = async () => {
try {
return await getAuth(authOptions);
} catch (err: unknown) {
if (err !== ERR_INVALID_AUTH && err !== ERR_INVALID_AUTH_CALLBACK) {
throw err;
}
// The auth callback in the URL was used or has expired. Drop it so a
// reload does not replay it, and fall back to stored tokens or a new login.
const searchParams = new URLSearchParams(location.search);
deleteAuthCallbackParams(searchParams);
replaceUrlParams(searchParams);
return getAuth(authOptions);
}
};
@@ -71,13 +103,7 @@ const authProm = isExternal
import("../external_app/external_auth").then(({ createExternalAuth }) =>
createExternalAuth(hassUrl)
)
: () =>
getAuth({
hassUrl,
limitHassInstance: true,
saveTokens,
loadTokens: () => Promise.resolve(loadTokens()),
});
: getAuthDroppingStaleCallback;
const connProm = async (auth) => {
try {
+10 -1
View File
@@ -1,4 +1,4 @@
import type { TemplateResult } from "lit";
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@@ -121,6 +121,15 @@ class OnboardingCoreConfig extends LitElement {
`;
}
protected firstUpdated(changedProps: PropertyValues<this>) {
super.firstUpdated(changedProps);
this.addEventListener("keyup", (ev) => {
if (this._location && ev.key === "Enter") {
this._save(ev);
}
});
}
private _handleFormChanged(
ev: ValueChangedEvent<{ country?: string; time_zone?: string }>
) {
+28 -72
View File
@@ -25,7 +25,6 @@ import type { HaInput } from "../components/input/ha-input";
import "../components/item/ha-list-item-base";
import "../components/item/ha-list-item-button";
import "../components/list/ha-list-base";
import { searchResultsStatus } from "../components/list/search-results-status";
import "../components/map/ha-locations-editor";
import type {
HaLocationsEditor,
@@ -43,29 +42,6 @@ const AMSTERDAM: [number, number] = [52.3731339, 4.8903147];
const darkMql = matchMedia("(prefers-color-scheme: dark)");
const LOCATION_MARKER_ID = "location";
const placeLabels = (place: OpenStreetMapPlace): [string, string] => {
const primary = [
place.name || place.address[place.category],
place.address.house_number,
place.address.road || place.address.waterway,
place.address.village || place.address.town,
place.address.suburb || place.address.subdivision,
place.address.city || place.address.municipality,
]
.filter(Boolean)
.join(", ");
const secondary = [
place.address.county ||
place.address.state_district ||
place.address.region,
place.address.state,
place.address.country,
]
.filter(Boolean)
.join(", ");
return [primary, secondary];
};
@customElement("onboarding-location")
class OnboardingLocation extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -84,10 +60,6 @@ class OnboardingLocation extends LitElement {
@state() private _search = false;
@state() private _searchTerm = "";
@state() private _status?: string;
@state() private _highlightedMarker?: number;
private _elevation?: string;
@@ -102,7 +74,7 @@ class OnboardingLocation extends LitElement {
@query("ha-locations-editor", true) private map!: HaLocationsEditor;
@query("ha-input") private _input?: HaInput;
@query("ha-input") private _input?: HTMLElement;
protected render(): TemplateResult {
const addressAttribution = this._localize(
@@ -146,7 +118,7 @@ class OnboardingLocation extends LitElement {
label=${this._localize(
"ui.panel.page-onboarding.core-config.address_label"
)}
.readonly=${this._working}
.disabled=${this._working}
@keyup=${this._addressSearch}
>
<ha-svg-icon slot="start" .path=${mdiMagnify}></ha-svg-icon>
@@ -175,12 +147,29 @@ class OnboardingLocation extends LitElement {
aria-label=${this._localize(
"ui.panel.page-onboarding.core-config.search_results"
)}
aria-busy=${this._working ? "true" : "false"}
>
${
this._places?.length
? this._places.map((place) => {
const [primary, secondary] = placeLabels(place);
const primary = [
place.name || place.address[place.category],
place.address.house_number,
place.address.road || place.address.waterway,
place.address.village || place.address.town,
place.address.suburb || place.address.subdivision,
place.address.city || place.address.municipality,
]
.filter(Boolean)
.join(", ");
const secondary = [
place.address.county ||
place.address.state_district ||
place.address.region,
place.address.state,
place.address.country,
]
.filter(Boolean)
.join(", ");
return html`<ha-list-item-button
@click=${this._itemClicked}
.placeId=${place.place_id}
@@ -198,16 +187,7 @@ class OnboardingLocation extends LitElement {
})
: html`<ha-list-item-base>
<span slot="headline"
>${
this._places === null
? ""
: searchResultsStatus(
this._searchTerm,
this._places,
() => true,
this._localize
)
}</span
>${this._places === null ? "" : "No results"}</span
>
</ha-list-item-base>`
}
@@ -215,7 +195,6 @@ class OnboardingLocation extends LitElement {
`
: nothing
}
<div class="visually-hidden" role="status">${this._status}</div>
</div>
<ha-locations-editor
class="flex"
@@ -245,6 +224,11 @@ class OnboardingLocation extends LitElement {
protected firstUpdated(changedProps: PropertyValues<this>) {
super.firstUpdated(changedProps);
setTimeout(() => this._input!.focus(), 100);
this.addEventListener("keyup", (ev) => {
if (ev.key === "Enter") {
this._save(ev);
}
});
}
protected updated(changedProps: PropertyValues) {
@@ -331,7 +315,6 @@ class OnboardingLocation extends LitElement {
)!;
this._location = [Number(place.lat), Number(place.lon)];
this._setCountry(place.address.country_code);
this._announceSelection(place);
}
private _itemClicked(ev) {
@@ -341,20 +324,12 @@ class OnboardingLocation extends LitElement {
)!;
this._location = [Number(place.lat), Number(place.lon)];
this._setCountry(place.address.country_code);
this._announceSelection(place);
}
private _announceSelection(place: OpenStreetMapPlace) {
this._status = this._localize(
"ui.panel.page-onboarding.core-config.selected_location",
{ location: placeLabels(place).filter(Boolean).join(", ") }
);
}
private async _addressSearch(ev: KeyboardEvent) {
ev.stopPropagation();
this._search = ((ev.currentTarget as HaInput).value ?? "").length > 0;
if (ev.key !== "Enter" || this._working) {
if (ev.key !== "Enter") {
return;
}
this._searchAddress((ev.currentTarget as HaInput).value ?? "");
@@ -364,8 +339,6 @@ class OnboardingLocation extends LitElement {
this._working = true;
this._highlightedMarker = undefined;
this._error = undefined;
this._status = undefined;
this._searchTerm = address;
this._places = null;
this.map.addEventListener(
"markers-updated",
@@ -391,12 +364,6 @@ class OnboardingLocation extends LitElement {
this._setCountry(this._places[0].address.country_code);
this._elevation = undefined;
}
this._status = searchResultsStatus(
address,
this._places,
() => true,
this._localize
);
} catch (e: any) {
this._places = undefined;
this._error = e.message;
@@ -414,7 +381,6 @@ class OnboardingLocation extends LitElement {
this._setCountry(reverse.address.country_code);
this._places = [reverse];
this._highlightedMarker = reverse.place_id;
this._announceSelection(reverse);
}
private _setCountry(countryCode: string) {
@@ -426,7 +392,6 @@ class OnboardingLocation extends LitElement {
}
private async _handleButtonClick(ev) {
this._input?.select();
if (this._search) {
this._searchAddress(ev.target.parentElement.value);
return;
@@ -588,15 +553,6 @@ class OnboardingLocation extends LitElement {
.attribution a {
color: inherit;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
`,
];
}
@@ -1,6 +1,7 @@
import type { TemplateResult } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { consume } from "../common/decorators/consume";
import "../components/ha-card";
import "../components/ha-ripple";
@@ -23,6 +24,7 @@ class OnboardingWelcomeLink extends LitElement {
protected render(): TemplateResult {
return html`
<ha-card
role=${ifDefined(this.noninteractive ? undefined : "button")}
.tabIndex=${this.noninteractive ? "-1" : "0"}
@keydown=${this._handleKeyDown}
>
@@ -35,6 +37,7 @@ class OnboardingWelcomeLink extends LitElement {
private _handleKeyDown(ev: KeyboardEvent): void {
if (ev.key === "Enter" || ev.key === " ") {
ev.preventDefault();
(ev.target as HTMLElement).click();
}
}
@@ -221,9 +221,7 @@ const computeDeviceClassOptions = (
const groups: string[][] = OVERRIDE_DEVICE_CLASSES[domain];
for (const group of groups) {
if (originalDeviceClass && group.includes(originalDeviceClass)) {
related.push(
...group.filter((deviceClass) => deviceClass !== originalDeviceClass)
);
related.push(...group);
} else {
others.push(...group);
}
@@ -345,10 +343,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
this._name = this.entry.name || this._originalName;
this._isMainEntity = !!this._device && !this._entryName;
this._icon = this.entry.icon || "";
this._deviceClass =
this.entry.device_class === this._originalDeviceClass
? null
: (this.entry.device_class ?? null);
this._deviceClass = this.entry.device_class ?? null;
this._origEntityId = this.entry.entity_id;
this._areaId = this.entry.area_id;
this._mainEntityWithOwnArea = this._isMainEntity && !!this.entry.area_id;
@@ -5,6 +5,7 @@ import {
mdiNas,
mdiPencil,
mdiPlayBox,
mdiRefresh,
mdiReload,
} from "@mdi/js";
import type { PropertyValues, TemplateResult } from "lit";
@@ -32,6 +33,8 @@ import {
fetchHassioHostInfo,
fetchHostDisksUsage,
} from "../../../data/hassio/host";
import type { RecorderDatabaseUsage } from "../../../data/recorder";
import { fetchRecorderDatabaseUsage } from "../../../data/recorder";
import type {
SupervisorMount,
SupervisorMounts,
@@ -77,6 +80,17 @@ class HaConfigSectionStorage extends LitElement {
// Guards against a slow response from a previous reload landing in a newer one.
private _mountUsageGeneration = 0;
// Undefined until loaded, null when no recent report exists.
@state() private _databaseUsage?: RecorderDatabaseUsage | null;
@state() private _databaseLoading = false;
@state() private _databaseAnalyzing = false;
@state() private _databaseError?: string;
private _databaseRequested = false;
protected async firstUpdated(
changedProps: PropertyValues<this>
): Promise<void> {
@@ -89,6 +103,19 @@ class HaConfigSectionStorage extends LitElement {
await panelIsReady(this);
}
protected willUpdate(changedProps: PropertyValues<this>): void {
super.willUpdate(changedProps);
// Recorder can finish loading after the page mounted during startup
if (
changedProps.has("hass") &&
!this._databaseRequested &&
isComponentLoaded(this.hass.config, "recorder")
) {
this._databaseRequested = true;
this._loadDatabaseUsage();
}
}
protected render(): TemplateResult | typeof nothing {
if (this._mountsInfo === undefined) {
return nothing;
@@ -101,6 +128,7 @@ class HaConfigSectionStorage extends LitElement {
].includes(mount.type)
);
const isHAOS = this._hostInfo?.features.includes("haos");
const hasRecorder = isComponentLoaded(this.hass.config, "recorder");
return html`
<hass-subpage
back-path="/config/system"
@@ -108,6 +136,19 @@ class HaConfigSectionStorage extends LitElement {
.narrow=${this.narrow}
.header=${this.hass.localize("ui.panel.config.storage.caption")}
>
${
hasRecorder
? html`<ha-icon-button
slot="toolbar-icon"
.disabled=${this._databaseLoading || this._databaseAnalyzing}
.path=${mdiRefresh}
.label=${this.hass.localize(
"ui.panel.config.storage.database.analyze"
)}
@click=${this._analyzeDatabase}
></ha-icon-button>`
: nothing
}
<div class="content">
${
this._error
@@ -154,9 +195,12 @@ class HaConfigSectionStorage extends LitElement {
: ""
}
${
isComponentLoaded(this.hass.config, "recorder")
hasRecorder
? html`<storage-database-card
.narrow=${this.narrow}
.usage=${this._databaseUsage}
.analyzing=${this._databaseAnalyzing}
.error=${this._databaseError}
></storage-database-card>`
: nothing
}
@@ -396,6 +440,45 @@ class HaConfigSectionStorage extends LitElement {
}
}
private async _loadDatabaseUsage(): Promise<void> {
this._databaseLoading = true;
this._databaseError = undefined;
try {
this._databaseUsage = await fetchRecorderDatabaseUsage(this.hass);
} catch (err: any) {
this._databaseError = this._databaseErrorMessage(err);
} finally {
this._databaseLoading = false;
}
}
private async _analyzeDatabase(): Promise<void> {
this._databaseAnalyzing = true;
this._databaseError = undefined;
try {
this._databaseUsage = await fetchRecorderDatabaseUsage(this.hass, true);
} catch (err: any) {
this._databaseError = this._databaseErrorMessage(err);
} finally {
this._databaseAnalyzing = false;
}
}
private _databaseErrorMessage(err: any): string {
switch (err.code) {
case "recorder_not_ready":
return this.hass.localize(
"ui.panel.config.storage.database.errors.recorder_not_ready"
);
case "migration_in_progress":
return this.hass.localize(
"ui.panel.config.storage.database.errors.migration_in_progress"
);
default:
return err.message || err.code || String(err);
}
}
private _moveDatadisk(): void {
showMoveDatadiskDialog(this, {
hostInfo: this._hostInfo!,
@@ -1,4 +1,4 @@
import type { PropertyValues, TemplateResult } from "lit";
import type { TemplateResult } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import type { HassConfig } from "home-assistant-js-websocket";
@@ -18,13 +18,11 @@ import type {
DataTableRowData,
} from "../../../components/data-table/ha-data-table";
import "../../../components/ha-alert";
import "../../../components/ha-button";
import "../../../components/ha-card";
import "../../../components/ha-segmented-bar";
import type { Segment } from "../../../components/ha-segmented-bar";
import "../../../components/ha-spinner";
import {
apiContext,
configContext,
fullEntitiesContext,
internationalizationContext,
@@ -36,13 +34,11 @@ import type {
RecorderTableUsage,
} from "../../../data/recorder";
import type { EntityRegistryEntry } from "../../../data/entity/entity_registry";
import { fetchRecorderDatabaseUsage } from "../../../data/recorder";
import { showMoreInfoDialog } from "../../../dialogs/more-info/show-ha-more-info-dialog";
import type { FrontendLocaleData } from "../../../data/translation";
import type { Themes } from "../../../data/ws-themes";
import type {
HomeAssistant,
HomeAssistantApi,
HomeAssistantConfig,
HomeAssistantInternationalization,
HomeAssistantUI,
@@ -126,6 +122,13 @@ interface EntityUsageRow extends DatabaseUsageRow, DataTableRowData {
export class StorageDatabaseCard extends LitElement {
@property({ type: Boolean }) public narrow = false;
// Undefined until loaded, null when no recent report exists.
@property({ attribute: false }) public usage?: RecorderDatabaseUsage | null;
@property({ type: Boolean }) public analyzing = false;
@property() public error?: string;
@state()
@consumeLocalize()
private _localize!: LocalizeFunc;
@@ -144,9 +147,6 @@ export class StorageDatabaseCard extends LitElement {
})
private _hassConfig!: HassConfig;
@consume({ context: apiContext, subscribe: true })
private _api!: HomeAssistantApi;
@state()
@consume({ context: uiContext, subscribe: true })
@transform<HomeAssistantUI, Themes>({
@@ -163,22 +163,8 @@ export class StorageDatabaseCard extends LitElement {
@consume({ context: fullEntitiesContext, subscribe: true })
private _entityRegistry: EntityRegistryEntry[] = [];
// Undefined until loaded, null when no recent report exists.
@state() private _usage?: RecorderDatabaseUsage | null;
@state() private _loading = false;
@state() private _analyzing = false;
@state() private _error?: string;
protected firstUpdated(changedProps: PropertyValues<this>): void {
super.firstUpdated(changedProps);
this._load();
}
protected render(): TemplateResult {
const usage = this._usage;
const usage = this.usage;
return html`
<ha-card
outlined
@@ -186,45 +172,34 @@ export class StorageDatabaseCard extends LitElement {
>
<div class="card-content">
${
this._error
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
this.error
? html`<ha-alert alert-type="error">${this.error}</ha-alert>`
: nothing
}
${
this.analyzing
? html`<div class="loading">
<ha-spinner></ha-spinner>
<span>
${this._localize(
"ui.panel.config.storage.database.analyzing"
)}
</span>
</div>`
: nothing
}
${
usage
? this._renderUsage(usage)
: this._analyzing
? html`<div class="loading">
<ha-spinner></ha-spinner>
<span>
${this._localize(
"ui.panel.config.storage.database.analyzing"
)}
</span>
</div>`
: usage === null
? html`<p class="description">
${this._localize(
"ui.panel.config.storage.database.description"
)}
</p>`
: nothing
: usage === null && !this.analyzing
? html`<p class="description">
${this._localize(
"ui.panel.config.storage.database.description"
)}
</p>`
: nothing
}
</div>
<div class="card-actions">
<ha-button
appearance="plain"
.loading=${this._analyzing}
.disabled=${this._loading || this._analyzing}
@click=${this._analyze}
>
${this._localize(
usage
? "ui.panel.config.storage.database.analyze_again"
: "ui.panel.config.storage.database.analyze"
)}
</ha-button>
</div>
</ha-card>
`;
}
@@ -468,45 +443,6 @@ export class StorageDatabaseCard extends LitElement {
});
};
private async _load() {
this._loading = true;
this._error = undefined;
try {
this._usage = await fetchRecorderDatabaseUsage(this._api);
} catch (err: any) {
this._error = this._errorMessage(err);
} finally {
this._loading = false;
}
}
private async _analyze() {
this._analyzing = true;
this._error = undefined;
try {
this._usage = await fetchRecorderDatabaseUsage(this._api, true);
} catch (err: any) {
this._error = this._errorMessage(err);
} finally {
this._analyzing = false;
}
}
private _errorMessage(err: any): string {
switch (err.code) {
case "recorder_not_ready":
return this._localize(
"ui.panel.config.storage.database.errors.recorder_not_ready"
);
case "migration_in_progress":
return this._localize(
"ui.panel.config.storage.database.errors.migration_in_progress"
);
default:
return err.message || err.code || String(err);
}
}
static styles = css`
ha-card {
margin-bottom: 12px;
@@ -516,10 +452,6 @@ export class StorageDatabaseCard extends LitElement {
flex-direction: column;
gap: var(--ha-space-4);
}
.card-actions {
display: flex;
justify-content: flex-end;
}
.loading {
display: flex;
align-items: center;
@@ -547,6 +479,7 @@ export class StorageDatabaseCard extends LitElement {
}
ha-data-table {
--data-table-border-width: 0;
--data-table-row-border-width: 0;
height: 100%;
}
`;
+5
View File
@@ -277,7 +277,12 @@ export const getMyRedirects = (): Redirects => ({
config: {
redirect: "/config/dashboard",
},
link: {
component: "cloud",
redirect: "/config/cloud",
},
cloud: {
// Old key of link, still used by existing links and my.home-assistant.io
component: "cloud",
redirect: "/config/cloud",
},
+2 -4
View File
@@ -10003,10 +10003,9 @@
"change_chart_type": "Change chart type",
"database": {
"title": "Database",
"description": "Analyze the database to see which tables, entities and statistics use the most space.",
"description": "Use the refresh button to analyze the database and see which tables, entities and statistics use the most space.",
"analyzing": "Analyzing the database, this can take a while on a large database...",
"analyze": "Analyze",
"analyze_again": "Analyze again",
"analyze": "Analyze database",
"as_of": "as of {time}",
"tables": "Tables",
"other_tables": "Other tables",
@@ -13079,7 +13078,6 @@
"location_name_default": "Home",
"address_label": "Search address",
"search_results": "Search results",
"selected_location": "Selected {location}",
"button_detect": "Detect",
"finish": "Next"
},