Skip to content

Web services description

roleo edited this page Jun 6, 2022 · 12 revisions

There are web services useful for many functions. The default format is JSON (or JPG for images).

Table of Contents

Snapshot

http://IP:PORT/cgi-bin/snapshot.sh?file=FILE

FILE: name of the file you want to save in /mnt/mmc/sonoff-hack/www/alarm_record/ (default returns image/jpeg)

Record

http://IP:PORT/cgi-bin/record.sh?name=NAME

Start recording of a short video: about 40 seconds starting 5 seconds in the past.

Returns the path of the file.

Privacy

http://IP:PORT/cgi-bin/privacy.sh?value=VALUE

VALUE: on, off or status Set privacy on or off, or get the status. Privacy "on" means rtsp and snapshot disabled, privacy "off" means rtsp and snapshot enabled.

Motion events management

List directories

http://IP:PORT/cgi-bin/eventsdir.sh

List of directories containing registered mp4 files.

List files

http://IP:PORT/cgi-bin/eventsfile.sh?dirname=20200101/10

List of mp4 files contained in a specific directory.

Delete directories

http://IP:PORT/cgi-bin/eventsdirdel.sh?dir=all

Remove all directories (containing registered mp4 files).

http://IP:PORT/cgi-bin/eventsdirdel.sh?dir=20200101/10

Remove directory /mnt/mmc/alarm_record/20200101/10 (directory containing registered mp4 files).

Delete file

http://IP:PORT/cgi-bin/eventsfiledel.sh?file=20200101/10/ARC20200101100320.mp4

Remove file /mnt/mmc/alarm_record/20200101/10/ARC20200101100320.mp4

Get recorded videos

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh

Use. Available variables:

"oldness" variable. Defines which video to retrieve..

  • "0" (default) or "1" means latest already available.

  • greater than "0" specifies the oldness, so "3" means the third oldest video. Only looks into the current hour folder. So if value is greater than the videos in the latest hour folder, the last one will be sent.

"type" variable. Defines what to retrieve.

  • "1" (default). Gets relative name in the format of DIR/VIDEO.mp4

  • "2". Gets full URL video.

  • "3". Gets the video itself as video/mp4 inline.

  • "4". Gets the video itself as video/mp4 attachment.

Examples of use:

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=0&type=4 -- Send the last video as an attachment.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=0&type=3 -- Show the last video inline in the browser.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?type=1 -- Send the relative route of the last available video.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=2&type=2 -- Send the URL of the second to last available video.

Configuration

Get configuration

http://IP:PORT/cgi-bin/get_configs.sh?conf=CONF

CONF action
system Get system configuration
mqtt Get mqtt configuration

Set configuration

http://IP:PORT/cgi-bin/set_configs.sh?conf=CONF

CONF action
system Update system configuration
mqtt Update mqtt configuration

Need POST mehod with a json file.

Get status info

http://IP:PORT/cgi-bin/status.json

Get hostname

http://IP:PORT/cgi-bin/hostname.js

Maintenance

Load settings from file

http://IP:PORT/cgi-bin/load.sh

Load configuration file (it requires post method).

Save settings to file

http://IP:PORT/cgi-bin/save.sh

Save configuration to a file.

Upgrade firmware

http://IP:PORT/cgi-bin/fw_upgrade.sh?get=info

Get upgrade info.

http://IP:PORT/cgi-bin/fw_upgrade.sh?get=upgrade

Start upgrade procedure.

Reboot the cam

http://IP:PORT/cgi-bin/reboot.sh

Service start and stop

http://IP:PORT/cgi-bin/service.sh?name=NAME&action=ACTION&param1=PARAM1&param2=PARAM2

name action param1 param2 description
rtsp start/stop/status N/A N/A start and stop sonoff rtspd daemon
onvif start/stop/status low/high/both N/A onvif: use param1 to set resolution
wsdd start/stop/status N/A N/A onvif web service discovery
ftpd start/stop/status busybox/pure-ftpd N/A ftpd: use param1 to set which daemon use
mqtt start/stop/status N/A N/A mqtt to send motion events to a broker
all start/stop/status N/A N/A all above services

PTZ

Move manually

http://IP:PORT/cgi-bin/ptz.sh?dir=DIRECTION

DIRECTION=left, right, up or down (required option).

Go to or set preset

http://IP:PORT/cgi-bin/preset.sh?action=ACTION&num=NUMBER&name=NAME

action num name
go_preset 0-14 N/A
set_preset 0-9 preset name