sonoff-hack
sonoff-hack copied to clipboard
Allow set preset via URL
Is there a way I can set a PTZ location preset via a curl command.
For example if one of my other cameras detects motion, front door for example I can set an automation to send a curl command to the sonoff to set it to a certain preset to watch the path down the side of the house.
You can set a preset (save it in the config file) with this syntax:
cgi-bin/preset.sh?action=set_preset&num=1&name=Path
You can go to a preset with this syntax
cgi-bin/preset.sh?action=go_preset&num=1
Check the wiki.
Thanks for the info but when I try with curl command , everything seems to work but the camera does not change his position to the preset requested. Here is the log :
command used : curl -v --user "mylogin:mypassword" http://192.168.X.XXX/cgi-bin/preset.sh?action=go_preset&num=0
` [1] 3335303
- Trying 192.168.X.XXX:80...
- Connected to 192.168.X.XXX (192.168.X.XXX) port 80 (#0)
- Server auth using Basic with user 'mylogin'
GET /cgi-bin/preset.sh?action=go_preset HTTP/1.1 Host: 192.168.X.XXX Authorization: Basic XXXXXXXXXX User-Agent: curl/7.85.0 Accept: /
- Mark bundle as not supporting multiuse
- HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-type: application/json < { "error":"true"
- Closing connection 0 }
`
Did you try it with a browser? Does it work without auth?
When I try with a browser I need to authenticate with basic auth login/password and then I get an "error" page too with :
{ "error": "false" }
But camera is well moving to the position I have asked.
I have not tried without authentication, I'm going to try to disable it and try again, is it possible to remove login password? Don't see anything in wiki that telling it's possible
{ "error": "false" }
Sorry for the misunderstanding but this output means "no errors".
You can remove the authentication in the webgui:
http://IP-CAM/?page=configurations
("Sorry for the misunderstanding but this output means "no errors"." => got it ! ) In fact the field are not filled but when I try to connect with browser I get a popup to insert login password. I have tried to put a new login/password then to empty fill and save configuration and reboot camera but nothing has changed , when I enter curl command in console a get error and camera does not move. Maybe there's something wrong with credentials :/, leave fields empty does not seem to remove authentification
Try to clear the cache of the browser.
If it doesn't work, enter with a ssh client and check the config file
sonoff-hack/etc/system.conf
My bad, I have changed the login password for MQTT instead of configuration page :-( Now i have reset login/password to blank and I can connect with my browser on admin web page without credential but when I launch the curl command I get again the error : ` curl -v http://192.168.x.xxx/cgi-bin/preset.sh?action=go_preset&num=1 [1] 3695339
- Trying 192.168.x.xxx:80...
- Connected to 192.168.x.xxx (192.168.x.xxx) port 80 (#0)
GET /cgi-bin/preset.sh?action=go_preset HTTP/1.1 Host: 192.168.x.xxx User-Agent: curl/7.85.0 Accept: /
- Mark bundle as not supporting multiuse
- HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-type: application/json < { "error":"true"
- Closing connection 0 } `
This is weird cause there's no issue when I launch curl for moving axis with ptz url like : curl -v http://192.168.x.xxx/cgi-bin/ptz.sh?dir=down
- Trying 192.168.x.xxx:80...
- Connected to 192.168.x.xxx (192.168.x.xxx) port 80 (#0)
GET /cgi-bin/ptz.sh?dir=down HTTP/1.1 Host: 192.168.x.xxx User-Agent: curl/7.85.0 Accept: /
- Mark bundle as not supporting multiuse
- HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-type: application/json < { "error":"false"
- Closing connection 0 `
Here is the /etc/system.conf
HTTPD=yes TELNETD=no SSHD=yes FTPD=no BUSYBOX_FTPD=no DISABLE_CLOUD=yes MQTT=yes SNAPSHOT=yes ONVIF=yes ONVIF_WSDD=yes ONVIF_PROFILE=both ONVIF_NETIF=ra0 NTPD=yes NTP_SERVER=pool.ntp.org RTSP_PORT=554 ONVIF_PORT=1000 HTTPD_PORT=80 USERNAME= PASSWORD= FREE_SPACE=0 FTP_UPLOAD=no FTP_HOST= FTP_DIR= FTP_DIR_TREE=no FTP_USERNAME= FTP_PASSWORD= FTP_FILE_DELETE_AFTER_UPLOAD=yes SSH_PASSWORD= TIMEZONE= SWAP_FILE=no PTZ_PRESET_BOOT=0 CRONTAB= SNAPSHOT_VIDEO=yes SYSLOGD=yes
Thanks for your help
Try double quote around the url.
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.
Hello ! I have just tried with double quote and it's working fine!
` curl -v "http://192.168.x.xxx/cgi-bin/ptz.sh?dir=right"
- processing: http://192.168.x.xxx/cgi-bin/ptz.sh?dir=right
- Trying 192.168.x.xxx:80...
- Connected to 192.168.x.xxx (192.168.x.xxx) port 80
GET /cgi-bin/ptz.sh?dir=right HTTP/1.1 Host: 192.168.x.xxx User-Agent: curl/8.2.1 Accept: /
- HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-type: application/json < { "error":"false"
- Closing connection `
Thanks a lot for your help !