# Model Updates from the Module
The module is capable of updating the information model objects that it owns. It includes the abb.ability.device model of the module itself together with the models that represent its children.
The following topics must be used to update models:
{topics_model_out}/abb.ability.device&id={optional GUID}&ack={optional ack setting}
- this topic shall be used when you're about to update the object model of the module itself{topics_messages_out}/type=deviceUpdated&model=abb.ability.device&id={optional GUID}&ack={optional ack setting}&objectId={objectId of the device being updated}
The values in the curly braces are the names of the environment variables that you need to read the topic names from. Read more here.
The topic names given above are for the abb.ability.device models. You could
of course update other models if your solution contains such. Optionally, you
can provide id
and ack
parameters, as shown.
# Payload Format
The payload should contain the JSON of the new version of the model. Mind that
the version
property should be set to the version of the PREVIOUS latest
version of this model. After the update, the value will be incremented.
{ "type": "abb.mj.simpleEdge.module.device@1", "properties": { "name": { "value": "8837ed9a-0c8b-4fa3-a64a-c598dd43c214/simpledotnetmodule" }, "someProperty": { "value": "some new value" } }, "model": "abb.ability.device", "version": 1, "objectId": "8837ed9a-0c8b-4fa3-a64a-c598dd43c214"}
If you asked for the acknowledgement, you'd get either one of these:
successful one
{"version":3,"success":true,"code":"ok","details":""}
unsuccessful one
{"success":false,"code":"http_response_error","details":"\"InfoModel put endpoint operation unsuccessful. StatusCode: 400 (Bad Request). Response: '{\"errors\":[{\"code\":\"400\",\"title\":\"BadRequest\",\"detail\":\"Payload integrity validation error. Please check validation details.\",\"id\":\"0HM614SOC2D3C:000007F7\",\"status\":\"BadRequest\",\"meta\":{\"validationErrors\":[{\"detail\":\"Value of unique property was changed. Previous value: 146e4dbc-898f-4ef2-85b3-8d555d9d3134/simpledotnetmodule, new value: 8837ed9a-0c8b-4fa3-a64a-c598dd43c214/simpledotnetmodule\",\"path\":\"properties.name\"}]}}]}'\""}
The error details depend from the type of error that you encounter. In the payload above, a property that should not be changed was modified in the update payload. The update was rejected.
# Example
Let's assume that our module's abb.ability.device model is initially the following:
{
"model": "abb.ability.device",
"type": "abb.mj.simpleEdge.module.device@1",
"name": "simpledotnetmodule",
"ownerId": "7c8d9943-bc4a-4d7c-b1f8-f276f5df232f",
"path": "simpledotnetmodule",
"version": 1,
"properties": {
"name": {
"value": "146e4dbc-898f-4ef2-85b3-8d555d9d3134/simpledotnetmodule"
},
"currentProtocol": {
"value": "opc ua"
}
},
"objectId": "8837ed9a-0c8b-4fa3-a64a-c598dd43c214",
"tenantId": "5f059166-65ea-49f5-8227-f8f547d75641"
}
We intend to update the "currentProtocol" property. The following message will be sent:
Topic: modules/simpledotnetmodule/model/reported/abb.ability.device
Payload:
{ "type": "abb.mj.simpleEdge.module.device@1", "properties": { "name": { "value": "146e4dbc-898f-4ef2-85b3-8d555d9d3134/simpledotnetmodule" }, "currentProtocol": { "value": "modbus" } }, "model": "abb.ability.device", "version": 1, "objectId": "8837ed9a-0c8b-4fa3-a64a-c598dd43c214"}
We might have used the acknowledgement feature to make sure that the update has went through. In this example, let's assume that it did. We can verify that by using the Instance API of the Ability Platform:
curl --location --request GET 'https://{instance-api-url}/v1/objects/8837ed9a-0c8b-4fa3-a64a-c598dd43c214/models/abb.ability.device?isHolistic=false' \
--header 'Authorization: Bearer eyJ0eXA...'
The response would be the following:
{
"model": "abb.ability.device",
"type": "abb.mj.simpleEdge.module.device@1",
"ownerId": "7c8d9943-bc4a-4d7c-b1f8-f276f5df232f",
"path": "simpledotnetmodule",
"version": 2,
"lastModified": "2021-02-10T10:57:46.889Z",
"properties": {
"name": {
"value": "146e4dbc-898f-4ef2-85b3-8d555d9d3134/simpledotnetmodule"
},
"currentProtocol": {
"value": "modbus"
}
},
"objectId": "8837ed9a-0c8b-4fa3-a64a-c598dd43c214",
"tenantId": "5f059166-65ea-49f5-8227-f8f547d75641"
}
The device model update would look almost the same. The main difference would be the topic name being different.