From 33e1d34cb1453b935b1c73ce1404173a45ac1d36 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 14 Oct 2021 11:17:44 -0700 Subject: [PATCH] Add support for device configuration URL (#10251) * Add support for device configuration URL * Lint * Tweak text --- gallery/src/demos/demo-integration-card.ts | 1 + src/data/device_registry.ts | 1 + .../config/devices/ha-config-device-page.ts | 32 ++++++++++++++++++- src/translations/en.json | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gallery/src/demos/demo-integration-card.ts b/gallery/src/demos/demo-integration-card.ts index ecfcd9671c..4da42f1279 100644 --- a/gallery/src/demos/demo-integration-card.ts +++ b/gallery/src/demos/demo-integration-card.ts @@ -212,6 +212,7 @@ const createDeviceRegistryEntries = ( area_id: null, name_by_user: null, disabled_by: null, + configuration_url: null, }, ]; diff --git a/src/data/device_registry.ts b/src/data/device_registry.ts index 8e074b5e2c..5c039437e4 100644 --- a/src/data/device_registry.ts +++ b/src/data/device_registry.ts @@ -18,6 +18,7 @@ export interface DeviceRegistryEntry { name_by_user: string | null; entry_type: "service" | null; disabled_by: string | null; + configuration_url: string | null; } export interface DeviceEntityLookup { diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index ebca2ef39e..39c9ab79e9 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -1,4 +1,4 @@ -import { mdiPencil, mdiPlusCircle } from "@mdi/js"; +import { mdiPencil, mdiPlusCircle, mdiOpenInNew } from "@mdi/js"; import "@polymer/paper-tooltip/paper-tooltip"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; @@ -13,6 +13,7 @@ import { slugify } from "../../../common/string/slugify"; import "../../../components/entity/ha-battery-icon"; import "../../../components/ha-icon-button"; import "../../../components/ha-icon-next"; +import "../../../components/ha-svg-icon"; import { AreaRegistryEntry } from "../../../data/area_registry"; import { ConfigEntry, @@ -316,6 +317,31 @@ export class HaConfigDevicePage extends LitElement { ` : html`` } + ${ + device.configuration_url + ? html` +
+ + + ${this.hass.localize( + `ui.panel.config.devices.open_configuration_url_${ + device.entry_type || "device" + }` + )} + + + +
+ ` + : "" + } ${this._renderIntegrationInfo(device, integrations)} @@ -944,6 +970,10 @@ export class HaConfigDevicePage extends LitElement { ha-card a { color: var(--primary-text-color); } + + ha-svg-icon[slot="trailingIcon"] { + display: block; + } `, ]; } diff --git a/src/translations/en.json b/src/translations/en.json index fddb6988d7..a31e5636ab 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2131,6 +2131,8 @@ "config_entry": "Config entry" }, "enabled_description": "Disabled devices will not be shown and entities belonging to the device will be disabled and not added to Home Assistant.", + "open_configuration_url_device": "Visit device", + "open_configuration_url_service": "Visit service", "automation": { "automations": "Automations", "no_automations": "No automations",