This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Power Module

Power Module RESTful API documentation

These examples are meant to be run on the device!
If you want to run them from a remote computer, you need to change “localhost” to the IP/hostname.
You will also need to generate an access token and use the “auth basic” method.
You may also want to use the secure protocol https://.

Generic

Base URL:

<HOSTNAME>/api/power/<version>/

Version check and device selection

See Version check and device selection

Error response

See Error Response

Source

GET /source

Returns the power sourcing capabilities of the device.

The source_* value shows the maximum power that can be consumed on this voltage rail in milliwatt.
The source_total value shows the maximum power all rails can consume together.
The efficiency_factor* can be used to calculate the power consumption including power dissipation.
e.g: Efficiency is 90% →value is 10W → calculated dissipation is 1W → total consumption is 11W

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/source

Parameters:

No body parameters

Response:

{
  "source_3v3": <mW>,
  "source_5v0": <mW>,
  "source_12v": <mW>,
  "source_total": <mW>,
  "efficiency_factor_3v3": <int(%)>,
  "efficiency_factor_5v0": <int(%)>,
  "efficiency_factor_12v": <int(%)>
}

Example

Request:

curl http://localhost/api/power/1.0/1/source

Response:

{
  "source_3v3": 17671,
  "source_5v0": 22275,
  "source_12v": 28750,
  "source_total": 28750,
  "efficiency_factor_3v3": 90,
  "efficiency_factor_5v0": 90,
  "efficiency_factor_12v": 100
}

Protection log

GET /protectionlog

Returns the internal protection table counters of the device. If an error like an over voltage event occurs the counter is increased. It can be reset by the factory reset command.

Label explanation:

opp_protection_cnt = Sum of all counters
ovp* = Over voltage protection
uvp* = Under voltage protection
pmc_temperature = Power Management Controller temperature exceeded 125°C
total_power_overload = Total power limit of the device exceeded (see /source)

Voltage limits:

3V3 rail = 3.240V - 3.440V
5V0 rail = 4.608V - 5.202V
12V rail = 11.30V - 12.77V

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/protectionlog

Parameters:

No body parameters

Response:

{
  "opp_protection_cnt": <int>,
  "ovp_cnt_3v3": <int>,
  "uvp_cnt_3v3": <int>,
  "ovp_cnt_5v0": <int>,
  "uvp_cnt_5v0": <int>,
  "ovp_cnt_12v": <int>,
  "uvp_cnt_12v": <int>,
  "ocp_cnt_3v3": <int>,
  "ocp_cnt_5v0": <int>,
  "ocp_cnt_12v": <int>,
  "pmc_temperature": <int>,
  "total_power_overload": <int>
}

Example

Request:

curl http://localhost/api/power/1.0/1/protectionlog

Response:

{
  "opp_protection_cnt": 0,
  "ovp_cnt_3v3": 0,
  "uvp_cnt_3v3": 0,
  "ovp_cnt_5v0": 0,
  "uvp_cnt_5v0": 0,
  "ovp_cnt_12v": 0,
  "uvp_cnt_12v": 0,
  "ocp_cnt_3v3": 0,
  "ocp_cnt_5v0": 0,
  "ocp_cnt_12v": 0,
  "pmc_temperature": 0,
  "total_power_overload": 0
}

Stats

GET /stats

Returns the voltage and current statistics of the device.

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/stats

Parameters:

No body parameters

Response:

{
  "voltage_3v3": <mV>,
  "voltage_5v0": <mV>,
  "voltage_12v": <mV>,
  "current_3v3": <mA>,
  "current_5v0": <mA>,
  "current_12v": <mA>,
  "limit_3v3": <mA>,
  "limit_5v0": <mA>,
  "limit_12v": <mA>
}

Example

Request:

curl http://localhost/api/power/1.0/1/stats

Response:

{
  "voltage_3v3": 3301,
  "voltage_5v0": 4936,
  "voltage_12v": 11936,
  "current_3v3": 762,
  "current_5v0": 536,
  "current_12v": 1,
  "limit_3v3": 5950,
  "limit_5v0": 4950,
  "limit_12v": 2400
}

Limits

POST /limits

Enables the watchdog timeout. The timeout is disabled after reset if the config is not saved.

“limit_3v3” must be > 1000 and < 5950 mA

“limit_5v0” must be > 1000 and < 4950 mA

“limit_12v” must be > 100 and < 2400 mA

Request:

Method: POST
URL: <HOSTNAME>/api/power/<version>/<slot>/limits

Parameters:

{
  "limit_3v3": <int>,
  "limit_5v0": <int>,
  "limit_12v": <int>
}

