From f428d6b3f2316a4ee42c7ae8350171c83be37ed6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 24 Jul 2025 21:53:04 +0200 Subject: [PATCH] Add download device info button (#26278) * Add download device info button * Update src/panels/config/core/ha-config-section-analytics.ts * Guard download support * Update src/translations/en.json --- .../core/ha-config-section-analytics.ts | 37 ++++++++++++++++++- src/translations/en.json | 3 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/panels/config/core/ha-config-section-analytics.ts b/src/panels/config/core/ha-config-section-analytics.ts index c64ede995d..aeaa0e6f27 100644 --- a/src/panels/config/core/ha-config-section-analytics.ts +++ b/src/panels/config/core/ha-config-section-analytics.ts @@ -1,9 +1,19 @@ +import { mdiDotsVertical, mdiDownload } from "@mdi/js"; import type { TemplateResult } from "lit"; -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; +import "../../../components/ha-button-menu"; +import "../../../components/ha-icon-button"; +import "../../../components/ha-list-item"; +import "../../../components/ha-svg-icon"; +import { getSignedPath } from "../../../data/auth"; import "../../../layouts/hass-subpage"; import type { HomeAssistant, Route } from "../../../types"; import "./ha-config-analytics"; +import { + downloadFileSupported, + fileDownload, +} from "../../../util/file_download"; @customElement("ha-config-section-analytics") class HaConfigSectionAnalytics extends LitElement { @@ -21,6 +31,26 @@ class HaConfigSectionAnalytics extends LitElement { .narrow=${this.narrow} .header=${this.hass.localize("ui.panel.config.analytics.caption")} > + ${downloadFileSupported(this.hass) + ? html` + + + + + + ${this.hass.localize( + "ui.panel.config.analytics.download_device_info" + )} + + + ` + : nothing}
@@ -28,6 +58,11 @@ class HaConfigSectionAnalytics extends LitElement { `; } + private async _handleOverflowAction(): Promise { + const signedPath = await getSignedPath(this.hass, "/api/analytics/devices"); + fileDownload(signedPath.path); + } + static styles = css` .content { padding: 28px 20px 0; diff --git a/src/translations/en.json b/src/translations/en.json index a6de4a8e72..42bc6842fc 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -6541,7 +6541,8 @@ }, "need_base_enabled": "You need to enable basic analytics for this option to be available", "learn_more": "How we process your data", - "intro": "Share anonymized information from your installation to help make Home Assistant better and help us convince manufacturers to add local control and privacy-focused features." + "intro": "Share anonymized information from your installation to help make Home Assistant better and help us convince manufacturers to add local control and privacy-focused features.", + "download_device_info": "Preview device analytics" }, "network": { "caption": "Network",