Read and write device parameters
Read a device parameter from the device managed object, send a new value to the device with a c8y_ParameterUpdate operation, and check the value that the device reports back.
This page is the agent skill cumulocity-read-write-device-parameters. Save it as cumulocity-read-write-device-parameters/SKILL.md in the skills folder of your agent: .agents/skills/ for Codex, GitHub Copilot, Cursor, and Gemini CLI, or .claude/skills/ for Claude Code.
It builds on cumulocity-authentication: install that skill too.
API reference
Core API-
GET
/Retrieve a specific managed objectinventory/ managedObjects/ {id} -
POST
/Create an operationdevicecontrol/ operations -
GET
/Retrieve a specific operationdevicecontrol/ operations/ {id} -
GET
/Retrieve all eventsevent/ events
Linked from the documentation
- Device parameter in Fragment library
- Managing parameters
A device parameter is a fragment on the device managed object, for example "reportingInterval": 60. You read a parameter from the managed object. To change it, you create a c8y_ParameterUpdate operation:
- The device picks up the operation and applies the new value.
- The device reports the value with an event of the type
c8y_ParameterUpdate, see Device parameter. - The device-parameter microservice copies the reported value to the device managed object.
The device-parameter microservice only copies the value if the property definition of the parameter in the Digital Twin Manager allows the asset context, or if the parameter has no property definition. To check the definition, see Inspect the definition of a device parameter.
SKILLS:
ROLES & PERMISSIONS:
- To read the device: ROLE_INVENTORY_READ
- To create the operation: ROLE_DEVICE_CONTROL_ADMIN
- To read the operation: ROLE_DEVICE_CONTROL_READ
- To read the parameter update events: ROLE_EVENT_READ
Your tenant is subscribed to the microservices device-parameter and dtm. The Parameters tab of the device needs both.
The examples use <device_id> for the ID of the device and <operation_id> for the ID of the operation. They set the parameter reportingInterval to 60.
To read a parameter
Send a Retrieve a specific managed object request:
GET /inventory/managedObjects/<device_id>
The platform returns HTTP 200 and the device. Check the following properties in the response:
- The fragment
reportingIntervalcontains the current value of the parameter. If the fragment is missing, the device never reported this parameter. You can still set it. - The array
c8y_SupportedOperationscontains"c8y_ParameterUpdate". If it is missing, do not create the operation. No agent picks it up.
If the platform returns HTTP 404, the device does not exist.
To send a new value to the device
Send a Create an operation request:
POST /devicecontrol/operations
Content-Type: application/json
Accept: application/json
{
"deviceId": "<device_id>",
"description": "Update parameter 'reportingInterval'",
"c8y_ParameterUpdate": {},
"c8y_ParameterUpdate_reportingInterval": {},
"reportingInterval": 60
}
The operation has three fragments. In the list, <parameter_key> stands for the fragment name of the parameter, here reportingInterval:
c8y_ParameterUpdate: An empty marker fragment for parameter updates.c8y_ParameterUpdate_<parameter_key>: An empty marker fragment for the parameter.<parameter_key>: The new value. Use any JSON value that the device accepts for this parameter, for example a number or an object.
Do not send a status. The platform sets it.
The platform returns HTTP 201 and the operation with its id and "status": "PENDING". Note the id as <operation_id>.
If the platform returns HTTP 422, the device is not an agent, and none of its parent devices is an agent. The platform cannot deliver operations to it.
To follow the operation
Send a Retrieve a specific operation request:
GET /devicecontrol/operations/<operation_id>
Repeat the request every 5 seconds until the status is SUCCESSFUL or FAILED, for at most 2 minutes:
- SUCCESSFUL: The device applied the value. It reports the value with a
c8y_ParameterUpdateevent. - FAILED: The
failureReasonproperty describes why the device did not apply the value. - Still PENDING after 2 minutes: No agent picked up the operation. The device is offline, or it does not listen for parameter updates. Cancel the operation, see To cancel a pending operation.
For details on the statuses of an operation, see Send an operation to a device.
To check the reported value
The device-parameter microservice writes the reported value to the managed object asynchronously, after the device sends its event.
Send the Retrieve a specific managed object request again:
GET /inventory/managedObjects/<device_id>
Repeat the request every 10 seconds, for at most 2 minutes, until the fragment reportingInterval contains the new value.
If the value does not change, check the property definition of the parameter, see Inspect the definition of a device parameter:
- The definition does not allow the asset context: The device-parameter microservice does not write this parameter to the managed object. Read the value from the latest parameter update event instead, as described below.
- The definition allows the asset context, or no definition exists: The device did not send a
c8y_ParameterUpdateevent, or its event is not the latest one for this parameter.
To read the latest value that the device reported, send a Retrieve all events request:
GET /event/events?source=<device_id>&type=c8y_ParameterUpdate&fragmentType=reportingInterval&pageSize=1
The platform returns HTTP 200 and the newest matching event in the events array. The fragment reportingInterval of the event contains the reported value.