Is it safe to delete before a restart the database and the .shm .wal files? What i will loose?
It is safe - I have had to do it several times over the 18 months I have been using HA, as it seems to have become corrupted.
You will lose your device history, but everything seems to work fine otherwise.
Do you need to stop the service from the web GUI before doing so? If I stop the service does that mean I might lose access to the web GUI?
Its a good idea to stop HA before deleting the database, but I’m not sure what you mean by
stop the service.
So basically it’s something that I need to do by removing the SD card? Can’t be done, for example, from configurator or samba?
You can do it via samba by 1) in your HA interface go to Configuration / General / Server Management / Stop. Then 2) in samba just delete the home-assistant_v2.db file. 3) restart HA.
When I did this my HA was dead!!
Not only a ping worked any longer.
Mine was as well. Or it seemed to get stuck in restarting. But removing the power from it and then plugging it in again and waiting a couple of minutes did the trick