Ip_bans deletion via automation

Is it possible to automate the deletion of the ip_bans file? I’d like to create a UI button or a time based automation to delete this file.

Thank you.

Deleting ip_bans.yaml requires a restart of HA for it to take effect. So I doubt it. Anyway, if someone has a solution, I would like to know too.

@francisp You can automate the reboot of HA by calling homeassistant.restart service

@tom_l thank you, same reason why I’m looking for this - I’ll track this FR.

I know, but it is not always wanted.
Seems I voted for that FR already, just forgot about it.

1 Like

How to automatically delete ip_bans.yaml every day at 17:05?

  • edit configuration.yaml
  • create a new entry
shell_command:
  delete_ipbans: 'su root -c rm /homeassistant/ipbans.yaml'
  • save configuration.yaml
  • restart home assistent!
  • After a restart, create a new automation with name “Delete ipbans.yaml + reboot at 17:05”
  • Create a trigger at 17:05
  • Add an action and type “shell command: delete_ipbans”
  • Add an action and type “delay” and select 10 seconds
  • Add an action and type “Call service” and select “Home Assistant Core Integration: Restart”
  • Save the automation.

Unfortunately the automation does not delete the ipbans.yaml file. Probably a rights issue.
Anyone a solution ?

This is a great idea,

I got this working with the below:

shell_command:
  delete_ipbans: 'rm ip_bans.yaml'

I didn’t need sudo or su. the context of the shell seems to be the /homeassistant directory so you don’t need to supply it.