motionctrl
motionctrl is a RESTful API written in Golang that acts as a controller/proxy for motion (with some sweet additional feature). It also can help you to build an IP camera and control it from any other third-part application.
Why motionctrl?
motionctlr allows you to:
- start/stop motion through an easy REST api service
- provide only one point to access both stream and webcontrol
- improve motion security with HTTPS (TODO)
- managing motion with JSON REST api that replace the old text webcontrol interface integrated in motion
- backup old image/video in Google Drive* (archive & encryption support)
- notify event through Telegram* to every device you want
*: more backup and notify services could be implemented easily, take a look inside backup/ notify/ folders!
Download
Download instruction
Configuration
In order to execute motionctrl you need a valid JSON configuration file, an example of it could be:
{
"address" : "127.0.0.1",
"port" : 8888,
"motionConfigFile" : "/home/andreacioni/motion/motion.conf",
"username" : "user",
"password" : "pass",
"ssl" : {
"key" : "/path/to/key.key",
"cert" : "/path/to/cert.pem"
},
"backup" : {
"when" : "@every 1m",
"method" : "google",
"encryptionKey" : "super_secret_key",
"archive":true,
"filePerArchive" : 10
},
}
Launch
Launch instruction
Available API
List of all available API and their description. Return value is always a JSON containing different values for each command (see table).
Path |
Description |
Parameter |
Return |
Status Codes |
/control/startup[?detection=(true|false)] |
Launch motion |
detection parameter should be used to start motion with motion detection enabled at startup (default=false) |
JSON object |
200: motion started 500: there was an error on starting up motion |
/control/shutdown |
Shutdown motion |
no parameters |
JSON object |
200: motion stopped 500: there was an error on stopping motion |
/control/restart |
Restart motion |
no parameters |
JSON object |
200: motion restarted 500: there was an error on restarting motion |
/control/status |
Report if motion is curretly running |
no parameters |
motionStarted(bool): true if motion is running |
200: always |
/detection/start |
Enable motion detection |
no parameters |
JSON object |
200: motion detection enabled 500: there was an error on enabling motion detection 409: motion is not started |
/detection/stop |
Disable motion detection |
no parameters |
JSON object |
200: motion detection enabled 500: there was an error on enabling motion detection 409: motion is not started |
/detection/status |
Check if motion detection is enabled |
no parameters |
motionDetectionEnabled(bool): true if motion detection is enabled |
200: if this checks succed 500: there was an error on checking motion detection enabled 409: motion is not started |
/config/list |
List current motion configuration |
no parameters |
JSON object which attributes contain all motion configuration parameters |
200: configuration obtained without errors 500: there was an error on retrieving motion configuraition 409: motion is not started |
/config/get?query=<param> |
Get a specific configuration |
query parameter indicates requested configuration parameter |
JSON object with only one attribute which name is <param> |
200: configuration obtained without errors 400: 'query' parameter is not specified 500: there was an error on retrieving motion configuraition 409: motion is not started |
/config/set?<name>=<value>[&writeback=(true|false)] |
Set a specific configuration |
name parameter indicates the configuration parameter to update writeback(bool): 'true' indicates that configuration will be written to file (default=false) |
JSON object with only one attribute which name is <param> |
200: configuration set without errors 400: 'writeback' parameter has an invalid value, allowed: 'true' or 'false' 403: attempting to write read-only configuration parameters 500: there was an error on setting motion configuraition 409: motion is not started |
/config/write |
Write current configuration to file |
name parameter indicates the configuration parameter to update writeback(bool): 'true' indicates that configuration will be written to file (default=false) |
JSON object with only one attribute which name is <param> |
200: configuration set without errors 500: there was an error on writing motion configuration to file 409: motion is not started |
When call fail (HTTP status code != 200), returned JSON object has only a message field containing an additional description of the error.
FAQ