Listener¶
The 2Ring Power Tool can listen for HTTP requests on the local machine, which can run a predefined script or send a command to an Ontrak ADU device.
For more information about the listener settings, see the Listener Settings chapter.
Run script¶
Script Location¶
It is expected that script files will be placed in a subdirectory named “Scripts” relative to the directory of the currently executed file. Make sure that in the same directory as your executable (.exe) file, there is a subdirectory named “Scripts” containing your files.
Supported Scripting Languages¶
PowerShell (.ps1)
Python (.py)
Visual Basic (.vbs)
HTTP Request Example for Script Execution¶
POST http://localhost:{Your_Port}`
Body:
{
"scriptName": "{Your_Script_Name}",
"{Your_Argument_Name}": "{Your_Argument}"
}
This request demonstrates how to execute a script by providing the script name and its corresponding arguments in the URL. Adjust the placeholders ({Your_Port}, {Your_Script_Name}, {Your_Argument_Name}, and {Your_Argument}) with actual values for your use case.
HTTP Response¶
Code 200 - OK
Code 404 - Not Found
Occurs with improperly constructed query.
Code 500 - Internal Server Error
Code 504 - Gateway Timeout
Occurs when the script execution exceeds the defined timeout limit.
Ontrak ADU¶
Power Tool processes the http request and then sends a command to Ontrak ADU device via a USB port.
HTTP Request Example¶
GET http://localhost:{Your_Port}/adu?port={port}&setState={action}&interval={interval}
This request demonstrates how to control ADU device. Adjust the placeholders ({Your_Port}, {port}, {action}, and {interval}) with actual values for your use case.
Below are available parameters, that can be defined in the request:
Port¶
Port specifies the port of the interface and available values are 0, 1, 2, or 3.
On command¶
setState=On
Write to device SK {port}
Off command¶
setState=Off
Write to device RK {port}
Blink command¶
setState=Blink&interval={interval}
Write to device RPK {port} at an interval (in seconds).
HTTP Response¶
Code 200 - OK
Code 400 - Bad Request
Possible reasons: “Missing parameters”
Code 404 - Not Found
Occurs with improperly constructed query.
Code 500 - Internal Server Error