PTZ Reolink cameras : HOW-TO use features that aren't available in home automation solutions (like privacy masks, detection zones,..)

hi all,

For those which have PTZ cameras and use presets, you know it’s boring to set another privacy mask or detection zone of an another preset. You lose the previous one parameter and set another one. here a method to set privacy masks or detection zones depend on the preset (without losing the others)

It’s based on a bash script (from jasonk’s bash script) which it’s an awesome script.
To find how to do this, go to my github webpage to have details.

EDIT : !! IMPORTANT !! These scripts work with standalone cameras (not tested on NVR or binocular cameras) . Let me a issue on my github webpage if it won’t work for you.

Regards
EDIT : To use these scripts in HA, use shell_command and this bash script to do this.

1 Like

I’m trying to make an automation to change the detection mask at sunrise and sunset.
But I was getting the error:

2023-07-18 07:42:27.043 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `./reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_dia)`, return code: 1
NoneType: None

So I raised the debug level:

2023-07-18 09:02:11.873 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `./reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_dia)`, return code: 1:
b'SetAlarmArea ERROR: please login first (-6)\nLogout ERROR: please login first (-6)\n'
2023-07-18 09:02:11.874 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `./reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_dia)`, return code: 1
NoneType: None
2023-07-18 09:10:11.332 DEBUG (MainThread) [homeassistant.components.shell_command] Stdout of command: `./reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_dia)`, return code: 0:
b'{\n  "rspCode": 200\n}\n'

Any way to change the command to get around this?
One way would be to send the command 2 or 3 times with an interval of about 40 seconds and hide the errors from the log, but if there is a cleaner way it would be better

reolink_save_detectionzoneai_dia: './reolink/rl-e1 GetAiAlarm "{\"channel\":0,\"ai_type\":\"people\"}" | jq "{channel:.[].channel,md:.[].scope,people:.[].scope,vehicle:.[].scope}" -c > ./reolink/detectionzoneAI_dia'
reolink_save_detectionzoneai_noite: './reolink/rl-e1 GetAiAlarm "{\"channel\":0,\"ai_type\":\"people\"}" | jq "{channel:.[].channel,md:.[].scope,people:.[].scope,vehicle:.[].scope}" -c > ./reolink/detectionzoneAI_noite'
reolink_set_mask_dia: './reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_dia)'
reolink_set_mask_noite: './reolink/rl-e1 SetAlarmArea $(cat ./reolink/detectionzoneAI_noite)'


Hi @walberjunior, for which camera do you have this error?

thanks for the reply.
Its a reolink E1 Outdoor

Animal detection is active for this cam?
Also, instead of this error, are these command doing the job and it change for what you want? It’s concern the detection zone not the privacy mask?

It has no animal detection.

If the error occurs, the change is not applied. I have to send the command again. Then on the second try I don’t get any errors and the change is applied.

That’s it, detection zone. I don’t use the privacy mask, but I can test it if you want.