Delete files service

Please check out:

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

7 Likes

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

Any interest in making this installable via HACS?

Hi.

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
data:
  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.

1 Like

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.

This is great, thanks for putting it together. One thing I noticed, your readme.md 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 readme.md 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 https://github.com/chomupashchuk/delete-file-home-assistant 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