Skip to content

Instantly share code, notes, and snippets.

@thomasloven
Last active May 28, 2022 20:15
Show Gist options
  • Save thomasloven/2a37152725c582fec4420ecedb65ebe3 to your computer and use it in GitHub Desktop.
Save thomasloven/2a37152725c582fec4420ecedb65ebe3 to your computer and use it in GitHub Desktop.
/*
To move a panel to below the divider in Home Assistant
Add this to your configuration.yaml
frontend:
extra_module_url:
- /local/move-panel.js
And put the following into <config-dir>/www/move-panel.js
Replace URL_TO_MOVE with the url of your panel
*/
customElements.whenDefined('ha-sidebar').then(() => {
const URL_TO_MOVE = "/lovelace";
const sideBar = document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("#drawer > ha-sidebar");
sideBar.updateComplete.then(() => {
const listbox = sideBar.shadowRoot.querySelector("paper-listbox");
const buttons = listbox.querySelectorAll("a");
const divider = listbox.querySelector("div");
for (let i = 0; i < buttons.length; i++) {
if (buttons[i].href.endsWith(URL_TO_MOVE)) {
listbox.insertBefore(buttons[i], divider.nextSibling);
}
}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment