If you’ve ever need to make mass edits to your dashboard, you’ll find there’s no API in Home Assistant to do so. However, the config is there to be edited, you just have to get to it. This is a small Deno script that uses the HomeAssistant websocket API to get and set configs the same way that Lovelace does.
Create a long-lived API token for your Home Assistant user, and then create a .env
file in the base directory like so:
HASS_TOKEN=<your token>
Download your lovelace dashboard as JSON.
deno run --allow-net --allow-read=.env,.env.defaults clients.ts get > dashboard.json
Edit it as you see fit, then upload it back:
deno run --allow-net --allow-read=.env,.env.defaults clients.ts set < dashboard.json