Device Management
This section of the Device API describes the 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"
}'
Body Parameters
device_namestringrequired#A new device name.
slugstringrequired#A new device slug.
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.slugstring#
device.typestring#One of the following types:
UNDEFINED_DEVICE_TYPE,STANDALONE,GATEWAY,EMBEDDED_UCM- communication module, which embedded into Enapter devices UCM,HARDWARE_UCM- Enapter Universal Communication Modules (UCM),VIRTUAL_UCM- Enapter virtual UCM,LINK_MASTER_UCM,LINK_SLAVE_UCM,LUA,NATIVE- Enapter device like Electrolyser or Dryer.
device.implemented_profilesarray of strings#A list of profiles implemented by the device. You can also find them in the device's manifest.
Expanded fields
device.propertiesobject#Device's properties.
device.communication_infoobject#Device's communication info.
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 \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}'
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.
config.mqtt_credentials.protocolstring#MQTTorMQTTS.
| MQTT | MQTTS |
|---|---|
|
|
|
|
|
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.slugstring#
device.typestring#One of the following types:
UNDEFINED_DEVICE_TYPE,STANDALONE,GATEWAY,EMBEDDED_UCM- communication module, which embedded into Enapter devices UCM,HARDWARE_UCM- Enapter Universal Communication Modules (UCM),VIRTUAL_UCM- Enapter virtual UCM,LINK_MASTER_UCM,LINK_SLAVE_UCM,LUA,NATIVE- Enapter device like Electrolyser or Dryer.
device.implemented_profilesarray of strings#A list of profiles implemented by the device. You can also find them in the device's manifest.
Expanded fields
device.propertiesobject#Device's properties.
device.communication_infoobject#Device's communication info.
device.connectivitystring#Device's connectivity status. Can be
ONLINE,OFFLINE,UNKNOWN.