Skip to content

Latest commit

 

History

History
292 lines (260 loc) · 3.77 KB

README.md

File metadata and controls

292 lines (260 loc) · 3.77 KB

SET-Server

Admin

Get All Users:

GET /admin/user
Sample Response:

[
{
  "userID": "00000000-0000-0000-0000-0000000000000",
  "username": "test",
  "hash": "0uathu049ighn3thpukrkucg039yhintuich.09ig0.8"
},
...
]

requires Admin token

Delete User:

DELETE /admin/user
Sample Request:

{
  "userID": "1234"
}

requires admin token

Set an admin script:

POST /admin/script
Sample Request:

{
  "scriptName": "default",
  "script": "if(light > 2)then end"
}

scriptName is optional
requires admin token

User

Create User:

POST /create
Sample Request:

{
  "username": "Test",
  "password": "test"
}

returns token

Get User Token:

POST /token
Sample Request:

{
  "username": "Test",
  "password": "test"
}

returns token for existing user

Devices

Register a new device:

POST /device/(deviceID)
Sample Request:

{
  "deviceName": "Living room alarm"
}

requires User Token

Rename a device

PUT /device/(deviceID)
Sample Request:

{
  "deviceName": "This is actually not the living room"
}

requires token

Delete device:

DELETE /device/(deviceID)
Requires User Token

Get user devices:

GET /device
Sample Response:

[
  {
    "deviceID": "deviceid",
    "deviceName": "deviceName"
  }
]

Requires User Token

Device Types

0 - temperature
1 - humidity
2 - light
3 - noise

Send Sensor Data:

POST /sensors/(sensorType)/(deviceID)
Sample Request:

{
  "value": 20.0
}

Get Sensor Data:

GET /sensors/(sensorType)/(deviceID)
Sample Response:

[
  {
    "id": 0,
    "value": 0,
    "timestamp": 0
  }
]

Motion Detected:

POST /sensor/motion/:deviceID

Scripts

Set a user's script:

POST /script
Sample Request:

{
  "scriptName": "default",
  "script": "if(temperature < 20 & noise > 400) then kettle; end"
}

scriptName is optional requires user token

Get a user's script:

GET /script
Sample Response:

{
  "script": "if(temperature < 20 & noise > 400) then kettle; end"
}

Remove a user's script:

DELETE /script
returns OK
requires user token

Actuators

Kettle

POST /actuator/kettle
Sample request:

{
  "on": true
}

returns OK

Lights

POST /actuator/lights
Sample request:

{
  "isWhite": false,
  "hue": 255,
  "brightness": 255
}

returns OK
requires Token

Plug

POST /actuator/plug
Sample request:

{
  "on": true
}

returns OK
requires token

Alarm

POST /actuator/alarm
Sample Request:

{
  "on": true
}

Signaling a photon

GET /flashPhoton/:deviceID
returns 200

Ideal Temp

Set Ideal temp

POST /idealTemp
Sample Request:

{
  "temp": 20
}

Get Ideal temp

GET /idealTemp Sample Response:

{
  "temp": 20
}

Zones

Create zone

POST /zone
Sample Request:

{
  "zoneName": "Zone 1"
}

Delete zone

DELETE /zone
Sample Request:

{
  "zoneName": "Zone 1"
}

Get zones

GET /zone
Sample response:

[
{
  "id": "0",
  "userID": "00000000-0000-0000-0000-0000000000000",
  "name": "Zone 1"
},
...
]

Bridges

WebSocket

Bridge WebSocket ws://<ip>/bridgeWS

SETLang

Example

if(temperature > 10 & humidity > 10 & light > 10 & noise > 10) then
  email;
  text;
  notification;
  kettle;
  lights on;
  lightSetting true, 200, 20;
end

lights command has parameters:

  • on
  • off

lightSetting command has parameters:

  • isWhite: true, false
  • hue: Color as a hue value between 0 and 255
  • brightness: brightness as a value between 0 and 20