Backup and data
Where the history is kept
Everything is in the app's own data folder, which Home Assistant includes in its backups. With the Docker image it is the folder you mount at /data.
| File | What's in it |
|---|---|
history.json | Devices, names, events, notes, battery records, stored devices, coordinator health and the rest of what you set. |
history.json.bak | The previous history.json, kept as a spare copy on each save. |
metrics.json | Hourly signal and message counts (14 days), daily link quality (90 days) and daily battery readings (400 days). |
scans.json | The last 40 routing scans of each network. |
coordinator_backups/ | Copies of each Zigbee2MQTT network's coordinator backup. They hold the network key, so only the app can read them. |
api_token | The token the integration uses to talk to the app. |
With the Docker image, options.json in the same folder holds the settings.
Uninstalling the app deletes this folder.
When it's written
To spare SD cards, the app doesn't write on every message:
- anything you set, and every event (offline, online, joined, renamed), is written within 30 seconds;
- what a device last said (last seen, readings, report counts) is written at most every 10 minutes;
- the trend data in
metrics.jsonis written every 15 minutes.
Stopping or restarting the app writes everything first, so only a power cut or a crash can lose those last minutes of readings.
The app keeps the last 3,000 events. When that is full, room is made first from devices with more than 50 events of one kind, such as a device that keeps going offline and online, so one noisy device doesn't push out the history of the others.
If the history file is damaged
If history.json can't be read when the app starts, after a disk fault or a file cut short, the app loads history.json.bak instead. At most the last few minutes of readings are missing. The app tells you with a notification in Home Assistant, and keeps the unreadable file as history.json.corrupt-<time>.
Backup and restore
Settings → Appearance & data → Backup:
- Download saves the full history and the signal and battery readings as one JSON file, named
zigbee-tracker-backup-<date>.json. Routing scan history isn't included. - Restore replaces the tracker's history with a backup file. Anything recorded since the backup is lost. The dialog offers Download current data first, so you can keep what's there now.
A restore brings back everything in the file, including firmware notes, your reporting-profile defaults, mesh score history, group history, battery stock and storage groups. A pause, held quiet-hours alerts and running escalations are about now, so they stay as they were before the restore.
Devices of a network the app doesn't listen to at the moment are restored as frozen, marked Not listened to. See ZHA and Matter.
This is separate from Home Assistant's own backups, so you can move the history to a new install, or between the app and the Docker image, or keep a copy before trying something risky.
CSV export
Export CSV, in the ⋮ menu or in Settings → Appearance & data → Export, downloads every device (except the coordinator) as a spreadsheet, one row per device:
IEEE address, name, former names, status, network, vendor, model, model ID, manufacturer, radio maker, description, type, power source, firmware, first seen, last seen, removed date, 24-hour signal, battery level, battery type and count, battery installed and last replaced dates, battery brand, number of replacements, 30-day uptime, area, Home Assistant name, purchase date, shop, price, warranty end, location, serial number and note.
Importing older history
The tracker starts recording when the app is installed, but Zigbee2MQTT and Home Assistant already know a lot about devices you've had before. On first start, and whenever you choose Import history (in the ⋮ menu or Settings → Appearance & data), the app reads:
| Source | What it gives |
|---|---|
Zigbee2MQTT configuration*.yaml (including backups) | Friendly names and descriptions |
Zigbee2MQTT database.db (including backups) | Model, manufacturer, last seen |
Zigbee2MQTT state.json | Last seen |
| Zigbee2MQTT logs | Joins, leaves, interviews and renames, with their times |
| Home Assistant device registry | Names you gave devices in Home Assistant, areas, and deleted devices |
| Home Assistant entity registry | Former names from deleted entities |
It looks in <config>/<base topic>/ for each network, which is where the Zigbee2MQTT app keeps its files. With the Docker image, it needs Home Assistant's config folder mounted at /homeassistant. Importing reads Zigbee2MQTT's files, so it isn't available when the app reads only ZHA or Matter.
Importing only adds: it fills in fields that are empty and adds names and events that aren't there yet. Devices found only in the files are added as removed. Devices you have forgotten are skipped. It's safe to run again.
The integration's z2m_tracker.import_history action does the same thing. See Integration and card.
Forgetting a device
Forget on a device deletes it, its events and its readings for good. It is on the device's Notes tab, and on the Removed from Zigbee2MQTT notice of a removed device.
To clear out many removed devices at once, pick the Removed or not listened to chip on Devices and use the Forget all N removed devices bar. It follows the search, so you can narrow it first, and asks before it deletes anything. It only covers devices removed from their network, not devices on a network the app doesn't listen to.
The app remembers which devices you forgot, so a history import doesn't bring them back. If a forgotten device is still on a network, or joins again later, it's tracked as a new device with an empty history.