Response:

{
  "status": "success"
}

Example

Request:

curl http://localhost/api/power/1.0/1/limits --header "Content-Type: application/json" --request POST --data '{"limit_3v3": 5950, "limit_5v0": 4950, "limit_12v": 2400}'

Response:

{
  "status": "success"
}

Temperature

GET /temperature

Returns the temperature value of all sensors.

on_board_temp: Value from the NTC located next to the AC/DC converter

pmc_temp: Value from the PMCs internal sensor

The unit is degree Celsius.

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/temperature

Parameters:

No body parameters

Response:

{
  "on_board_temp": <float>,
  "pmc_temp": <float>
}

Example

Request:

curl http://localhost/api/power/1.0/1/temperature

Response:

{
  "on_board_temp": 40.353,
  "pmc_temp": 36.632
}

Fan

If the fan mode is changed it may take up to 10 seconds until it is applied by the firmware (to prevent fan vibrations).
fan_setting_mode and fan_current_mode can be compared to check the execution status.

GET /fan

Returns the fan statistics.

fan_forced: False means the fan is auto controlled by the firmware. True means the setting from fan_setting mode is applied.

fan_current_mode: Shows the mode currently in use (in auto and manual mode)

fan_setting_mode: Shows the mode which will be applied if fan_forced is True.

fan_*_mode values: 0, 20, 40, 60, 80, 100 (percent)

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/fan

Parameters:

No body parameters

Response:

{
  "fan_forced": <bool>,
  "fan_current_mode": <int>,
  "fan_setting_mode": <int>
}

Example

Request:

curl http://localhost/api/power/1.0/1/fan

Response:

{
  "fan_forced": false,
  "fan_current_mode": 0,
  "fan_setting_mode": 80
}

POST /fan

Changes the fan mode to the configured setting.

fan_*_mode values: 0, 20, 40, 60, 80, 100 (percent)

Request:

Method: POST
URL: <HOSTNAME>/api/power/<version>/<slot>/fan

Parameters:

{
  "fan_forced": <bool>,
  "fan_mode": <int>
}

Response:

{
  "status": "success"
}

Example

Request:

curl http://localhost/api/power/1.0/1/fan --header "Content-Type: application/json" --request POST --data '{"fan_forced": true, "fan_mode": 100}'

Response:

{
  "status": "success"
}

RPM

GET /fan/rpm

Returns the fan rounds-per-minute value.
It takes at least a second to update the value after the fan mode changed.

The typical maximum value is 5000 RPM +/- 15%.

Request:

Method: GET
URL: <HOSTNAME>/api/power/<version>/<slot>/fan/rpm

Parameters:

No body parameters

Response:

{
  "enabled": <bool>,
  "rpm": <int>
}

Example

Request:

curl http://localhost/api/power/1.0/1/fan/rpm

Response:

{
  "enabled": false,
  "rpm": 0
}

POST /fan/rpm

Changes the fan rounds-per-minute measurement status.

Request:

Method: POST
URL: <HOSTNAME>/api/power/<version>/<slot>/fan/rpm

Parameters:

{
  "measurement_enabled": <bool>
}

Response:

{
  "status": "success"
}

Example

Request:

curl http://localhost/api/power/1.0/1/fan/rpm --header "Content-Type: application/json" --request POST --data '{"measurement_enabled": true}'

Response:

{
  "status": "success"
}

1 - Power Module examples

Basic usage examples

These examples are meant to be run on the device!
If you want to run them from a remote computer, you need to change “localhost” to the IP/hostname.
You will also need to generate an access token and use the “auth basic” method.
You may also want to use the secure protocol https://.

Python examples

Get voltage, current and power

Example:

import requests

base_url = "http://localhost/api/power/1.0/"
# For tokens see http://noreya-nexus.local/nexuscontrolui/system/settings#access-token
login = ("token","")

resp = requests.get(base_url, auth=login)
if resp.status_code == requests.codes.ok:
  response = resp.json()
  for device in response['devices']:
    print("Voltage, current and power values for Power Module on slot " + str(device['slot_number']) + ":")
    resp = requests.get(base_url + str(device['slot_number']) + "/stats", auth=login)
    if resp.status_code == requests.codes.ok:
      response = resp.json()
      voltage_3v3 = round(response['voltage_3v3']/1000,3)
      voltage_5v0 = round(response['voltage_5v0']/1000,3)
      voltage_12v = round(response['voltage_12v']/1000,3)

      current_3v3 = round(response['current_3v3']/1000,3)
      current_5v0 = round(response['current_5v0']/1000,3)
      current_12v = round(response['current_12v']/1000,3)

      power_3v3 = round(voltage_3v3*current_3v3,3)
      power_5v0 = round(voltage_5v0*current_5v0,3)
      power_12v = round(voltage_12v*current_12v,3)

      print("3V3 rail voltage/current/power: " + str(voltage_3v3) + "V * " + str(current_3v3) + "A = " + str(power_3v3) + "W")
      print("5V0 rail voltage/current/power: " + str(voltage_5v0) + "V * " + str(current_5v0) + "A = " + str(power_5v0) + "W")
      print("12V rail voltage/current/power: " + str(voltage_12v) + "V * " + str(current_12v) + "A = " + str(power_12v) + "W")
    else:
      print("Error response for slot " + str(device['slot_number']))
else:
  print("Error response")

Output:

Voltage, current and power values for Power Module on slot 1:
3V3 rail voltage/current/power: 3.302V * 0.585A = 1.932W
5V0 rail voltage/current/power: 4.938V * 0.397A = 1.96W
12V rail voltage/current/power: 11.945V * 0.002A = 0.024W

Fan control

Example:

import requests
import time

base_url = "http://localhost/api/power/1.0/"
# For tokens see http://noreya-nexus.local/nexuscontrolui/system/settings#access-token
login = ("token","")

def check_fan(slot_number):
  response = requests.get(base_url + str(slot_number) + "/fan", auth=login)
  if response.status_code == requests.codes.ok:
    response = response.json()
    if response['fan_forced']:
      print("Fan is controlled by the driver")
    else:
      print("Fan is controlled by the firmware")

    print("Fan speed is: " + str(response['fan_current_mode']) + '%')
    print("Fan setting is: " + str(response['fan_setting_mode']) + '%')

    if (response['fan_current_mode'] != response['fan_setting_mode']) and response['fan_forced']:
        print ("Fan setting is going to be applied within 10 seconds")
        return True
    elif response['fan_forced']:
      print ("Fan setting applied!")
      print ("")
    return False
  else:
    raise RuntimeError("Could not get fan status")

response = requests.get(base_url, auth=("", ""))
if response.status_code == requests.codes.ok:
  response = response.json()
  for device in response['devices']:
    slot_number = device['slot_number']
    print("Fan control for Power Module on slot " + str(slot_number) + ":")

    response = requests.get(base_url + str(slot_number) + "/reset", auth=login)
    if response.status_code == requests.codes.ok:
      print("Successfully reset device")  # We do "write" requests so we need to get a defined state

    request = {"measurement_enabled": True}
    response = requests.post(base_url + str(slot_number) + "/fan/rpm", json=request, auth=login)
    if response.status_code == requests.codes.ok:
      print("Fan rpm measurement enabled")
    else:
      print("Enabling RPM measurement failed")

    check_fan(slot_number)
    print("")

    request = {"fan_forced": True, "fan_mode": 100}
    response = requests.post(base_url + str(slot_number) + "/fan", json=request, auth=login)
    if response.status_code == requests.codes.ok:
      print("Fan speed set to 100%")
      while check_fan(slot_number):  # Worst case it can take 10 seconds until the mode changes!
        time.sleep(1)
    else:
      print("Could not set fan mode")

    time.sleep(2) # It takes at least a second before the RPM value is available
    response = requests.get(base_url + str(slot_number) + "/fan/rpm", auth=login)
    if response.status_code == requests.codes.ok:
      response = response.json()
      print("Fan rounds-per-minutes: " + str(response['rpm']))
    else:
      print("Could not get fan rpm value")

    response = requests.get(base_url + str(slot_number) + "/reset", auth=login)
    if response.status_code == requests.codes.ok:
      print("Successfully reset device")

else:
  print("Error response")

Output:

Fan control for Power Module on slot 1:
Successfully reset device
Fan rpm measurement enabled
Fan is controlled by the firmware
Fan speed is: 0%
Fan setting is: 100%

Fan speed set to 100%
Fan is controlled by the driver
Fan speed is: 0%
Fan setting is: 100%
Fan setting is going to be applied within 10 seconds
Fan is controlled by the driver
Fan speed is: 0%
Fan setting is: 100%
Fan setting is going to be applied within 10 seconds
Fan is controlled by the driver
Fan speed is: 0%
Fan setting is: 100%
Fan setting is going to be applied within 10 seconds
Fan is controlled by the driver
Fan speed is: 100%
Fan setting is: 100%
Fan setting applied!

Fan rounds-per-minutes: 4500
Successfully reset device