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

Toggle 'detect' status via HTTP API #8877

Open
jangrewe opened this issue Dec 6, 2023 · 13 comments
Open

Toggle 'detect' status via HTTP API #8877

jangrewe opened this issue Dec 6, 2023 · 13 comments
Labels
enhancement New feature or request pinned

Comments

@jangrewe
Copy link

jangrewe commented Dec 6, 2023

First off, THANK YOU for creating Frigate! I've been using Shinobi/Zoneminder/etc. for many years, but they've all been a very painful experience (coming from a professional Sysadmin, that means something).
I got Frigate up & running in a Docker container with TensorRT and all the bells & whistles in less than half an hour, and i never want to switch back to anything else. ♥️

Now regarding the actual feature request:

Describe what you are trying to accomplish and why in non technical terms
I want to be able to toggle the 'detect' status via the HTTP API, so that I can easily switch it on and off via my home automation. Otherwise it would record me all the time i'm moving through my flat, instead of just when i'm not at home.

I see that this is possible via the Websocket, but: that's a bit more complicated to use than a simple HTTP call.

Describe the solution you'd like
A new HTTP API endpoint like POST /api/<camera_name>/detect, similar to the Websocket, e.g. with

{"payload": "OFF"}

Describe alternatives you've considered
A very complicated cURL command to emulate a Websocket client. Not fun, and also not very reusable.

Additional context

@jangrewe jangrewe added the enhancement New feature or request label Dec 6, 2023
@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Dec 6, 2023

what home automation platform are you using? these should support mqtt which can be used for this, otherwise I believe that websocket should suffice.

@jangrewe
Copy link
Author

jangrewe commented Dec 6, 2023

Ironically ESPHome without Home Assistant. I can send simple HTTP requests from my MCUs, but implementing Websockets there would be at least a major PITA, if possible at all. Also no MQTT implemented.

I'm not great at Python and/or knowing the internals of Frigate, but when looking at frigate/http.py it doesn't look too complicated to add another endpoint to accomplish this? 😉

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Dec 6, 2023

I'm not great at Python and/or knowing the internals of Frigate, but when looking at frigate/http.py it doesn't look too complicated to add another endpoint to accomplish this? 😉

it is likely much more complicated than you may think given that there is a lot of logic to determine when a setting can be enabled / disabled and we must set it so that the change is seen across the many different processes that frigate is using.

Certainly doable but would require a considerable overhaul to ensure it is not a major amount of effort to maintain. we can see what @blakeblackshear thinks

@blakeblackshear
Copy link
Owner

What if we just leveraged the new inter_process bus and only published a message in the http api?

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Dec 7, 2023

that could be done, only concern is we wouldn't be able to send an error back to the user if it failed like in the case of recordings being disabled in config or others

@kabadisha
Copy link

I'd like to add my support for this feature. I have a bash script that runs on my router that detects if my phone is connected. If it is, I would like to disable detection so that I'm not recording myself all day.

@Eierkopp
Copy link

...so that I'm not recording myself all day.

Same here. I'm using Python aiohttp for that purpose.

    async def disable_detection(self, cam):
        async with aiohttp.ClientSession(auth=AUTH) as session:
            async with session.ws_connect(f"https://{FRIGATE_HOST}:{FRIGATE_PORT}/ws") as ws:
                await ws.send_json({"topic": f"{cam}/detect/set", "payload": "OFF", "retain": True})

@MaBeniu
Copy link

MaBeniu commented Jan 29, 2024

After getting sorted main config paramos now started to think of such feature as well. Some configurations control from HA would be perfect. Especially detection of objects. While family is at home it doesn't make sense to track people on weekends during day time. While at night it still might be relevant for case if intruders get there. So such change based on time would be easy to define in HA on top of it to combine with families presence at home. Shortly I see lots of value with this. 🙂
Changing tracked objects list from HA could be other alternative as a workaround, just a thought.

@NickM-27
Copy link
Sponsor Collaborator

Some configurations control from HA would be perfect

there is already a lot of control over the config and interactions with frigate in HA via the HA integration

@MaBeniu
Copy link

MaBeniu commented Jan 29, 2024

Accept my apology 🙏
Indeed found those, tons of options. Brilliant

@kabadisha
Copy link

I ended up working around this limitation by spending all weekend fiddling with HomeAssistant integration with Frigate and my Router. I now have an automation set up to disable detection when my router can see my phone has connected.

While I now have a more configurable, powerful automation handling this, I still think this Frigate feature request is sensible:

  • It's simpler to understand.
  • It's quicker to implement.
  • It doesn't require you to have HomeAssistant.

As such, my vote for this feature stands.

@NickM-27
Copy link
Sponsor Collaborator

To be clear, nothing about home assistant is required. Mqtt is supported by node red and other tools.

The recent changes in architecture will make this easy to implement

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 20, 2024
@NickM-27 NickM-27 added pinned and removed stale labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

6 participants