Device API
Apikey authentication
If you want to call any of the following actions when your not logged in you have this options to authenticate with the API key:
- Append on the URL of your request: &apikey=APIKEY
- Use POST parameter: "apikey=APIKEY"
- Add the HTTP header: "Authorization: Bearer APIKEY"
Read only:
Read & Write:
Devicekey authentication
Using a device key will only allow sending data for the Node of that device, giving a greater level of security.
The input module can use a devicekey instead of an apikey. If you want to authenticate as a device, just replace apikey=APIKEY with devicekey=DEVICEKEY:
- Append on the input URL of your request: &devicekey=DEVICEKEY
- Use POST parameter while calling input: "devicekey=DEVICEKEY"
Ensure that the sent input Node matches the Node that is configured for the device on the device menu.
Available HTML URLs
| The device list view | https://emoncms.org/device/view |
| This page | https://emoncms.org/device/api |
Available JSON commands
To use the json api the request url needs to include .json
Device actions
| List devices | https://emoncms.org/device/list.json |
| Get device details | https://emoncms.org/device/get.json?id=1 |
| Add a device | https://emoncms.org/device/set.json?nodeid=Room&name=Test&description=House&type=test&dkey=DEVICEKEY |
| Delete device | https://emoncms.org/device/delete.json?id=1 |
| Update device | https://emoncms.org/device/set.json?id=1&nodeid=Room&name=Test&description=House&type=test&dkey=DEVICEKEY |
| Generate a random device key | https://emoncms.org/device/generatekey.json |
| Set a new random device key | https://emoncms.org/device/setNewDeviceKey.json?id=1 |
| Initialize device | https://emoncms.org/device/init.json?id=1 |
Device MQTT authentication
| Request authentication | https://emoncms.org/device/auth/request.json |
| Check authentication request | https://emoncms.org/device/auth/check.json |
| Allow authentication request | https://emoncms.org/device/auth/allow.json?ip=127.0.0.1 |
Template actions
| List template metadata | https://emoncms.org/device/template/listshort.json |
| List templates | https://emoncms.org/device/template/list.json |
| Reload templates | https://emoncms.org/device/template/reload.json |
| Get template details | https://emoncms.org/device/template/get.json?type=example |
| Prepare device initialization | https://emoncms.org/device/template/prepare.json?id=1 |
Devices templates documentation
Template files are located at '\Modules\device\data\*.json'
Each file defines a device type and provides the default inputs and feeds configurations for that device.
A device should only need to be initialized once on instalation. Initiating a device twice will duplicate its default inputs and feeds.