QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
250 stars 41 forks source link

Wakeup call for disconnected cameras #170

Closed fsedarkalex closed 8 months ago

fsedarkalex commented 8 months ago

Regarding the in-development idle disconnect feature for battery powered cams, It would be cool to have an mqtt command that can wake up a specific camera. Just the same behavior as a push notification would trigger.

This could greatly help in home automation scenarios. Just imagine a PIR sensor or maybe even one of the cames would detect movement, and you want to get footage on all cameras. Or as in my case, I want to have a dashbaord that shows all cams when I want to get a quick security overview.

I would imagine something like

neolink/{CAMERANAME}/control/wakeup or neolink/{CAMERANAME}/control/connect

QuantumEntangledAndy commented 8 months ago

In that case send the command

neolink/query/camname/preview or any other valid mqtt query command

QuantumEntangledAndy commented 8 months ago

It will stay connected for about a minute after a command.

QuantumEntangledAndy commented 8 months ago

Might be good to put in a more formal command where you can specify the number of minutes though.

fsedarkalex commented 8 months ago

I agree, but I'd like to suggest seconds instead of minutes. In my case for example I would use like 30 seconds.

QuantumEntangledAndy commented 8 months ago

So the whole way this works is that there is a central ticket system. Any thread can take out a ticket to keep it alive. When the last ticket it closed it waits 30s then disconnects. The push notifications for example take out the ticket for 30s at a time. The commands in mqtt take out the ticket for however long it requires for them to complete their job which could be 2s to several hours.

So if I put in a command for 1min it will take out a ticket for 1min then drop the ticket. Then the central ticket system will wait 30s before it then disconnects. Every ticket has an extra +30s in it from the last ticket that is dropped.

So second resolution makes little sense because it represent the minimum time it will be alive for not the exact time. It will also add an extra final +30 when the last ticket is closed.

I think though minute resolution with a 0min option would work as it will keep it alive for the minimum 30s

QuantumEntangledAndy commented 8 months ago

Ok it is included in this build

command is /neolink/camname/control/wakeup (mins)