Digital Loggers

Only the WiFi capable, Atheros-based power controllers support the REST API.

Download the RestAPI reference here.

These examples are using cURL. Not all curl versions authenticate properly, such as the version that comes with Windows.
This version of curl is tested and works well.

To use the REST API, enable the "Allow REST-style API" on the External APIs page of the power controller

REST API Power Switch Control Examples

Look at the API - level 1
curl -u admin:1234 -H "Range: dli-depth=1" -H "Accept: application/json" --digest ""

Outlet/relay control examples. Relays are zero based (0-7).

Switch relay 3 on. (true=on   false=off)
curl -X PUT -H "X-CSRF: x" --data "value=true" --digest "admin:1234@" .

Turn all relays on.
curl -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" --digest ";/state/"

Turn relays 1 and 5 on.
curl -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" --digest ",4/state/"

Get the status of relay/outlet 1
curl -k -u admin:1234 -H "Accept:application/json" --digest

Get the status of all relays
curl -k -u admin:1234 -H "Accept:application/json" --digest;/state/

Running scripts

Run a script (flash_a_light)
curl -u admin:1234 --digest -H "X-CSRF: x" -H "Accept: application/json"  --data "[{\"user_function\":\"flash_a_light\"}]"

Run a script passing arguments (cycle_an_outlet(outlet number, interval)) and HTTPS
curl -k -u admin:4321 -H "X-CSRF: x" -H "Content-Type: application/json" --digest --data-binary "[{\"user_function\":\"cycle_an_outlet\",\"source\":\"cycle_an_outlet(5,10)\"}]" ""

Show the running threads (scripts)
curl -u admin:1234 -X GET -H "Accept: application/json" --digest

Stop a running thread (by Thread ID)
-u admin:1234 --digest -H "X-CSRF: x" -H "Accept: application/json" -H "Content-Type: application/json" --data "[\"20\"]"

Stop all running threads (scripts)
curl -u admin:1234 --digest -H "X-CSRF: x" -H "Content-Type: application/json" --data "[\"all\"]"

Getting info from meters (when equipped). Buses and sensors are zero indexed.

Get the EPCR Bus 2 Voltage (zero indexed)
curl -u admin:1234 -H "Accept:application/json"

Get the EPCR Bus 1 (zero indexed) Current. This will be a small number if zero (e.g. 1.4e-45), so you'll need to round it.
curl -u admin:1234 -H "Accept:application/json"

Get the EPCR Bus 1 Total Energy Useage in Joules. (1 kWh = Joules * 0.00000027778)
curl -u admin:1234 -H "Accept:application/json"

EPCR internal temperature (degrees kelvin)   Celsius=kelvin - 273.16   Farenheight=9 / 5 * (kelvin - 273.16) + 32
curl -u admin:1234 -H "Accept:application/json"

EPCR/DIN4 sensor temperature (degrees kelvin)
curl -u admin:1234 -H "Accept:application/json"

EPCR/DIN4 sensor humidity
curl -u admin:1234 -H "Accept:application/json"

Have a smart way to use your power switch?  We'll acknowledge your contribution. Learn more about scripting here or AutoPing here.