Skip to content
المشاريع

giuliodali/ha-db-storage-manager

عرض على GitHub

حول

Home Assistant Database Explorer and Size Reducer: See where your Home Assistant database space goes, and safely shrink it

البيانات والتحليلات

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • Overview - Live database size, free space, unreferenced data, cleanup candidates, treemap by integration and type, largest entities, size over time with free space / undo data and long-term statistics stacked.
  • Entities - Search and faceted filters (Suggestion, Referenced In, Integration, Device, Type, Defined in, Retention, Status, Last update). Size bars split states from statistics.
  • Referenced In - Counts every place an entity is used: automations, scripts, scenes, dashboards (per view), helpers, Energy dashboard, YAML files (including sql and command_line definitions).
  • Actions - Disable, clear history, disable and clear, change retention. Each shows a preview first: what happens to each entity, how much it frees, and warnings.

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
+٢
خلال 15 يومًا
+٦
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

DB Storage Manager icon

DB Storage Manager

See exactly where your Home Assistant database space goes, and safely get it back.
A HACS integration with a sidebar panel, undo for everything it clears, and per-entity history retention.

HACS Custom Release Validate License: MIT

Walkthrough: find a spike, filter to leftover history, clear it with a backup, set a retention rule, undo from History

The problem

Home Assistant's database only ever grows. One chatty sensor, a few integrations you removed last year, an energy integration that imports a statistic every half hour: none of it announces itself. You find out when backups take minutes, restores crawl, the History page stutters, or the SD card or disk fills.

Home Assistant gives you one global knob (purge_keep_days) and a purge button. It can't tell you which entity is costing you space, whether anything uses it, or let you take it back if you clear the wrong thing.

What you get

  • Know where the space goes. Every entity sized, split into state history and long-term statistics, by integration, device and type.
  • Know what is safe to remove. Each entity gets a suggestion (Remove history, Disable, Review, Keep) with the reasons, based on whether your automations, scripts, dashboards, helpers and YAML still reference it.
  • Clear it with a safety net. Everything an action removes is saved to one compressed backup first. One click on Undo puts it all back.
  • Keep it small automatically. Give a noisy sensor its own retention (1, 3, 5 or 7 days of detailed states) instead of shortening history for the whole house. Long-term statistics for graphs and Energy are never touched.
  • Find what caused a spike. Drag across the size-over-time chart to see which entities wrote data in that period.
  • Nothing hidden. Every nightly retention run is logged on the History tab, in two sensors and as an event; turn the schedule off and call db_storage_manager.run_retention from your own automation if you want a trace.

Features

Overview Live database size, free space, unreferenced data, cleanup candidates, treemap by integration and type, largest entities, size over time with free space / undo data and long-term statistics stacked.
Entities Search and faceted filters (Suggestion, Referenced In, Integration, Device, Type, Defined in, Retention, Status, Last update). Size bars split states from statistics.
Referenced In Counts every place an entity is used: automations, scripts, scenes, dashboards (per view), helpers, Energy dashboard, YAML files (including sql and command_line definitions).
Actions Disable, clear history, disable and clear, change retention. Each shows a preview first: what happens to each entity, how much it frees, and warnings.
Undo Whole-batch undo from the History tab. Only missing rows are restored, so data recorded since is kept.
Retention Per-entity limits on state history, enforced by a nightly job the integration schedules itself, followed by a repack to return the space.
Inspector Browse the raw stored states (with collapsible JSON attributes), hourly and 5-minute statistics for any entity.
Settings Hide automations; Home Assistant's default state retention as a slider with the predicted space freed or gained (shows the recorder: purge_keep_days value to set in your YAML); long-term statistics retention in 6-month steps, with a separate limit for Energy dashboard statistics.
Reclaim Repack the database so freed space goes back to the disk, and watch the file shrink.
Sensors, event, services Database size and free space, retention rules and last run, a db_storage_manager_retention_run event and a db_storage_manager.run_retention action for your own automations.

Overview

Entities filtered to Remove history

Install (via HACS)

Open your Home Assistant instance and open this repository in HACS.

  1. Click the button above (or search for DB Storage Manager in HACS), then Download.

  2. Restart Home Assistant.

  3. Add the integration:

    Open your Home Assistant instance and start setting up DB Storage Manager.

    (or Settings → Devices & services → Add integration → DB Storage Manager).

  4. Open DB Storage in the sidebar (administrators only).

Take a backup first (Settings → System → Backups). The integration only changes what you ask it to, and backs that up, but a backup is cheap.

Five-minute tour

  1. Press Re-Scan (the first scan takes a few seconds).
  2. On Entities, tick Remove history under Suggestion: entities that no longer exist or are disabled, but still hold history.
  3. Select them, press Clear history, read the preview, confirm. A backup is written first.
  4. Find a chatty sensor, select it, press Change retention and pick 1d or 3d.
  5. Open History to see what you did, what each action freed, and Undo any of it.

More in the docs below.

Documentation

Getting started Requirements, install, first scan, what each tab is for
Finding things Search, filters, suggestions, Referenced In, the period drill-down, the inspector
Actions and undo What each action does, previews, backups, undoing, History tab
Retention Per-entity limits, how the nightly job runs, how to see and trace it
Settings Hide automations, default state retention, long-term statistics retention
Options, sensors and services Everything you can configure or automate against
How it stays safe What it touches, what it never touches, where files live
Troubleshooting and FAQ Common questions and fixes

Requirements

  • Home Assistant 2026.11 or newer, with the recorder on SQLite (the default). MariaDB and PostgreSQL are not supported.
  • An administrator account (the panel is admin-only).

Limits worth knowing

  • "Referenced In" matches literal entity ids. It can't see dynamic references (expand(), states.sensor, built-up ids, area or label targets) or anything outside Home Assistant. Entities in a domain used by such templates are flagged "+N dynamic". Suggestions are advice, not verdicts.
  • It never deletes entities themselves. Disabling keeps the registry entry, which is what stops an integration re-creating the entity. It edits configuration.yaml only to save the default state retention you set on the Settings page.
  • Size figures for single entities are estimates scaled to the real table sizes. Rankings are reliable.
  • Nightly retention runs are a rolling window and are not backed up. The first clean-up when you create a rule is.

Contributing

Issues and pull requests are welcome. The panel source is in frontend-src/ (Lit and ECharts, built with Vite); the built bundle is committed so HACS users need no build step.

cd frontend-src && npm ci && npm run build      # writes custom_components/db_storage_manager/frontend/
pip install pytest-homeassistant-custom-component && pytest -q

Changes are listed in the changelog. Released under the MIT licence.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…