If you have set up solutions in the smart home that fill the disk / SD card with data, then you may want to create an automation that deletes such files on a regular basis. With us, we have, among other things, set up camera recordings, and if you do not delete old files, they will quickly fill the disk / SD card.
To do this automatically, we have added the “Delete files in Home Assistant” service which can be found at https://github.com/chomupashchuk/delete-file-home-assistant.
Failure to follow the instructions that are described on github page, so it is extremely easy to install:
- Copy data to
custom_components
; - Restart Home Assistant to find the component;
- Include data in
configuration.yaml
; - Restart Home Asistant to see new services.
Når denne er på plass, så lager man en veldig enkel automasjon. I eksemplet her brukes Home Assistant sin egen automasjon, og ikke Node-Red.
Trigger is “time” here. Every night at 23:55:00 the automation is started
Under “Actions” then select “Call service” and the service “delete.files_in_folder”. In the data field, you must then specify the folder in which to delete files, and how old the files should be. In the example below, all files older than one week (604800 seconds) are deleted in the “media / recording” folder
If you want to keep files longer than a week, you only select the number of seconds you want to keep the files.