Delete files service

Please check out:

it is a service i’ve created to delete snapshots in my case.


Thanks. Checked it for same type of task. I’m also needed to remove my camera snapshots. Works perfectly for me! You saved my time

1 Like

Any interest in making this installable via HACS?


I have not heard of HACS before, I can have a look into it.

I have followed the steps in the read me and after restarting I can now see the “delete.file” and “delete.files_in_folder” services.
I then tried deleting the file “/config/www/camera/snapshots/image.jpg” by calling the service using Developer Tools > Services

service: delete.file
  file: '/config/www/camera/snapshots/image.jpg'

I get an error message "Failed to call service delete/file. is not recognized as a file

Can anyone tell me where I’m going wrong please?

I’ve managed to solve my own question… The service data that I needed to use was

file: /config/www/camera/snapshots/image.jpg

Now I can confirm that deleting a single file works by calling the service from developer tools, would anyone know if I can call this service from node red? The server, domain and service all auto populate but I’m unsure of the syntax for the data.

As you noticed the data filed was incorrect and it is not the first time the same was reported.
Note that in README.MD a structure is written for things like templates and automations, where you mention service and data. Developer tools tab is another story as it has dedicated fields for service name and data. In your example instead of file the integration in fact got service and data as higher level parameters in yaml format.
I have updated component with a new check to see if file or folder are found.

1 Like

I have not used node red. Data format should depend on how it works. {} hints at JSON instead of YAML markup (HA uses yaml for some time now in Developer tools), but not 100% sure. You may try {"file": "/config..."} maybe with and without {}.

Thanks for explaining @chomu. That makes perfect sense. I have just tested node red using JSON as you suggested and it works perfectly

    "file": "/config/www/camera/snapshots/image.jpg"

You could also use my integration for moving or deleting snapshots.


Sounds good that there are other options to handle files. My integration was created with sole purpose to deletes files (either by specifying them directly or by specifying folder to scan with additional parameters), nothing more is planned.

1 Like

This is great, thanks for putting it together. One thing I noticed, your file states that the default value for “time” is 86400. However, the documentation on “developer tools > service” states that the default is 3600. In practice, it seems like the actual default is 3600. You should consider updating your to reflect the correct default.

Values aligned. That happens when updating files in multiple places without automated synchronization.

1 Like

Hello, it still works.
But since a few days i have following in the log viewer

2021-03-13 00:46:37 WARNING (MainThread) [homeassistant.loader] You are using a custom integration delete which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-03-13 00:46:37 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'delete'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'delete'

LG Werner may be you do not know that.

13 days ago a manifest was added with a version to the component to get rid of a second warning.

I’ve tried changing structure to be HACS compliant so please let me know if it works or not.

1 Like

I’ve just reinstalled the delete files service using Hacs. The process was as follows

  1. Go to */hacs/entry to open the Home Assistant Community Store
  2. Select “Integrations”
  3. Click the three dots in the top right corner and select “Custom Repositories”
  4. Add URL and select category as “Integration”
  5. Go to */config/server_control and select “Restart”
  6. Add the line “delete:” to the file /config/configuration.yaml
  7. Go to /config/server_control to check configuration and then restart server

Dear @Davros ,

please enlight me a little bit, as I’m confused how to properly use this tool…

After installing it:

  • do I simply declare it in the GLOBAL configuration yaml, with the desired parameters (folder name, what to delete, etc)? If yes, how exactly? You only mentioned to add delete: but I’m lost how to exactly format the rest, since in @chomu 's github page based on the instructions it seems to be more like a service call to me, to be used in automation…

  • or simply use it an automation based on the github description as a service, triggering it based on time frequency, calling it like every day? If this is the correct solution, do I have to add anything to global configuration.yaml, and if yes, what exactly?

I’d like to delete plate recognition camera snapshots older than a week from a folder, to not let it grow too big.

Many thanks in advance!

oh, I’m sorry, after rereading @chomu 's instructions I think I might answer my own question, so basically:

  • copy (or use HACS to install) integration
  • declare in global config yaml simply with one line as delete:, nothing more,
  • then use it as a service in whatever way you’d like (node red as others stated above, or automation run periodically)

That’s correct. Once you have installed the integration and added the line “delete:” to the file /config/configuration.yaml you will need a reboot but then you should see the services “delete.file”, “delete.file_in_folder” and “remote.delete_command”. These service allow you to create scripts or automations.

1 Like