roleoroleo / sonoff-hack

Custom firmware for Sonoff GK-200MP2B camera
GNU General Public License v3.0
200 stars 45 forks source link

Allow set preset via URL #67

Open pops106 opened 2 years ago

pops106 commented 2 years ago

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.

roleoroleo commented 2 years ago

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.

bennyboom38 commented 6 months ago

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

`

roleoroleo commented 5 months ago

Did you try it with a browser? Does it work without auth?

bennyboom38 commented 5 months ago

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

roleoroleo commented 5 months ago

{ "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 immagine

bennyboom38 commented 5 months ago

("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

roleoroleo commented 5 months ago

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

bennyboom38 commented 5 months ago

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

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

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

roleoroleo commented 5 months ago

Try double quote around the url.

github-actions[bot] commented 2 months ago

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.

BenjaminFalque commented 1 month ago

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"

Thanks a lot for your help !