Device Management
This section of the Device API describes the modifying actions that can be performed on devices.
Update Device
PATCH devices/{device_id}
Updates device information. This operation requires at least the OWNER access level.
Request
$ curl -X PATCH \
http://api.enapter.com/v3/devices/devicea0-45f2-4e9e-a6f0-69a310ab110b \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"device_name": "Hydrogen detector"
}'
Response
Updated device.
{
"device": {
"id": "devicea0-45f2-4e9e-a6f0-69a310ab110b",
"blueprint_id": "bluepri1-50n3-4t9d-e6v0-69i310cb110e",
"name": "Hydrogen detector",
"site_id": "sitebba0-79f2-4e9e-a6f0-69a310ab110b",
"updated_at": 1735689600,
"slug": "gas-detector-in-living-room",
"type": "LUA",
"authorized_role": "INSTALLER"
}
}
device.idstring#Device ID.
device.blueprint_idstring#Blueprint ID.
device.site_idstring#Site ID.
device.namestring#Device name.
device.updated_atinteger#The timestamp of the most recent update of the device’s information.
device.authorized_rolestring#The user's authorized role for the device.
device.propertiesobject#Device's properties.
device.manifestobject#Device's manfiest.
device.communication_infoobject#Device's communication info.
device.slugstring#Device's slug.
device.typestring#Device's type.
device.siteobject#Device's site info.
device.implemented_profilesarray of strings#A list of profiles implemented by the device. You can also find them in the device's manifest.
device.connectivitystring#Device's connectivity status. Can be
ONLINE,OFFLINE,UNKNOWN.
Delete Device
DELETE devices/{device_id}
Deletes device. This operation requires at least the OWNER access level.
It's not possible to delete an upstream device with running device(s). You need to delete the running device(s) first.
Request
$ curl -X DELETE
http://api.enapter.com/v3/devices/devicea0-45f2-4e9e-a6f0-69a310ab110b
Generate device configuration
POST devices/{device_id}/generate_config
Generates a new configuration for connecting to the Enapter Cloud.
It's not possible to generate a configuration for devices with communication types UCM_LUA or UCM_EMBEDDED.
Request
$ curl -X POST \
http://api.enapter.com/v3/devices/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/generate_config \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"protocol": 'MQTTS'
}'
Body parameters
protocolstring#Can be
MQTTorMQTTS.
Response
A new device configuration.
MQTTS
{
"config": {
"mqtt_host": "mqtt.enapter.com",
"mqtt_port": 8883,
"mqtt_credentials": {
"protocol": "MQTTS",
"private_key": "...",
"certificate": "...",
"ca_chain": "..."
},
"time_sync_protocol": "HTTP",
"time_sync_host": "127.0.0.1",
"time_sync_port": 80,
"hardware_id": "C8795CBA5375484E829105E959663C8B",
"channel_id": "ucm"
}
}
MQTT
{
"config": {
"mqtt_host": "mqtt.enapter.com",
"mqtt_port": 1883,
"mqtt_credentials": {
"protocol": "MQTT",
"username": "...",
"password": "..."
},
"time_sync_protocol": "HTTP",
"time_sync_host": "127.0.0.1",
"time_sync_port": 80,
"hardware_id": "C8795CBA5375484E829105E959663C8B",
"channel_id": "ucm"
}
}
config.mqtt_hoststring#Enapter Cloud MQTT broker host.
config.mqtt_postinteger#Enapter Cloud MQTT broker port.
config.mqtt_credentialsobject#Contains either MQTT or MQTTS credentials.
mqtt_credentials.protocolstring#MQTTorMQTTS.
mqtt_credentials.usernamestring#If
MQTT: Enapter Cloud MQTT broker username.
mqtt_credentials.passwordstring#If
MQTT: Enapter Cloud MQTT broker password.
mqtt_credentials.private_keystring#If
MQTTS: Enapter Cloud MQTT broker private key.
mqtt_credentials.certificatestring#If
MQTTS: Enapter Cloud MQTT broker certificate.
mqtt_credentials.ca_chainstring#If
MQTTS: Enapter Cloud MQTT broker certificate chain.
config.time_sync_protocolstring#Time synchronization protocol.
config.time_sync_hoststring#Time synchronization host.
config.time_sync_portinteger#Time synchronisation server port.
config.hardware_idstring#Device hardware ID.
config.channel_idstring#Device channel ID.
Change Blueprint
POST devices/{device_id}/assign_blueprint
Changes blueprint of a specified device.
Request
$ curl -X POST \
http://api.enapter.com/v3/devices/fecbbba0-79f2-4e9e-a6f0-69a310ab110b/assign_blueprint \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"blueprint_id": 'bluepri2-60n4-4t9d-e6v0-69i310cb110e'
}'
Response
An updated device.
{
"device": {
"id": "devicea0-45f2-4e9e-a6f0-69a310ab110b",
"blueprint_id": "bluepri2-60n4-4t9d-e6v0-69i310cb110e",
"name": "Gas detector in living room",
"site_id": "sitebba0-79f2-4e9e-a6f0-69a310ab110b",
"updated_at": 1735693200,
"slug": "gas-detector-in-living-room",
"type": "LUA",
"authorized_role": "INSTALLER"
}
}
device.idstring#Device ID.
device.blueprint_idstring#Blueprint ID.
device.site_idstring#Site ID.
device.namestring#Device name.
device.updated_atinteger#The timestamp of the most recent update of the device’s information.
device.authorized_rolestring#The user's authorized role for the device.
device.propertiesobject#Device's properties.
device.manifestobject#Device's manfiest.
device.communication_infoobject#Device's communication info.
device.slugstring#Device's slug.
device.typestring#Device's type.
device.siteobject#Device's site info.
device.implemented_profilesarray of strings#A list of profiles implemented by the device. You can also find them in the device's manifest.
device.connectivitystring#Device's connectivity status. Can be
ONLINE,OFFLINE,UNKNOWN.