Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing recording to other than default media folder on Home Assistant addon #6693

Closed
samuelolteanu opened this issue Jun 4, 2023 · 28 comments
Labels
enhancement New feature or request

Comments

@samuelolteanu
Copy link

samuelolteanu commented Jun 4, 2023

With the upcoming release of Home Assistant 2023.6, we can now add a samba folder to ha media. It's not however (easily) possible to change the default recording path of frigate addon to the samba media folder, something like this:

Captură de ecran 2023-06-04 033322

@samuelolteanu samuelolteanu added the enhancement New feature or request label Jun 4, 2023
@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 4, 2023

The media folders are added by name, I think it could make sense as a user to just add a share with the name frigate so it is used automatically

@dm7500
Copy link

dm7500 commented Jun 8, 2023

The media folders are added by name, I think it could make sense as a user to just add a share with the name frigate so it is used automatically

Just tried this using the below method in 2023.6:

  1. Uninstall Frigate add-on
  2. Delete all content found in frigate directory
  3. Re-create new frigate storage connection
  4. Reinstall Frigate add-on

Received errors about being unable to create recordings and clips sub-directories in frigate share. Even when I created them on my NAS manually, it gives me the below error in the Frigate log when starting up.

2023-06-08 04:46:56.210755053  [2023-06-08 00:46:56] frigate.app                    INFO    : Starting Frigate (0.12.0-da3e197)
2023-06-08 04:46:56.251065496  [2023-06-08 00:46:56] frigate.app                    INFO    : Creating directory: /tmp/cache
2023-06-08 04:46:56.254638897  [2023-06-08 00:46:56] peewee_migrate                 INFO    : Starting migrations
2023-06-08 04:46:56.255799739  unable to open database file
2023-06-08 04:46:57.467651600  [INFO] Service Frigate exited with code 1 (by signal 0)

Seems there either needs to be some guidance on how to set this up with the new Storage system in HASSOS, or an option as suggested here, to change the default recording path Frigate will use.

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 8, 2023

It sounds like it doesn't have write access is the problem, otherwise we'd expect it to just ignore the NAS and keep writing to local storage

@dm7500
Copy link

dm7500 commented Jun 8, 2023

That was my thought too. I was able to get it to work with the new NAS storage, but only by changing the frigate.db location to be on the local HA drive, using the below config

database:
  path: /config/frigate.db

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 8, 2023

That is going to be required in the next version of frigate anyway due to performance issues using the db on remote storage

@muzzak123
Copy link

muzzak123 commented Jun 27, 2023

@dm7500 I was able to get this to work by using your tips above, thx.
However rather than lose all my current frigate clips and recordings I did this.

  1. Stopped Frigate addon
  2. Created a temporary Network Storage link to my NAS share like so
    NAS Configt
  3. Moved the existing files in HA from /media/frigate to /media/frigate_temp (aka my NAS share)
  4. Moved the database location as you suggested and added entry to config
  5. As there doesnt seem to currently be a way to rename Network Storage in HA, I then deleted the Network Storage link to frigate_temp, and recreated it exactly the same but this time named it frigate. Hence the HA folder /media/frigate now points to the NAS folder.
  6. Start Frigate

So far it seems to be working well.

@muzzak123
Copy link

Just an update. Seems my method above isn't permanent and doesnt survive a reboot. I'm investigating why.

@muzzak123
Copy link

And now it seems my method is official :-)
https://docs.frigate.video/guides/ha_network_storage/#setting-up-remote-storage-for-frigate
I run my HA in a VM on the same box as my NAS. Seems I can reboot the HA VM no problem, so if you run HA on something separate to your NAS this method will work fine.
The issue I'm having is that after a full NAS reboot, it seems like HA is trying to mount the storage before it is available on the NAS

@erwindouna
Copy link

erwindouna commented Jul 8, 2023

And now it seems my method is official :-) https://docs.frigate.video/guides/ha_network_storage/#setting-up-remote-storage-for-frigate I run my HA in a VM on the same box as my NAS. Seems I can reboot the HA VM no problem, so if you run HA on something separate to your NAS this method will work fine. The issue I'm having is that after a full NAS reboot, it seems like HA is trying to mount the storage before it is available on the NAS

Would you be able to paste some screenshots and further instructions of your workable solution? I am running exactly the same situation HA in a VM on my NAS (I am also using Samba). It seems I am able to create a Network Storage and I have the db config entry included exactly as mentioned as in the documentation.
My odd situation is that Frigate still seems to be storing the recordings locally in the VM (I intend to keep it rather slim and use the NAS as an actual storage) and nothing is being sent to the shared folder. Maybe if you're willing to explain what and how you configured your shared folder on the NAS and what steps next to get it up and running?

@muzzak123
Copy link

@erwindouna Did you make sure you stopped the Frigate addon before you start ? The behaviour you are describing is typical when Frigate still has hold of the /media/frigate folder.
Another thing you can do to test the NAS side of things, is to copy a file from Windows to your NAS SMB folder you have chosen for Frigate to store it's data. You should be able to see this file through the HA GUI by selecting Media - My Media - frigate

@erwindouna
Copy link

@erwindouna Did you make sure you stopped the Frigate addon before you start ? The behaviour you are describing is typical when Frigate still has hold of the /media/frigate folder. Another thing you can do to test the NAS side of things, is to copy a file from Windows to your NAS SMB folder you have chosen for Frigate to store it's data. You should be able to see this file through the HA GUI by selecting Media - My Media - frigate

