I have a mini-PC (Linux) that serves as my Home Assistant host, as well as a Jellyfin media center. The HA instance is setup using in a virtual machine.
What I’d like to do is be able to read the remaining disk size of an external disk that is connected to my mini-PC from my HA dashboard. However, I’m not sure what would be the best approach, and I’m curious what you think.
So far, I have considered the following 2 options:
In an HA automation, SSH from the HA virtual machine back to the host, run the df command, and pass its output back to the automation.
Setup a small Node app on the host PC that reads the disk space and presents it in a neat interface, which I could then iFrame in my HA dashboard.
However none of these options really feel all that great. Option 1 introduces a potential security risk, while option 2 feels a bit cumbersome.
I also run a VM (not Linux, on a Mac, so similar but not the same) and while I don’t report the hosts disk free space, I do have a couple of routines for external drives that I report free space on. How I handled it was to write a bash script to get the free space and then make a curl call to the Home Assistant API to update the helper entities I set up for that purpose.
You could also do this via a remote SSH call but it gets a bit more complicated to do, I’ve found just writing bash scripts (or Python, PHP or even using Mac automation and Applescripts) makes an easy way to quickly integrate information into HA. Then you put it on a cron job to run that script at whatever interval you feel is best.
What a great idea to call the Home Assistant API. Haven’t really worked with it before so it didn’t occur to me, but I have to say; this is what I’ll be doing. Thanks a lot!