Creating Standalone Device
ENAPTER3_API_TOKEN="<your API token>" \
enapter3 device create standalone \
--device-name "My Standalone Device" \
--site-id <site_id>
On Gateway
Site id is not required if you create a Standalone Device on Gateway.
The result of creating a new Standalone Device will be a JSON object:
{
"device_id": "8d7de32e-d00c-4019-a215-db6e14b77375",
"slug": "my-standalone-device",
"config": {
"hardware_id": "SD595D4EF54C643B7988AADDBF12A2E30",
"channel_id": "s",
"mqtt_protocol": "MQTTS",
"mqtt_host": "mqtt.enapter.com",
"mqtt_port": 1883,
"mqtt_credentials": {
"private_key": "...",
"certificate": "...",
"ca_chain": "..."
}
}
}
This response is documented in the HTTP API reference.
To continue implement a device logic you need to save information from the response:
- copy the
device-idorslugvalue to any place to use later - copy
config.mqtt_host,config.mqtt_port,config.hardware_idandconfig.channel_idvalues to any place to use later; - store
config.mqtt_credentials.ca_chainintoserver-ca.crtfile (note that you need to replace\nwith actual new lines); - store
config.mqtt_credentials.certificateintoclient.crtfile (note that you need to replace\nwith actual new lines); - store
config.mqtt_credentials.private_keyintoclient.keyfile (note that you need to replace\nwith actual new lines).