Skip to content

Latest commit

 

History

History
169 lines (123 loc) · 2.78 KB

File metadata and controls

169 lines (123 loc) · 2.78 KB

API

API Route

The API Route is available under http://<host>/api as POST Method via JSON Objects.

API Response

The API Route provides some Debug Responses

Not implemented

This Error occurs if you use an API Type which is unknown or was deprecated.

{"type":"error","message":"Not implemented"}

Invalid Request

This Error occurs if your requesting JSON Frame is wrong.

{"type":"error","message":"Invalid request"}

No JSON payload provided

This Error occurs if the Software has problems parsing your JSON Request.

{"type":"error","message":"No JSON payload provided"}

Relais

The Board comes with two Relais (max 10 A at 24 VDC) wich can be controlled via the HTTP POST API.

Set Relais State

The Relais on the Board can be toggled via the Relai Type, the Channel is the Relai (eq. Relais 1 or Relais 2).

In this Example the Relais on Channel 1 is turned on.

{
  "type": "relais",
  "channel": 1,
  "state": true
}

Switch Relais on for X Seconds.

The Relais on the Board can be turned on for a specified Time and then automatically turned off.

In this Example the Relais on Channel 1 is turned on for 1 Minute.

{
  "type": "relais",
  "channel": 1,
  "duration": 60,
  "state": true
}

Status

You can retrieve the Device Status by using the Status Type.

Sensors

{
  "type": "status"
}

This will return the current Status:

{
  "type": "success",
  "channels": [
    1,
    0
  ],
  "adc": "1.10",
  "cpu": "10.5",
  "frequency": 160
}

Restart Device

You can restart the Device via the Restart Type.

{
  "type": "restart"
}

Reset

You can reset the Device Config by using the Reset Type.

{
  "type": "reset"
}

Info

You can retrieve the Device Info by using the Info Type.

{
  "type": "info"
}

This will return the current Status:

{
  "type": "success",
  "wifi": {
    "client": {
      "ssid": "",
      "password": ""
    },
    "ap": {
      "ssid": "BYTELEVEL",
      "password": "BYTESTORE2026"
    }
  },
  "mqtt": {
    "state": false,
    "host": "",
    "port": 1883,
    "user": "",
    "password": ""
  },
  "admin": {
    "state": false,
    "user": "",
    "password": ""
  },
  "hardware": {
    "led": true
  },
  "firmware": "1.0.1"
}

API Auth

When you enable Authentification for the UI, the API will be becoming protected via the Admin Credentials.

Because this is a non-High-Security-Device, it just uses Basic Auth.

You need to replace as username:password decoded as Base64 String.

curl --location 'http://<host>/api' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <base64-encoded-password>' \
--data '{
    "type": "info"
}'