Created
September 16, 2026 16:39
-
-
Save davidc/f60f9ef440114123adeba7a3b822a6ae to your computer and use it in GitHub Desktop.
Fix Home Assistant energy Sankey diagram
This file contains hidden or 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
| frontend: | |
| extra_module_url: | |
| - /local/energy-rename.js |
This file contains hidden or 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
| (() => { | |
| 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