Skip to content

Instantly share code, notes, and snippets.

@davidc
Created September 16, 2026 16:39
Show Gist options
  • Select an option

  • Save davidc/f60f9ef440114123adeba7a3b822a6ae to your computer and use it in GitHub Desktop.

Select an option

Save davidc/f60f9ef440114123adeba7a3b822a6ae to your computer and use it in GitHub Desktop.
Fix Home Assistant energy Sankey diagram
frontend:
extra_module_url:
- /local/energy-rename.js
(() => {
const SUBSTITUTIONS = {
"ui.panel.lovelace.cards.energy.energy_devices_detail_graph.untracked_consumption":
"Came in a fluffer",
"ui.panel.lovelace.cards.energy.energy_devices_graph.untracked_consumption":
"Came in a fluffer",
};
const originalFetch = window.fetch;
window.fetch = async (...args) => {
const response = await originalFetch(...args);
const url =
typeof args[0] === "string" ? args[0] : args[0]?.url ?? "";
if (!url.includes("/translations/") || !url.endsWith(".json")) {
return response;
}
const data = await response.clone().json();
let modified = false;
for (const [key, value] of Object.entries(SUBSTITUTIONS)) {
if (data[key] !== undefined) {
data[key] = value;
modified = true;
}
}
if (!modified) return response;
return new Response(JSON.stringify(data), {
status: response.status,
statusText: response.statusText,
headers: new Headers(response.headers),
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment