-
Notifications
You must be signed in to change notification settings - Fork 25
alexstocker edited this page Jun 11, 2019
·
12 revisions
Endpoint: /apps/sensorlogger/api/v1/createlog
Add a SensorLog for a given deviceId
Params:
- deviceId (string), required
- date (string), optional server time used if not set
- humidity (float), optional
- temperatur (float), optional
If given "deviceId" does not exists, a new device with this id will be created automatically.
{
"date":"2017-03-03 12:30:47",
"deviceId":"f7645058-fe8c-11e6-bc64-92361f002671",
"humidity":34.700000762939,
"temperature":24
}
{
"success":true,
"message":"Sensor Log successfully stored",
"data":null
}
Example: post.php
Endpoint: /apps/sensorlogger/api/v1/createlog
To be able to store an extended log successfully registration of the device is required
{
"date":"2017-03-03 12:30:47",
"deviceId":"f7645058-fe8c-11e6-bc64-92361f002671",
"data" : [
{
"dataTypeId": 1,
"value": -0.3
},
{
"dataTypeId": 2,
"value": 19
},
{
"dataTypeId": 3,
"value": 795.9
}
]
}
{
"success":true,
"message": "Sensor Log successfully stored",
"data": [
{
"dataTypeId":1,
"value":-0.3
},
{
"dataTypeId":2,
"value":19
},
{
"dataTypeId":3,
"value":795.9
}
]
}
- Examples:
Endpoint: /apps/sensorlogger/api/v1/registerdevice
Params:
- deviceId(string), required
- deviceName(string), optional
- deviceType(string), optional
- deviceGroup(string), optional
- deviceParentGroup(string), optional
- deviceDataTypes(array), required
- type(string), required
- description(string), required
- unit(string), required
{
"deviceId":"231d2508-786d-400d-bc35-0273a38f664d",
"deviceName":"Multi data sensor",
"deviceType": "Indoor",
"deviceGroup": "Wohnzimmer",
"deviceParentGroup": "Wohnung",
"deviceDataTypes": [
{
"type": "temperature",
"description": "Temperature",
"unit": "°C"
},
{
"type": "humidity",
"description": "Humidity",
"unit": "% r.F."
},
{
"type": "co2",
"description": "Carbon dioxide",
"unit": "ppm"
}
]
}
{
"success":true,
"message":"Device successfully registered",
"data": [
{
"id":"1",
"description":"Temperatur",
"type":"temperature",
"short":"\u00b0C"
},
{
"id":"2",
"description":"Luftfeuchtigkeit",
"type":"humidity",
"short":"% r.F."
},
{
"id":"3",
"description":"Carbon dioxide",
"type":"CO2","short":"ppm"
}
]
}
Example:
Endpoint: /apps/sensorlogger/api/v1/getdevicedatatypes
{
"deviceId":"231d2508-786d-400d-bc35-0273a38f664d"
}
Example: getdatatypes.php
[
{
"id":"4",
"description":"Carbon monoxide",
"type":"CO",
"short":"ppm"
},{
"id":"5",
"description":"Ethanol",
"type":"C2H6OH",
"short":"ppm"
},{
"id":"6",
"description":"Hydrogen",
"type":"H2",
"short":"ppm"
},{
"id":"7",
"description":"Ammonia",
"type":
"NH3","short":"ppm"
},{
"id":"8",
"description":"Methane",
"type":"CH4",
"short":"ppm"}
]
- 9001 ... missing params
- 9002 ... device already exists
- 9404 ... not found
- 9405 ... not allowed
- 9999 ... unknown problem
{
"success":false,
"error": {
"code":9999,
"message":"Some Error message"
}
}
{
"success":false,
"error": {
"code":9404,
"message":"Device #000e643ee8-0f9f-11e7-93ae-92361f002675 not registered"
}
}