I tried your approach on testing to upload a file from Windows to the NAS SMB folder and try to see it in Media - Frigate. I didn't see the uploaded file showing up in HA. Best guess is that I configured something wrong on the NAS. When trying to update the configuration in HA, I am getting the error the mount is not empty. I'll have to look into this later (yet I have found a potential source for a solution: home-assistant/supervisor#4358 (comment)).

@muzzak123
Copy link

muzzak123 commented Jul 12, 2023

Yeah - It may also be a permissions issue. Check to ensure the userid that runs the VM on the NAS has read/write access to the SMB folder

@xekil
Copy link

xekil commented Jul 13, 2023

Just an update. Seems my method above isn't permanent and doesnt survive a reboot. I'm investigating why.

Good morning,

I have exactly the same problem, I use Haos on a VM and the media folder on my NAS Synology (NFS), if I restart Home Assitant (following an update for example) then frigate no longer saves on the NAS Synology :(

Have you found a permanent solution?
THANKS

@muzzak123
Copy link

@xekil So far the only way I can get it to survive a full NAS reboot is to turn off the Start on Boot in the Frigate integration, and then when everything is up I start Frigate manually

@xekil
Copy link

xekil commented Jul 15, 2023

Thanks for the reply, I suspected that. It's no big deal, I'm going to switch to an LXC configuration.

@thewan056
Copy link

thewan056 commented Jul 26, 2023

@xekil So far the only way I can get it to survive a full NAS reboot is to turn off the Start on Boot in the Frigate integration, and then when everything is up I start Frigate manually

you can automate this by exposing the NAS SNMP and getting HA to read specifically the value of the status of the volume that your frigate folder is located on. When the status of that volume becomes available, depends what your NAS SNMP reports, you can then start/restart Frigate or restart HA itself. My experience described below:

Note that my HA/Frigate setup is separate from my NAS. I use an automation to restart HA, leaving the Start on Boot enabled for Frigate, when the volume on my NAS that my Frigate is using reports itself to HA as "healthy" using SNMP. In my case restarting HA to mount the network share properly is more reliable than just starting/restarting frigate as sometimes HA doesn't remount the network share at all when it comes back online if HA starts before the network share is ready. With this setup I'm happy with my NAS rebooting anytime, including weekly reboots as my HA and Frigate will just fix itself.

Now if only Frigate can have a fall back storage so that it continues working in the event the NAS share disappears.

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jul 26, 2023

Closing this as from frigate's perspective using network shares for the addon is supported. Reconnection / other logic to the NAS is something that HA will need to clean up

https://docs.frigate.video/guides/ha_network_storage

@navarrolux
Copy link

navarrolux commented Sep 11, 2023

That was my thought too. I was able to get it to work with the new NAS storage, but only by changing the frigate.db location to be on the local HA drive, using the below config

database:
  path: /config/frigate.db

So where does the frigate.db file need to be? The instructions state to move it to the /config folder, but it was already there.
I have not been able to have frigate safe the recordings to my NAS.
any help would be greatly appreciated.

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Sep 11, 2023

So where does the frigate.db fine need to be? The instructions state to move it to the /config folder. but it was already there.

The only reason it would already be there is if you already had that in your config, in 0.12 the default location is /media/frigate/frigate.db

In 0.13 the default location will be /config/frigate.db

@navarrolux
Copy link

So where does the frigate.db fine need to be? The instructions state to move it to the /config folder. but it was already there.

The only reason it would already be there is if you already had that in your config, in 0.12 the default location is /media/frigate/frigate.db

In 0.13 the default location will be /config/frigate.db

Thank you. That helps explain that.
I tested it and, yes, the frigate.db was moved thanks to the config file.
Having said this, I am still not able to have frigate save to the NAS. any ideas as to where I can look next?
Thanks again

@NickM-27
Copy link
Sponsor Collaborator

it can be due to any number of reasons, more info is needed

@navarrolux
Copy link

navarrolux commented Sep 12, 2023

@NickM-27, thank you.
I finally figured it out.
My issue was that I had named the network storage in HA "frigate" but chose a different name for the folder on my NAS.
Once I named both the network storage in HA and the folder in my NAS as "frigate" it started working.
I do appreciate your help.

@samuelolteanu
Copy link
Author

samuelolteanu commented Sep 12, 2023

I've tested Frigate recording on samba for some time now and It's mostly fine. The remote folder needs to be always on or the addon will start to record locally and not switch back. Right now i've setup a ha ping binary sensor that stops or starts the addon depending on the network state of the samba server. Not sure yet if it fixed anything.

Update: it did. HA noticing/taking action for missing (currently active) network folder takes longer than 5 second ping interval. No Idea where is records up until the addon is stopped but somehow it recovers, once good ping.

@navarrolux
Copy link

After monitoring for an evening I'm noticing that frigate is writing the videos to both locations (local storage and NAS).
Is this the normal behavior?

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Sep 12, 2023

After monitoring for an evening I'm noticing that frigate is writing the videos to both locations (local storage and NAS).
Is this the normal behavior?

No, and this is not something that frigate has any control over. Frigate writes to one location inside the container /media/frigate/

if recordings are being written to both locations that is because multiple volumes have been bind mounted to the same location inside the frigate container. That is an HA / Supervisor issue (because that is what starts / stops / controls the frigate docker container)

@xAcrosonicx
Copy link

After monitoring for an evening I'm noticing that frigate is writing the videos to both locations (local storage and NAS). Is this the normal behavior?

@navarrolux - did you ever solve this? Mine is currently writing both to my NAS and /media/frigate for both recording and clips

@NickM-27
Copy link
Sponsor Collaborator

@xAcrosonicx that is not possible to be writing to both locations, most likely you are misunderstanding the UI (they don't make it clear). The /media is just a mount of the NAS share, if you delete a file on the NAS it will be deleted in /media as well

@xAcrosonicx
Copy link

@NickM-27 - thank you for clarifying! I was using terminal to find the large directories/files and noticed it showed my /media/frigate as the largest - hence my confusion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants