Loading...
 
Power ยป  RED-PSU

RED-PSU: Using the API

Overview

The RED-PSU and RED-PSU PRO use a RESTful JSON (JavaScript Object Notation) based API which is also incorporated in its own web interface for configuration and control. A copy of the API in YAML form can be download from the link below:-
Download YAML file

An example C# API class has been written and published on Github. It is free to download, but comes with no support or warranty,
Github RedPSU API example

Best Practices

  • Do not keep the HTTP port open. When making a request, simply send the API command, wait for the response and then close the connection. There is no guarantee that the HTTP connection that you initially establish will always remain open.
  • The API is restful based, this means that you have to periodically request information from the RED-PSU and compare the previous and latest responses to see what has changed. Be careful not to continuously send API requests as they consume resources on the RED-PSU.

API

There are five main areas which you can interact with on the RED-PSU:-

  • System - Configure/Retrieve information such as name, description, location, the requirement for password access, startup delay and channel interval.
  • PSUs - Check the condition of the PSUs, for example, if they are both still operational (dual version), temperatures, fan speed and currents.
  • Users - Manage user account access.
  • Outputs - Configure/Retrieve output names, currents and turn each one On and Off independently.
  • Network - Manage the network settings.


By default, you must first authenticate with the RED-PSU. This can be disabled in the System Settings if you require. Once connected, you can simply interact with the RED-PSU using JSON.

The Base URL is http://<IPADDRESS>/api where <IPADDRESS> is the IP address of the RED-PSU.

For example, in order to retrieve a JSON response showing a list of the outputs you would send http://<IPADDRESS>/api/outputs. To retrieve the system settings, use http://<IPADDRESS>/api/system etc.

Working with JSON is beyond the scope of this wiki, however, there are plenty of resources online that will help you to interact with this product.

System

Unit level information and controls.

Web Interface

RED PSU   Configuration   General RED PSU   System Operations

Variables

Read/Write

name              string
                  maxLength: 20
                  Unit name
description       string
                  maxLength: 30
                  Unit description
location          string
                  maxLength: 20
                  Unit location
requirePassword   boolean
                  True if a password is required to access the unit.
startupDelay      number
                  Delay after reset before outputs start to switch on (ms).
channelInterval   number
                  Interval between Outputs switching on (ms).

Read Only

firmwareVersion   string
                  Currently running system firmware version.

GET /system

Retrieves the firmware version, name, description, location, require password, startup delay and channel interval.

Parameters:

None

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "firmwareVersion": "string",
      "name": "string",
      "description": "string",
      "location": "string",
      "requirePassword": true,
      "startupDelay": 0,
      "channelInterval": 0
    }
  }
}

Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.


PUT /system

Updates the name, description, location, require password, startup delay or channel interval. You do not need to send all of the attributes, only those that you need to update.

Parameters:

None

Resources:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "name": "string",
      "description": "string",
      "location": "string",
      "requirePassword": true,
      "startupDelay": 0,
      "channelInterval": 0
    }
  }
}

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.
409: Conflict. Type and ID do not match the server's endpoint.


POST /system/reset

Reboot the unit or Factory Reset it

Parameters:

None

Resources:

Reboot the unit.

{
   "parameters": {
     "level": "UNIT"
   }
}

or Factory reset the unit.

{
   "parameters": {
     "level": "FACTORY"
   }
}

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.


POST /system/identify

Indentify the unit by flashing LED's

Parameters:

None

Resources:

Number of times it should flash. -1 is Forever, 0 is off

{
  "repeat": -1
}

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.



PSUs

PSU Information

Web Interface

RED PSU   Status & Control

Variables

Read Only

psuNumber            number
                     The PSU number corresponding to the physical psu on the unit.
status               string
                     Current state of the PSU.
                     Enum:
                     [ active, present, not present, invalid ]
internalTemperature  number($float)
                     Internal temperature (degrees Celsius).
ambientTemperature   number($float)
                     Ambient temperature  (degrees Celsius).
fanSpeed             number
                     Fan-speed (rpm).
mainsCurrentnumber   number($float)
                     Input current (amps).
outputCurrent        number($float)
                     Output current (amps).

GET /psus

Gets the information about the two PSU's (if applicable)

Parameters:

None

Resources:

None

Response:

{
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "psuNumber": 0,
        "status": "active",
        "internalTemperature": 0,
        "ambientTemperature": 0,
        "fanSpeed": 0,
        "mainsCurrent": 0,
        "outputCurrent": 0
      }
    }
  ]
}

For Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.


GET /psus/{id}

