# Model Updates from the Cloud

Whenever any object owned by your Edge module gets updated, you (or rather your module) should know about it. An example could be an update of some configuration value that your module is characterized by (i.e., telemetry sending interval). Some user could update the value via web UI, and expect the Edge module to adjust to the new setting.

Ability Edge supports such functionality by the usage of the topic {topics_model_in}/# (# is a wildcard character - thanks to it our subscription covers all the topics that start with "{topics_model_in}/"). As long as you are subscribed to that, you will get all the updates of your information model objects (module objects and the children devices objects). Each model is delivered under a separate topic level, i.e. configuration model updates are delivered via {topics_model_in}/abb.ability.configuration.

Configuration model is sent to a module on each external update, other models must be explicitly requested. The version of the model is included in the payload, it can be used to identify redundant update messages. Note that models are retained, thus the latest model of a particular model definition will be delivered to the module every time it subscribes to this topic. Model updated for devices behind the module are delivered with the object identity in the last topic level - {topics_model_in}/{modelDefinitionId}/{objectId}.

# Payload Format

The payload will contain the delivered model, i.e.:

{"model":"abb.ability.configuration","type":"abb.mj.simpleEdge.module.configuration@1","version":1,"lastModified":"2021-02-10T09:35:25.582Z","properties":{"name":{"value":"f1bec093-020a-4752-929c-e8856371d7d7/simpledotnetmodule"},"docker":{"image":{"value":"abbability.azurecr.io/abb.mj.simpleedge.module:1"}}},"objectId":"7f10b72b-7d09-4a8e-8e77-121645b9cc4a","tenantId":"5f059166-65ea-49f5-8227-f8f547d75641"}

The JSON above is in one line on purpose - this is how your module will receive it.

# Automatic Delivery

When your module starts it will automatically receive its abb.ability.device and abb.ability.configuration models (unless you do not subscribe to the {topics_model_in}/# topic). Then, anytime abb.ability.configuration model gets updated, it will also be delivered automatically, without explicit request.

WARNING

The abb.ability.device model is expected to be updated ONLY by the module.

# Example

Below you can see a practical example of the updates coming into the module:

After the module starts, subscribe to the {topics_model_in}/# topic. You will automatically receive the update:

  1. abb.ability.device model:

    Topic: modules/simpledotnetmodule/model/desired/abb.ability.device/b778c9f3-8f93-4472-a2f6-19ed13b7c2a8

    Payload:

    {"model":"abb.ability.device","type":"abb.mj.simpleEdge.module.device@1","name":"simpledotnetmodule","ownerId":"4fee485e-7d54-49f9-a11a-fe2b15cb5954","path":"simpledotnetmodule","version":1,"lastModified":"2021-02-10T10:23:45.564Z","properties":{"name":{"value":"b715c9d0-e3c4-4ba8-b358-dbaa34ffbda2/simpledotnetmodule"}},"objectId":"b778c9f3-8f93-4472-a2f6-19ed13b7c2a8","tenantId":"5f059166-65ea-49f5-8227-f8f547d75641"}
    
  2. abb.ability.configuration model:

    Topic: modules/simpledotnetmodule/model/desired/abb.ability.configuration/b778c9f3-8f93-4472-a2f6-19ed13b7c2a8

    Payload:

    {"model":"abb.ability.configuration","type":"abb.mj.simpleEdge.module.configuration@1","version":1,"lastModified":"2021-02-10T10:23:45.782Z","properties":{"name":{"value":"b715c9d0-e3c4-4ba8-b358-dbaa34ffbda2/simpledotnetmodule"},"docker":{"image":{"value":"abbability.azurecr.io/abb.mj.simpleedge.module:19.03"}},"deviceProtocol":{"value":"opc ua"}},"objectId":"b778c9f3-8f93-4472-a2f6-19ed13b7c2a8","tenantId":"5f059166-65ea-49f5-8227-f8f547d75641"}
    

As you can see in the abb.ability.configuration model, there is a property called "deviceProtocol". It is a custom property that we have added to our module's configuration for the sake of this example. Let's assume that this property controls the protocol that the module will use while communicating with some devices. Let's now update the module's cofiguration using the Instance API, by changing the "deviceProtocol" value:

curl --location --request PATCH 'https://{ability-instance-api}/v1/objects/b778c9f3-8f93-4472-a2f6-19ed13b7c2a8/models/abb.ability.configuration' \
--header 'Return-Object-Model: false' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0e...' \
--data-raw '{
    "properties": {
        "deviceProtocol": {
            "value": "modbus"
        }
    }
}'

Getting back to the Edge-side, the module receives the following message:

Topic: modules/simpledotnetmodule/model/desired/abb.ability.configuration/b778c9f3-8f93-4472-a2f6-19ed13b7c2a8

Payload:

{"model":"abb.ability.configuration","type":"abb.mj.simpleEdge.module.configuration@1","version":2,"lastModified":"2021-02-10T10:26:20.052Z","properties":{"name":{"value":"b715c9d0-e3c4-4ba8-b358-dbaa34ffbda2/simpledotnetmodule"},"docker":{"image":{"value":"abbability.azurecr.io/abb.mj.simpleedge.module:19.03"}},"deviceProtocol":{"value":"modbus"}},"objectId":"b778c9f3-8f93-4472-a2f6-19ed13b7c2a8","tenantId":"5f059166-65ea-49f5-8227-f8f547d75641"}

This way, we have updated the module's configuration. It is up to the module's code to decide what to do about the changed "deviceProtocol" value.

Last updated: 10/20/2021, 9:08:02 AM
Feedback