I agree that this has been really annoying. I want to configure my user profile settings once and then save them permanently, so that I can use them across multiple devices and sessions.
@jerrm Thanks for the tip about HA using localstorage. I was able to hack together a workaround that will restore my settings from custom.js
.
You’ll need to set up custom.js
as an extra_module_url
option in config/configuration.yaml
:
frontend:
extra_module_url:
- /local/custom.js
Then you can add this JS to www/custom.js
:
// Persistent settings across multiple devices / sessions
// ------------------------------------------------------
(function () {
// Visit /profile?edit=1 to change your settings, then update them here.
const settings = {
defaultPanel: '"lovelace"',
dockedSidebar: '"docked"',
enableShortcuts: "true",
hiddenTabs: "{}",
selectedLanguage: "null",
selectedTheme: '{"dark":true}',
sidebarHiddenPanels: '[]',
sidebarPanelOrder:
'["lovelace","hacs","logbook", "..."]',
suspendWhenHidden: "true",
vibrate: "true",
};
let settingsUpdated = false;
const currentSettings = {};
Object.keys(settings).forEach((key) => {
currentSettings[key] = localStorage.getItem(key);
if (currentSettings[key] !== settings[key]) {
localStorage.setItem(key, settings[key]);
settingsUpdated = true;
}
});
const urlSearchParams = new URLSearchParams(location.search);
if (!settingsUpdated) {
console.log("Settings are up to date.");
return;
}
if (urlSearchParams.get("edit") === "1") {
console.warn(
"Settings updated:\n",
JSON.stringify(currentSettings, null, 2)
);
} else {
console.warn("Settings updated, reloading page...");
location.reload();
}
})();
Now you can visit /profile?edit=1
to change your settings. Once you’re finished, open the developer tools and reload the page (make sure you uncheck “Disable cache” in the Network tab). You’ll see your updated settings in the logs:
Copy this and paste it into custom.js
, then refresh the page. You should now see Settings are up to date.
in the logs. Now your settings will be restored automatically whenever you sign in.
Note: The same settings will be used by all users. I couldn’t figure out how to get the current user ID.
This will also be really nice for my wall-mounted dashboards, I couldn’t figure out any other way to set the dark theme by default. People have been complaining about that for years as well