Gets the information about an individual PSU

Parameters:

id = Id of the PSU

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "psuNumber": 0,
      "status": "active",
      "internalTemperature": 0,
      "ambientTemperature": 0,
      "fanSpeed": 0,
      "mainsCurrent": 0,
      "outputCurrent": 0
    }
  }
}

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.
404: Document not found.



Users

Set up and read user information.

Web Interface

RED PSU   Configuration   User Accounts

Variables

Read/Write

username       string
               maxLength: 18
               Unique username

Write Only

password       string
               Password

GET /users

Get all User accounts. NOTE: Passwords are protected and can not be accessed.

Parameters:

None

Resources:

None

Response:

{
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "username": "string"
      }
    }
  ]
}

Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.


POST /users

Add a new User account

Parameters:

None

Resources:

{
  "data": {
    "type": "string",
    "attributes": {
      "username": "string",
      "password": "string"
    }
  }
}

Response:

None

Status Code

201: Resource Created.
401: Unauthorised. Invalid or no credentials provided.
403: Forbidden. Request refused as maximum number of users have been defined
409: Conflict. Type and ID do not match the server's endpoint or user name already exists.


GET /users/{id}

Get a single User account.

Parameters:

id = Id of User

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "username": "string"
    }
  }
}

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.
404: Document not found.


PUT /users/{id}

Update a single User account.

Parameters:

id = Id of User

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "password": "string"
    }
  }
}

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.
403: Forbidden. Request refused as maximum number of users have been defined
409: Conflict. Type and ID do not match the User.


DELETE /users/{id}

Delete a single User account.

Parameters:

id = Id of User

Resources:

None

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.
403: Forbidden. Request refused as maximum number of users have been defined
409: Conflict. Type and ID do not match the server's endpoint.


GET /users/me

A special case to get the user information for the authenticated user.

Parameters:

id = Id of User

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "username": "string"
    }
  }
}

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.
404: Document not found.



Outputs

Output status and control.

Web Interface

RED PSU   Status & Control

Variables

Read/Write

name           string
               maxLength:     20
               Human readable label corresponding to the output port.

Read Only

outputNumber   number
               The output number corresponding to the physical output on the unit.
current        number($float)
               Output current (amps).
power          number($float)
               Output power (watts).
status         string
               Current Output status.
               Enum:
               [ on, off, fault ]

Write Only

status         string
               Set the requested Output status.
               Enum:
               [ ON, OFF ]

GET /outputs

Get all Outputs

Parameters:

None

Resources:

None

Response:

{
  "data": [
    {
      "id": "string",
      "type": "string",
      "attributes": {
        "outputNumber": 0,
        "current": 0,
        "power": 0,
        "status": "on",
        "name": "string"
      }
    }
  ]
}

Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.


GET /outputs/{id}

Get a single Output.

Parameters:

id = Id of Output (Physical port number)

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "outputNumber": 0,
      "current": 0,
      "power": 0,
      "status": "on",
      "name": "string"
    }
  }
}

Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.
404: Document not found.


PUT /outputs/{id}

Update an Output.

Parameters:

id = Id of Output (Physical port number)

Resources:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "status": "ON",
      "name": "string"
    }
  }
}

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.
403: Forbidden. Request refused as maximum number of users have been defined
409: Conflict. Type and ID do not match the Output.



Network

Network Settings

Web Interface

RED PSU   Configuration   Network Settings

Variables

Read/Write

ipAddress      string
               IP Address
ipNetmask      string
               Netmask IP
ipGateway      string
               Gateway IP
useDhcp        boolean
               Use DHCP

Read Only

macAddress     string
               Network interface MAC address


GET /network

Get the network configuration

Parameters:

None

Resources:

None

Response:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "macAddress": "string",
      "ipAddress": "string",
      "ipNetmask": "string",
      "ipGateway": "string",
      "useDhcp": true
    }
  }
}

Example:

[+] Show/Hide Example

Status Code

200: OK
401: Unauthorised. Invalid or no credentials provided.


PUT /network

Update the network configuration

Parameters:

None

Resources:

{
  "data": {
    "id": "string",
    "type": "string",
    "attributes": {
      "ipAddress": "string",
      "ipNetmask": "string",
      "ipGateway": "string",
      "useDhcp": true
    }
  }
}

Response:

None

Status Code

204: Successful Operation (No Content).
401: Unauthorised. Invalid or no credentials provided.
409: Conflict. Type and ID do not match the Network Settings.



Page last modified on Wednesday February 21, 2024 12:40:16 GMT-0000