From 4e3b8759f4889444e507c6472445d8bdbe4dd673 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 24 Feb 2021 19:35:08 +0100 Subject: [PATCH 1/4] My redirects tweaks Add better error message for missing supervisor and add config and call service redirects --- .../service/developer-tools-service.ts | 9 +++++++ src/panels/my/ha-panel-my.ts | 26 ++++++++++++++----- src/translations/en.json | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index 8e331e93e41f..0d6771222d14 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -11,6 +11,7 @@ import memoizeOne from "memoize-one"; import { LocalStorage } from "../../../common/decorators/local-storage"; import { computeDomain } from "../../../common/entity/compute_domain"; import { computeObjectId } from "../../../common/entity/compute_object_id"; +import { extractSearchParam } from "../../../common/url/search-params"; import "../../../components/buttons/ha-progress-button"; import "../../../components/entity/ha-entity-picker"; import "../../../components/ha-card"; @@ -40,6 +41,14 @@ class HaPanelDevService extends LitElement { protected firstUpdated(params) { super.firstUpdated(params); + const serviceParam = extractSearchParam("service"); + if (serviceParam) { + this._serviceData = { + service: serviceParam, + target: {}, + data: {}, + }; + } if (!this._serviceData?.service) { const domain = Object.keys(this.hass.services).sort()[0]; const service = Object.keys(this.hass.services[domain]).sort()[0]; diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index 2a9887e6c366..9f47efc1bb19 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -15,6 +15,7 @@ import { import "../../layouts/hass-error-screen"; import { isComponentLoaded } from "../../common/config/is_component_loaded"; import { domainToName } from "../../data/integration"; +import { documentationUrl } from "../../util/documentation-url"; const REDIRECTS: Redirects = { developer_states: { @@ -23,12 +24,21 @@ const REDIRECTS: Redirects = { developer_services: { redirect: "/developer-tools/service", }, + developer_call_service: { + redirect: "/developer-tools/service", + params: { + service: "string", + }, + }, developer_template: { redirect: "/developer-tools/template", }, developer_events: { redirect: "/developer-tools/event", }, + config: { + redirect: "/config", + }, cloud: { component: "cloud", redirect: "/config/cloud", @@ -201,12 +211,16 @@ class HaPanelMy extends LitElement { ) || "This redirect is not supported."; break; case "no_supervisor": - error = - this.hass.localize( - "ui.panel.my.component_not_loaded", - "integration", - "Home Assistant Supervisor" - ) || "This redirect requires Home Assistant Supervisor."; + error = this.hass.localize( + "ui.panel.my.no_supervisor", + "docs_link", + html`${this.hass.localize("ui.panel.my.documentation")}` + ); break; default: error = this.hass.localize("ui.panel.my.error") || "Unknown error"; diff --git a/src/translations/en.json b/src/translations/en.json index 7e54c9717c9b..69507b4028ea 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -826,6 +826,8 @@ "my": { "not_supported": "This redirect is not supported by your Home Assistant instance. Check the {link} for the supported redirects and the version they where introduced.", "component_not_loaded": "This redirect is not supported by your Home Assistant instance. You need the integration {integration} to use this redirect.", + "no_supervisor": "This redirect is not supported by your Home Assistant installation. It needs either the Home Assistant Operating System or Home Assistant Supervised installation method. For more information, see the {docs_link}.", + "documentation": "documentation", "faq_link": "My Home Assistant FAQ", "error": "An unknown error occured" }, From 56b84c03baafcaffa897662f2861ade535e06d6d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 24 Feb 2021 19:42:25 +0100 Subject: [PATCH 2/4] Add zha, mqtt and zwave js --- src/panels/my/ha-panel-my.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index 9f47efc1bb19..507b4e1c9ac4 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -52,6 +52,15 @@ const REDIRECTS: Redirects = { domain: "string", }, }, + config_mqtt: { + redirect: "/config/mqtt", + }, + config_zha: { + redirect: "/config/zha/dashboard", + }, + config_zwave_js: { + redirect: "/config/zwave_js/dashboard", + }, devices: { redirect: "/config/devices/dashboard", }, From 2ce6a615721c306004c41d104f53be8b01f61893 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 24 Feb 2021 19:49:45 +0100 Subject: [PATCH 3/4] Add correct components and history and logbook --- src/panels/my/ha-panel-my.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index 507b4e1c9ac4..34933187fc91 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -53,12 +53,15 @@ const REDIRECTS: Redirects = { }, }, config_mqtt: { + component: "mqtt", redirect: "/config/mqtt", }, config_zha: { + component: "zha", redirect: "/config/zha/dashboard", }, config_zwave_js: { + component: "zwave_js", redirect: "/config/zwave_js/dashboard", }, devices: { @@ -71,39 +74,49 @@ const REDIRECTS: Redirects = { redirect: "/config/areas/dashboard", }, blueprints: { + component: "blueprint", redirect: "/config/blueprint/dashboard", }, blueprint_import: { + component: "blueprint", redirect: "/config/blueprint/dashboard/import", params: { blueprint_url: "url", }, }, automations: { + component: "automation", redirect: "/config/automation/dashboard", }, scenes: { + component: "scene", redirect: "/config/scene/dashboard", }, scripts: { + component: "script", redirect: "/config/script/dashboard", }, helpers: { redirect: "/config/helpers", }, tags: { + component: "tags", redirect: "/config/tags", }, lovelace_dashboards: { + component: "lovelace", redirect: "/config/lovelace/dashboards", }, lovelace_resources: { + component: "lovelace", redirect: "/config/lovelace/resources", }, people: { + component: "person", redirect: "/config/person", }, zones: { + component: "zone", redirect: "/config/zone", }, users: { @@ -127,6 +140,14 @@ const REDIRECTS: Redirects = { profile: { redirect: "/profile/dashboard", }, + logbook: { + component: "logbook", + redirect: "/logbook", + }, + history: { + component: "history", + redirect: "/history", + }, }; export type ParamType = "url" | "string"; From 2810d4ebc3bc139798873a3862d7626041801192 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 24 Feb 2021 19:50:43 +0100 Subject: [PATCH 4/4] Update developer-tools-service.ts --- src/panels/developer-tools/service/developer-tools-service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index 0d6771222d14..d9c6c5a8a15a 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -48,8 +48,7 @@ class HaPanelDevService extends LitElement { target: {}, data: {}, }; - } - if (!this._serviceData?.service) { + } else if (!this._serviceData?.service) { const domain = Object.keys(this.hass.services).sort()[0]; const service = Object.keys(this.hass.services[domain]).sort()[0]; this._serviceData = {