Show a simple text file in a card

I have a simple text file that contains the size of my NAS drive and the attached USB drives. It looks like this:

7.3T  1.9T  5.4T  26% /volume1
3.6T  2.7T  962G  74% /volumeUSB1/usbshare
3.6T  894G  2.8T  25% /volumeUSB2/usbshare
4.6T  470G  4.1T  11% /volumeUSB4/usbshare
4.6T  219G  4.3T   5% /volumeUSB3/usbshare

I want to display this in a card on the view where my other info from my Synology is.

I have searched and found a solution using file sensor, but that only shows the last line.

I assume I am missing something obvious as this should be quite straight forward. But after struggling with all kind of options that I found i still can not find a solution.

The file is locally on my homeassistant ‘/config/syndisks/aa.txt’

I managed to solve it myself. It certainly is not an elegant way, but it works.

On my synology I replace all the linefeeds with QQ with this command:
sed ':a;N;$!ba;s/\n/QQ/g' /volume1/Media/j3.txt > /volume1/HAmount/config/syndisks/aa.txt

In configuration.yaml i added this sensor:


  - platform: file
    name: disksize
    file_path: /config/syndisks/aa.txt

Then on the markdown card I use this to show the contents:
{{ states('sensor.disksize')| regex_replace('QQ', '\\n') }}

1 Like