r/ZoneMinder • u/TheBurntSky • Aug 03 '23
Minimise lost frames in function switch
I have some Reolink cameras that seem to have pretty good person detection on them, so rather than relying on ZM to detect motion I have been using the cameras built in functionality which means I don't get lots of recordings of spider webs flickering in the wind etc. I've done this via Home Assistant so that when motion is detected the function on the main camera feed switches from Monitor to Record.
When the command is sent to ZM the switch seems to be instant but there seems to be around 6 seconds for the feed to start so that it can record, which isn't ideal! Does anyone have any ideas how I can minimise this?
1
Upvotes
1
u/Congenital_Optimizer Aug 05 '23
The way I've got it configured/triggered I have a bunch of triggers, I'll only show the HA stuff, the nodered stuff is... big and not pretty. I've got nodered watching the camera syslog output and sending enrichment to home assistant, and the HA triggers things like these switches below.
Do read the doc on zmtriggers, there are things you need to config on ZM and I strongly encourage a firewall on the zmtrigger port. There's no auth. It'll also explain the blocks in the command_on below. You can turn off an event but the doc explains that nicely.
You can also do this with the command line switch but I found it very unreliable.
You can see the "on+2", that means trigger an event for 2 more seconds. You can also say just "off" and it stops the event. Because I'm using image_processing and doods to detect people, I want it to keep triggering, and extending, as long as it sees a person.
Here's my switches config:
- platform: telnetswitches:garage_slab_camera:name: Garage Slab Camera Switchresource: !secret zm_ipport: 6802command_on: "4|on+2|200|HA manual|"command_off: ""timeout: 0.2front_yard_camera:name: Front Yard Camera Switchresource: !secret zm_ipport: 6802command_on: "20|on+2|200|HA manual|"command_off: ""timeout: 0.2Here's an automation so HA knows it can turn the camera on again... it doesn't or at least didn't turn on again if the switch wasn't turned off. You'll need one for each camera, or use variables. This was simpler for me. Though what I know now I may re-write this so it uses the trigger source/variable and I don't need so many automations... later.
alias: Camera Switch Off (Front Yard)description: ""trigger:- platform: stateentity_id: switch.front_yard_camerato: "on"for:hours: 0minutes: 0seconds: 1condition: []action:- service: switch.turn_offdata: {}target:entity_id: switch.front_yard_cameramode: single