Skip to content

Filesystem usage percentage incorrectly calculated #39

Description

@xxxarmitagexxx

Currently the Homeassistant integration is reporting the disk usage percentage as used/total. This ignores ext4's reserved blocks (5% by default). To be in line with df, it should report used/(used+available).

In my case for one of my drive 16TB exos, it was reporting 93% while df is reporting 98% which is the real metric based on what is actually usable by the user.

It can be fixed in the sensors.py under SmartSnifferFilesystemSensor.native_value by replacing return fs.get("use_percent") by:

used = fs.get("used_bytes", 0)
available = fs.get("available_bytes", 0)
if used + available == 0:
    return None
return round(used / (used + available) * 100, 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions