Digital Loggers


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

These examples are using cURL. *Some curl versions may not authenticate properly when using digest authentication.
This version of curl is tested and works well in Windows.

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

Download the REST API Reference here or version-specific REST API reference and examples are available in help.
Click on the Help menu link on the power controller.

Then click on the on-line help icon.

REST API Power Switch Control Examples

**Only the admin user can run scripts.
Non-admin users must be granted access in the External APIs settings, but then can only toggle outlets.

*** Firmware version 1.10.x and newer, allows the creation of special clients with fine-grained token-based access priveleges.
These tokens can offer clients limited administrator privileges as well as limited outlet access.

Persistent state - The outlet state will revert to the persistent state after a power cycle or reboot.
Set persistent state: curl --digest -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" ""
Get persistent state: curl -u admin:1234 -k -H "Accept:application/json" --digest
*Getting the persistent state may not reflect the physical state, if the transient state has been set.

Transient state - Temporary outlet state. The outlet may not return to the set state, but will revert to the persistent state after a power cycle or reboot.
Set transient state: curl --digest -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" ""
Get transient state: curl -u admin:1234 -k -H "Accept:application/json" --digest
*Getting the transient state is "usually" the pysical state, but if there is a delay,  e.g. cycle(), the physical state may not have been set yet.

Physical state - Get current physical outlet state of the outlet/relay.
Physical state: curl -u admin:1234 -k -H "Accept:application/json" --digest
*The physical state cannot be set by the user. Users set the Transient state or Persistent state. The unit will change the physical state.

Note: Setting the "state" or "transient state" to "on" may not happen immediatey, as the on sequence delays and cycle delays will be honored.

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 --digest -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" ""

Turn all relays on.
curl --digest -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" ";/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 physical status of relay/outlet 3
curl -k -u admin:1234 -H "Accept:application/json" --digest

Get the physical status of all relays

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

curl -u admin:1234 -H "Accept:application/json" --digest ";/name/"
Cycle relay/outlet 1
curl -u admin:1234 -X POST -H "X-CSRF: x"  --digest ""
Change the state of several outlets as simultaneously as possible. (Requires firmware 1.10.11+)
curl --digest -u admin:1234 -H "X-CSRF: x"  -H "Content-type: application/json"  --data-binary "[[[0,false],[1,true],[2,false],[5,true],[7,true]]]" "" 


Run a script (flash_a_light)
curl -u admin:1234 --digest -H "X-CSRF: x" -H "Content-Type: 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 "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\"]"


Enable SSH
curl -u admin:1234 -X PUT -H "X-CSRF: x" --data "value=true" --digest ""

Add a user, allowing access to outlets 5, 6, 7 and 8
curl --digest -u admin:1234 -H "Content-type: application/json" -H "X-Requested-With: XMLHttpRequest" --data-binary "{\"password\":\"aPassword\",\"is_admin\":false,\"name\":\"aUsername\",\"is_allowed\":true,\"outlet_access\":[false,false,false,false,true,true,true,true]}" ""

Delete a user
curl --digest -u admin:1234 -X DELETE -H "X-Requested-With: XMLHttpRequest" ""

System. (Requires firmware or later)

curl --digest -u admin:1234 -H "X-CSRF: x" -H "Content-type: application/json"  --data-binary "[]" "

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.