-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Reolink_API_PTZ_Commands.sh
28 lines (24 loc) · 1.44 KB
/
Reolink_API_PTZ_Commands.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
## Script Reolink_API_PTZ_Commands.sh
## ./Reolink_API_PTZ_Commands.sh 'commande PTZ Reolink' 'parametre de la commande' (respecter la casse)
## 'commande PTZ Reolink' : PtzCtrl, StartZoomFocus
## 'parametre de la commande' possible : Left, Right, Up, Down, LeftUp, RightUp, LeftDown, RightDown, Stop
## Exemple : ./Reolink_API_PTZ_Commands.sh PtzCtrl Left 24
username="YourReolinkCameraUsername"
password="YourReolinkCameraPassword"
cameraIP=$1 # addresse IP de la camera
command=$2 # commande
parameter=$3 # parametre de la commande
speed=$4 # vitesse de déplacement
id=$5 # Id de position en utilisation ToPos
case $parameter in
Left|Right|Up|Down|ZoomInc|ZoomDec|FocusInc|FocusDec)
payload="[{\"cmd\":\""${command}"\",\"action\":0,\"param\":{\"channel\":0,\"op\":\""${parameter}"\",\"speed\":${speed}}}]";;
Stop)
payload="[{\"cmd\":\""${command}"\",\"action\":0,\"param\":{\"channel\":0,\"op\":\""${parameter}"\"}}]";;
ZoomPos)
payload="[{\"cmd\":\""${command}"\",\"action\":0,\"param\":{\"ZoomFocus\":{\"channel\":0,\"op\":\""${parameter}"\",\"pos\":${speed}}}}]";;
ToPos)
payload="[{\"cmd\":\""${command}"\",\"action\":0,\"param\":{\"channel\":0,\"id\":${id},\"op\":\""${parameter}"\",\"speed\":${speed}}}]";;
esac
curl -k -X POST -H "Content-Type: application/json" -d "${payload}" "http://${cameraIP}/cgi-bin/api.cgi?cmd=${command}&user=${username}&password=${password}"