Add "file size" sensor to the System Monitor

I would like to be able to track the size of my database (or other files on the system)
the system monitor only has directory support for size. i’d like to see support for individual files.
Thanks!
Note: i’m sure this could be done with another sensor (cli probably) but would just like to see it included in the system monitor platform as it feels more appropriate and one less platform to load and maintain.

You can use command line sensors to achieve this.

I have done the same thing - just dont have the specific command at hand at the moment (I am at work). Basically calling a du or df or stat (assuming you are using linux) - let the linux arguments begin!

My sensors snapshot below:

image

There is a custom component (search for filesize)

used like this…

- platform: filesize
  file_paths:
    - C:\Users\MyPc\AppData\Roaming\.homeassistant\home-assistant_v2.db
    - C:\Users\MyPc\AppData\Roaming\.homeassistant\home-assistant.log

I knew it could (i did it after i posted) but just like things more simplified :slight_smile:
sensor:

  • platform: command_line
    name: HA DB Size
    command: “ls -sh /home/homeassistant/.homeassistant/home-assistant_v2.db | cut -f1 -d ’ '”

There is a custom File size sensor component thanks to @robmarkcole

1 Like

So I have added the below.

  - platform: filesize
    file_paths:
      - /config/home-assistant_v2.db

What is the name of the sensor to read the data?

File paths must also be added to allowlist_external_dirs in your configuration.yaml

Then search for a sensor in dev tools.

1 Like

sensor.home-assistant_v2