Due to the limitations of the folder sensor (not able to access /backup
as HA container when running HA OS), I went the MQTT path instead of using a file as temporary information cache. Works the same. Following InfluxDB information (database size) as sensor in Home Assistant - #17 by e-raser where InfluxDB folder size is gathered - same process.
The clue is to get the information at all, for this I used the community SSH & Web Terminal with protection mode off and using this within the init_commands
in the addons configuration section:
while [ 1 = 1 ]; do du -shm /backup | cut -f1 | mosquitto_pub -t homeassistant/sensor/system/foldersize/backup -r -u '<mqtt_username>' -P '<mqtt_password>' -l -i 'SSH-addon_init-command_1' && sleep 900; done &
So every 15 minutes (sleep 900
) the size is calculated and sent to the MQTT broker.
Then the following MQTT sensor creates the sensor entity:
mqtt:
sensor:
- name: Home-Assistant Size Folder /backup
unique_id: abc-abc-abc-abc
#entity_id: sensor.home_assistant_size_folder_backup
unit_of_measurement: MB
icon: mdi:folder
state_topic: "homeassistant/sensor/system/foldersize/backup"
state_class: total
entity_category: diagnostic
value_template: "{{ value }}"
Giving