-
Notifications
You must be signed in to change notification settings - Fork 1
API
All API calls require an API key. An API key is created with the server, and can be found via the Django admin interface at /admin. Alternatively there is also an endpoint GET /api/hub/HUB MAC Address/token Use the token by adding the Authorization header to API calls
Authorization: Token <token>
Returns a json object containing information about all deployments
Example response
[{
"id": 1,
"hub": "12:34:56:78:90:01",
"sensors": [{
"sensor": {
"id": "7",
"channels": [
{"id": "ELEC", "name": "Electricity", "units": "W"},
{"id": "BATT", "name": "Battery", "units": "%"}
]},
"cost": 0,
"location": "Electricity 1",
"nearest_thermostat": true,
"room_area": 20.0,
"room_height": 2.4
}],
"thermostats": [{
"setting": 20.0,
"time": "18:00",
"days": "all"
},{
"setting": 0.0,
"time": "22:00",
"days": "all"
}],
"boiler_manufacturer": "Worcester",
"boiler_model": "Greenstar 30SI",
"boiler_output": 30.0,
"boiler_efficiency": 89.8,
"boiler_type": "Gas",
"building_area": 100.0,
"building_height": 10.0
}]Returns the most recent sensor data for a deployment.
Example response
[
{
"id": 17,
"channels": [
{
"id": "BATT",
"value": 2.4,
"time": 1489788939385
},
{
"id": "ELEC",
"value": 97,
"time": 1489788939385
}
]
}
]Returns the sensor data for a deployment. All the following parameters are optional
- sensors - comma separated list of sensor ids, defaults to all sensors
- channels - comma separated list of channels, defaults to all non-hidden channels. Use 'all' to output all channels, including normally hidden channels like signal strength and battery
- simplify - set to false to return all data
- aggregate - period of time to aggregate data over. eg. using 1h will return the data averaged into 1 hour blocks.
- s = second
- m = minute
- h = hour
- d = day
- w = week
- start - limits to data after start date. Formatted like 2017-01-18 16:34:56
- end - limits to data before end date. Formatted like 2017-01-18 16:34:56
Example response
{
"sensors": [{
"id": 7,
"name": "Electricity 1",
"location": "Electricity 1",
"channels": [{
"id": "ELEC",
"name": "Electricity",
"units": "W",
"data": [
{"time": 1489074517920, "value": 20.000279285077713},
{"time": 1489400836395, "value": 19.999943017821185}
]
}]
}],
"annotations": [{
"id": 1,
"text": "Test",
"start": "2017-03-10 23:06:23",
"end": "2017-03-11 19:18:50",
"layer": 1,
"author": "admin",
"deployment": 1,
"created": "2017-03-13 10:41:54"
}]
}Endpoint used to upload prediction data for a deployment. No real functionality here yet, this is just a placeholder.
Method for hub to ping the server
Endpoint used to post new sensor readings to the server. Post with body formatted as form data, with the following
- hub - mac address of a hub
- sensor - id of a sensor
- channel - id of a channel, eg. TEMP
- value - sensor value