-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Enhancement Request: Ability to dynamically disable/enable individual cameras #1911
Comments
I would also really like to find a way to enable/disable particular cameras in frigate. I am trying to keep my CPU usage to a minimum and would like to enable/disable certain cameras based on time of day, presence detection, alarm activated, etc. Is it possible in a future release to stop the ffmpeg process for a camera if the detect, snapshot, and record switches are all turned off? |
@tbrausch I have a PR up to add the ability to selectively toggle motion detection which will help with this. Completely disabling ffmpeg for a camera selectively would be much more complicated but I don't think impossible. |
You could use MQTT, as shown here: frigate/<camera_name>/detect/set# frigate/<camera_name>/detect/state# frigate/<camera_name>/recordings/set# |
Yes, I can turn off objrect detection, but the ffmpeg process for motion
detection still runs, and this is what utilizes a bit of CPU resources,
especially with 6 cameras at one time.
…On Tue, Apr 19, 2022 at 1:59 PM crashnbernstein ***@***.***> wrote:
I would also really like to find a way to enable/disable particular
cameras in frigate. I am trying to keep my CPU usage to a minimum and would
like to enable/disable certain cameras based on time of day, presence
detection, alarm activated, etc. Is it possible in a future release to stop
the ffmpeg process for a camera if the detect, snapshot, and record
switches are all turned off?
You could use MQTT, as shown here:
https://docs.frigate.video/integrations/mqtt
frigate/<camera_name>/detect/set#
<https://docs.frigate.video/integrations/mqtt#frigatecamera_namedetectset>
Topic to turn detection for a camera on and off. Expected values are ON
and OFF.
frigate/<camera_name>/detect/state#
<https://docs.frigate.video/integrations/mqtt#frigatecamera_namedetectstate>
Topic with current state of detection for a camera. Published values are
ON and OFF.
frigate/<camera_name>/recordings/set#
<https://docs.frigate.video/integrations/mqtt#frigatecamera_namerecordingsset>
Topic to turn recordings for a camera on and off. Expected values are ON
and OFF.
—
Reply to this email directly, view it on GitHub
<#1911 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKZQ3VHUJ4KWD46LUFLTO53VF3YBHANCNFSM5FL4U7WA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
+1 |
I see that the new 11.0 beta has included switches to enable/disable motion detection on a per camera basis. When detection, motion, and recording are turned off for a particular camera is the ffmpeg process for that camera terminated? |
No, video will still be decoded and it will still be viewable in frigate / HA. This will come as a separate action in a future release |
OK, thx! |
In case anyone is interested, thought I would share a simple workaround that I am currently using to get around this issue. Just to reiterate, I am running HA on a Celeron processor with 4 cameras and object detection at 1920x1080, 3FPS (my cameras do not support substreams). This takes a significant amount of CPU resources, so sometimes I want to disable 2 of the cameras while other times I want all 4 cameras active (when I am away, for example). Workaround:
|
+1, the abilitity to enable/disable cameras is hugely useful (it is very common for several cameras to be used only at night or when away). Even better: ideally, frigate could automatically switch off its input sources when not used. Each camera can have multiple inputs for different roles ( |
Building on the workaround of @tbrausch for disabling cameras, instead of completely removing a camera from the confg, it's possible to give it a "dummy" input like the one below. With this config, ffmpeg takes ~1% CPU on my rpi4, and of course consumes no bandwidth. The advantage is that the camera is still visible in the UI, we can browse events/recordings, etc.
|
Great idea - can you upload your black.mp4 file and I will give it a try? |
Sure: https://user-images.githubusercontent.com/362089/178692766-3a394ad7-e027-48cb-b2c3-1c6d7be2370e.mp4 (It was created with |
Brilliant chatziko. With my 4 cameras the "black" yml version runs @ 1.8% while running during the day |
Nice! You can also try this version, I remember I made some change that made it faster to decode (although 1.8% seems already pretty optimal)
|
I really liked the idea of replacing the config and getting rid of the cameras. Nevertheless I am running Home Assistant on VirtualBox VDI and Frigate via docker-compose on the host. What I end up doing was the following:
On Host#!/usr/bin/python3
import paho.mqtt.client as mqtt
import shutil
HOST = "192.168.X.X"
USER = "frigate_swapper"
PASSWORD = "ABC"
CLIENT = "FrigateSwapper"
PORT = 1883
TOPIC = "frigate/swapper/config"
TARGET_CONFIG = "config.yaml"
config = {
"2" : "two-cameras.yaml",
"4" : "all-cameras.yaml"
}
def on_message(client, userdata, message):
payload = str(message.payload.decode("utf-8"))
print("Payload %s received" % payload)
if payload in config:
shutil.copyfile(config[payload], TARGET_CONFIG)
else:
print("config %s not found for frigate" % payload)
client = mqtt.Client(CLIENT)
client.on_message=on_message
print("connecting to Home Assistant MQTT Broker")
client.username_pw_set(USER, PASSWORD)
client.connect(HOST, PORT)
client.on_message=on_message
print("subscribing to topic %s" % TOPIC)
client.subscribe(TOPIC)
client.loop_forever() On Home Assistantalias: Frigate - Enable Only Day Cameras
trigger:
- platform: time
at: "07:00:00"
condition: []
action:
- service: mqtt.publish
data:
topic: frigate/swapper/config
payload: "2"
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: mqtt.publish
data:
topic: frigate/restart
mode: single |
Hello together, It works like a charm....but I still have some little problems:
See the pictures to better unsderstand what I mean: Frigate's birdseye Does anybody have the same problems? |
The filler video will be to be cropped to fit the same aspect ratio as your actual camera |
@NickM-27 FYI the "Describe the solution you'd like" in this issue is really quite different from #4897. I think it's worth mentioning that the issue you just closed as a duplicate is specifically about turning on/off camera logs by plugging/unplugging them. Not through external software such as HA as discussed in this issue. |
the change needs to be made in frigate because frigate still expects the stream to exist and not everyone uses go2rtc for every stream. |
This has been long in the wants for lots of people. Would it be too much dev/design work to simply enable/disable cameras either on a schedule or on demand (or both)? All of the workarounds (the most effective being the automation that swaps out config files) have the disadvantage of also eliminating the disabled cameras from the UI (event watching, etc.). Can someone in the dev arena actually give some feedback as to the progress of this? Some of us are regular donors and would like some feedback on the feasibility of this long standing and basic request. |
This is not a basic request. it is a difficult challenge to implement this feature given the many edge cases of different user configurations, some of the reasons were outlined in #6744 (comment) and the subsequent conversation. There are other changes we have planned that will make implementing this easier, but those changes need to come first |
Hello, there is a simple solution which consists of using a connected plug to turn off the camera when you are at home. No use of wifi bandwidth and power saving. |
I too need this feature, to be able to enable/disable the camera via mqtt api. I already disable the cameras detection, motion, etc via mqtt api and now also disable power to the cams via Poe switch. As stated earlier the current issue are the error messages and also when power is restored to the cameras, frigate does not always recover the streams without a restart. Just wanted to express my interest in this request. |
I'm trying to replicate such configuration in version 0.13.2-6476f8a, but I got these errors (repeated every 10 seconds):
Here the complete config:
|
Just stumbled upon the same use case - frigate eats a lot of resources when a camera is not needed, but there's no way to turn it off. |
Any news on this? Maybe for Frigate 0.14? |
Frigate 0.14 is already in beta, maybe 0.15 but it's hard to say at this point |
In Frigate 0.14 there is a mention of enable\disable each camera, but it can't be done without restarting Frigate addon, as it is done for detection and recording. Maybe there is another way to turn off camera without restarting? |
if there was, this would be closed |
is there another way than edit the yaml file and set |
I automatically switch camera's on/off based on people present and night/day time. Filling up the logs and burning needles energy. A suggestion: could you initiate a retry via a MQTT message for each camera, additional to the retry-interval? That allows for a (very) long retry-interval and still a fast wake-up. Additionally: consider to provide the state (online/offline/...) of each camera via MQTT. |
@halsafar could you please share your python script 😊? |
Hey @miketyson666 - A few steps to make this work. This also assumes you have Frigate working with MQTT. If you do not have Frigate connected to an MQTT server then you can manually reboot it using a shell script. In Home Assistant
In Home Assistant
Here is the python script itself
Restart/Reload Home Assistant. Now in a Home Assistant Automation you can do something like this: Finally you need to reboot Frigate which can be done via MQTT: Good luck! |
thanks @halsafar , it seems working great :-) |
|
Would this work if I have Frigate and HA on a separate LXC container in Proxmox? |
Hey @kevzz01 - In my setup I have Frigate and HA in separate Docker containers. The only requirement is that the HA script can read/write the Frigate config.yaml file. This can be achieved in several ways (mount inside HA for example). I then use MQTT (mosquitto, another container) to manage the reboot (Frigate supports rebooting via MQTT). So you should be able to achieve similar in Proxmox as long as HA can access the Frigate config.yaml file. |
My dockerized frigate runs on a different physical host machine. I have a homelab setup with multiple servers, each running several dozen docker containers. It's not a too uncommon setup. Putting HA and frigate on the same host or remote mounting folders (and bind mount them into containers) for this "dynamic" yaml workaround is not an option for me. Like many others I'm waiting as well since a long time for a proper solution implemented in frigate. It's a pity that such an essential feature wasn't foreseen in the original design. |
Yah it would be much better if Frigate offered this as a core feature. I really think MQTT enable/disable cameras is the way to go. |
Now I also came up with this use case that I wanted to use an old webcam just temporarily for the time we are away. I know about enabling/disabling via config file but really expected that it's also already available via MQTT. So I support this Idea! |
+1 for this |
Still waiting for this feature! |
+1 for this I also have - especially indoor - cameras, which are only on while I'm away and otherwise they are POE switched-off and I want to get rid of all the error-messages. As frigate and HA are running on different machines in my setup I combined the workarounds from @kevzz01 and @samgundel On the frigate-host I created a
This script also handles the restart of frigate, IF necessary. I made this script executable and added to the crontab of user In HA, when I'm away, I execute first the POE switch-on, wait a minute to let the camera become available and then execute the following action:
(it is also possible to modify several cameras with one action, just add each camera to the payload, separated by a blank space, e.g. When I return I execute first the action below and then the POE switch-off:
|
+10 for a switch in frigate to be able to disable / enable a camera dynamicaly |
Describe what you are trying to accomplish and why in non technical terms
I want to be able to dynamically enable/disable cameras defined in the config.yml so that I can ensure no data is flowing from camera to the frigate container when not in use. Right now when the switch to stop recording is turned off, the camera/ffmpeg/rtsp process still keeps gathering video data and continues to drop files into /tmp/cache. (Assume snapshot and detect is also off)
I want to be able to ensure no data is flowing between camera and frigate container when I don't need the camera to capture anything. The use case here is I don't want cameras doing anything when I'm home in the house. My cameras are wireless enabled and use power/wireless bandwidth. It becomes quite a bandwidth hog having multiple in the house to simply throw all that data away. The switch to turn them on then becomes important to turn on the camera with recordings when I'm away from the house (triggered by HA via security alarm.)
Describe the solution you'd like
I would like another frigate HA switch service call to be available per camera that will completely disable/enable the camera and stop/start the ffmpeg process when not needed in the container.
Describe alternatives you've considered
From another NVR type of solution (Zoneminder) I've used, the idea of starting/stopping ffmpeg is a part of the profile and callable to disable said cameras. (That's my alternative) :)
From a frigate standpoint already tried stopping recording switch to learn what I summarized above.
Additional context
None.
The text was updated successfully, but these errors were encountered: