Skip to content

Conversation

@MindFreeze
Copy link
Member

@MindFreeze MindFreeze commented Jul 28, 2025

Proposed change

We need this for better space management. To show charts like this in the frontend
image

Reports only the main disk right now but eventually we'll need the same data for USB mounts and maybe some network mounts.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

@mdegat01 mdegat01 added the new-feature A new feature label Jul 28, 2025
Copy link
Contributor

@mdegat01 mdegat01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool! As its still in draft I'll just add comments for some thoughts looking at it rather then approve or not. But I'd love to see this UI in Home Assistant!

@mdegat01 mdegat01 added missing-documentation Added to pull requests that needs a docs, but none is linked needs-cli Pull requests needs CLI changes but none is linked needs-client-library Pull requests needs client library changes but none is linked labels Jul 28, 2025
@mdegat01
Copy link
Contributor

On the labels I added:

  • Missing documentation - Supervisor's API is documented here. So we'll need to update that for API changes
  • Need client library - We'll need to add support for this to our client library as Home Assistant is trying to use that for all supervisor access going forward
  • Need cli - Less important but presumably it would be nice to access this info from the cli in future

I can probably take care of these if you want, we just have to finalize the API first.

@MindFreeze
Copy link
Member Author

As we discussed, I updated the URL, tweaked the structure a bit and added "total_space" and "system". We can update the buckets more in the future but if the protocol is OK, I'll update the docs and lib.
IMO we don't need this in the cli as there you can just use du but we can add it if you want.

@agners
Copy link
Member

agners commented Aug 14, 2025

I run this on my production instance with a depth of 2, this is the json I got back:

{
  "result": "ok",
  "data": {
    "total_space": 984465879040,
    "used_space": 213384400896,
    "children": {
      "addons_data": {
        "used_space": 17918974193,
        "children": {
          "core_configurator": {
            "used_space": 173
          },
          "77f1785d_chip_tool": {
            "used_space": 2
          },
          "core_whisper": {
            "used_space": 3892688550
          },
          "a0d7b954_vscode": {
            "used_space": 176693578
          },
          "core_mosquitto": {
            "used_space": 845657
          },
          "982ee2c4_volvo2mqtt": {
            "used_space": 475
          },
          "core_ssh": {
            "used_space": 38000998
          },
          "a0d7b954_influxdb": {
            "used_space": 8218539131
          },
          "a0d7b954_grafana": {
            "used_space": 1215195
          },
          "a0d7b954_uptime-kuma": {
            "used_space": 671268550
          },
          "core_letsencrypt": {
            "used_space": 445994
          },
          "core_piper": {
            "used_space": 442690429
          },
          "a0d7b954_ssh": {
            "used_space": 6290
          },
          "core_git_pull": {
            "used_space": 2376
          },
          "a0d7b954_logviewer": {
            "used_space": 76
          },
          "core_mariadb": {
            "used_space": 4299634590
          },
          "core_silabs_flasher": {
            "used_space": 109
          },
          "core_speech-to-phrase": {
            "used_space": 132782908
          },
          "a0d7b954_spotify": {
            "used_space": 158
          },
          "a0d7b954_phpmyadmin": {
            "used_space": 70
          },
          "17fe96b6_puppet": {
            "used_space": 207
          },
          "a0d7b954_glances": {
            "used_space": 397
          },
          "core_matter_server": {
            "used_space": 44157845
          },
          "core_vlc": {
            "used_space": 67
          },
          "core_assist_microphone": {
            "used_space": 368
          }
        }
      },
      "addons_config": {
        "used_space": 20040109,
        "children": {
          "a0d7b954_emqx": {
            "used_space": 3355776
          },
          "core_matter_server": {
            "used_space": 16684333
          }
        }
      },
      "media": {
        "used_space": 619970,
        "children": {
          "frigate": {
            "used_space": 65536
          }
        }
      },
      "share": {
        "used_space": 18309324,
        "children": {
          "mosquitto": {
            "used_space": 116
          },
          "speech-to-phrase": {
            "used_space": 18309208
          }
        }
      },
      "backup": {
        "used_space": 174410946560
      },
      "ssl": {
        "used_space": 3267
      },
      "homeassistant": {
        "used_space": 134055761,
        "children": {
          "custom_components": {
            "used_space": 122467
          },
          "glances": {
            "used_space": 8981
          },
          "blueprints": {
            "used_space": 53063
          },
          "python-matter-server": {
            "used_space": 4351441
          },
          "ota": {
            "used_space": 240760
          },
          "iotawatt_ha": {
            "used_space": 75066
          },
          ".storage": {
            "used_space": 39609972
          },
          "custom_zha_quirks": {
            "used_space": 10573
          },
          "esphome": {
            "used_space": 2977631
          },
          ".git": {
            "used_space": 1527118
          },
          "automations": {
            "used_space": 26032
          },
          "frigate-hass-integration": {
            "used_space": 396310
          },
          "www": {
            "used_space": 371349
          },
          "hass-weather-srgssr": {
            "used_space": 521089
          },
          "tts": {
            "used_space": 10866909
          }
        }
      },
      "system": {
        "used_space": 20881451712
      }
    }
  }
}

This is from a rather simple installation on Home Assistant Green

{
  "result": "ok",
  "data": {
    "total_space": 30016831488,
    "used_space": 5170909184,
    "children": {
      "addons_data": {
        "used_space": 5073,
        "children": {
          "core_ssh": {
            "used_space": 5073
          }
        }
      },
      "addons_config": {
        "used_space": 11067,
        "children": {
          "core_zwave_js": {
            "used_space": 11067
          }
        }
      },
      "media": {
        "used_space": 0
      },
      "share": {
        "used_space": 0
      },
      "backup": {
        "used_space": 11151360
      },
      "ssl": {
        "used_space": 0
      },
      "homeassistant": {
        "used_space": 2355866,
        "children": {
          ".storage": {
            "used_space": 66945
          },
          "blueprints": {
            "used_space": 5703
          }
        }
      },
      "system": {
        "used_space": 5157385818
      }
    }
  }
}
# du -sh *
6.2G    docker
484.4M  logs
16.0K   lost+found
20.0K   rngtest
61.4M   supervisor
1.3G    swapfile

What I generally notice is that quite some space is essentially unattributed and lands in system. I guess we could use the Docker API to get container image sizes. However, due to layer sharing using individual image sizes may add up to more space than actually occupied, which can lead to weird graphs in the end 🙈

@agners
Copy link
Member

agners commented Aug 14, 2025

When you look at the Home Assistant Green output, pretty much everything is accounted for System at this point.

# du -s -x *
3165276 docker
504204  logs
16      lost+found
20      rngtest
65036   supervisor
1325764 swapfile

Docker has the /system/df API (or docker system df -v command) which would allow for more detailed information. But as mentioned, the shared space makes things complicated to attribute 😢

REPOSITORY                                        TAG          IMAGE ID       CREATED        SIZE      SHARED SIZE   UNIQUE SIZE   CONTAINERS
agners/aarch64-hassio-supervisor                  latest       7e3dc674f09f   3 hours ago    490MB     53.77MB       436.2MB       1
ghcr.io/home-assistant/aarch64-hassio-cli         2025.08.1    b99ab04c1358   40 hours ago   62.7MB    53.77MB       8.972MB       1
ghcr.io/home-assistant/aarch64-hassio-audio       2025.08.0    de6ae9c3a553   3 days ago     96.2MB    53.77MB       42.39MB       1
ghcr.io/home-assistant/aarch64-hassio-dns         2025.08.0    31a532040358   3 days ago     77.5MB    53.77MB       23.73MB       1
ghcr.io/home-assistant/aarch64-hassio-multicast   2025.08.0    2afd5d4f11cb   3 days ago     53.9MB    53.77MB       170.7kB       1
ghcr.io/home-assistant/green-homeassistant        2025.8.0b2   fe0f4fde185d   10 days ago    2GB       0B            2GB           1
homeassistant/aarch64-addon-ssh                   9.18.0       54189453a186   7 weeks ago    132MB     0B            132.3MB       1
ghcr.io/home-assistant/aarch64-hassio-observer    2025.02.0    abf1bf606aca   5 months ago   9.53MB    0B            9.532MB       1

I am fine starting with the current rather simple and straight forward approach. It will help to have a rough overview where space goes, especially if users have local backups/media or add-ons with big user data (e.g. InfluxDB). But I think it will raise questions pretty quickly, e.g. especially on a newly installed system with a couple of Add-ons installed: Users will wonder why "Add-on" is still small, or "System" occupying so much space... Since the frontend for this API will be part of Core, we need to consider how we can evolve the API if needed.

@MindFreeze
Copy link
Member Author

I run this on my production instance with a depth of 2, this is the json I got back:

This is from a rather simple installation on Home Assistant Green

What I generally notice is that quite some space is essentially unattributed and lands in system. I guess we could use the Docker API to get container image sizes. However, due to layer sharing using individual image sizes may add up to more space than actually occupied, which can lead to weird graphs in the end 🙈

Here are the charts from this json
image
image

@MindFreeze
Copy link
Member Author

Updated the url and structure as discussed. Also here is an example of another prod system
image

@agners
Copy link
Member

agners commented Aug 19, 2025

@MindFreeze one of the use case is certainly that users can learn which add-on uses lots of space. What is the current plan for the add-on names? The code currently returns directory names, which matches add-on slugs. is the idea that the frontend translates those or is the intention to do this in the backend later on?

@MindFreeze
Copy link
Member Author

Both are possible. With the current format, Supervisor can add the names as label or leave the labels empty and let frontend translate using the id. We can figure it out in the next PRs

@MindFreeze
Copy link
Member Author

The first iteration will only display the top level info anyway. Deeper visualizations will be done later

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, very nice addition, looking forward for this to land 🤩

@agners agners merged commit 2324b70 into home-assistant:main Aug 19, 2025
23 checks passed
@MindFreeze MindFreeze deleted the storage branch August 19, 2025 08:55
@agners agners added needs-cli Pull requests needs CLI changes but none is linked and removed needs-client-library Pull requests needs client library changes but none is linked missing-documentation Added to pull requests that needs a docs, but none is linked needs-cli Pull requests needs CLI changes but none is linked labels Aug 19, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2025
@mdegat01 mdegat01 removed the needs-cli Pull requests needs CLI changes but none is linked label Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants