Created
June 22, 2020 04:51
-
-
Save balloob/580deaf8c3fc76948559c5963ed4d436 to your computer and use it in GitHub Desktop.
Add redirects to the Home Assistant sidebar to any place in Home Assistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Add a link to the sidebar to any path in Home Assistant | |
Put this file in <config>/www/panel-redirect.js | |
In configuration.yaml: | |
panel_custom: | |
- name: panel-redirect | |
# url_path needs to be unique for each panel_custom config | |
url_path: redirect-server-controls | |
sidebar_title: Server Controls | |
sidebar_icon: mdi:server | |
module_url: /local/panel-redirect.js | |
config: | |
# Where you want to redirect to | |
target: /config/server_control | |
*/ | |
class PanelRedirect extends HTMLElement { | |
connectedCallback() { | |
if (this._info) { | |
this._navigate(); | |
} | |
} | |
set panel(info) { | |
this._info = info; | |
if (this.isConnected) { | |
this._navigate(); | |
} | |
} | |
_navigate() { | |
history.replaceState(null, "", this._info.config.target); | |
const event = new Event("location-changed", { | |
bubbles: true, | |
composed: true, | |
}); | |
event.detail = { replace: true }; | |
this.dispatchEvent(event); | |
} | |
} | |
customElements.define("panel-redirect", PanelRedirect); |
The existing one can't be moved to the top of the screen
All of them can be moved. Long click the menu title.
The existing one can't be moved to the top of the screen
All of them can be moved. Long click the menu title.
Nope - settings and developer tools are pinned and cannot be moved - at least on my installation
Ah, sorry. Yes you are correct.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi - any clues anyone please? I'm lost.
I want to add an additional Settings menu to my sidebar. The existing one can't be moved to the top of the screen. I want all my most frequently used menu items on the first page to avoid too much scrolling. I'd like to do the same with the development tools too.
I'm set up like this, but the link persists in redirecting the url to /lovelace/0 or /lovelace/dashboard