|  Developer
Updated on March 28, 2023

hub.cloud.subscription.update

Connection Type:

  • Update a subscription on a controller
Edit
Field Type Required Description
abstractUUID string + Abstract unique id
gatewayName string Name of the gateway (plugin) to redirect this request
mappings array + List of abstracts to be mapped to hub items
mappings[].capability string + Capability of an abstract. Note: firmware items does not have analogy for this field
mappings[].variable string + Variable of an abstract. Note: this field is similar to name of a firmware item
mappings[].valueType string Value type. This field is similar to item /
mappings[].dictionaryType bool Whether item value is a dictionary type
mappings[].value depends on Value of an abstract
mappings[].maxValue depends on Upper limit of item’s value field
mappings[].mimValue depends on Lower limit of item’s value field
mappings[].enum strings array Finite array of possible token values
Edit

NOTE: Update subscription on a controller:

add capability variables; remove capability variables; change item schema

This command gives the ability to update an existing subscription without removing its components.

  • 1) To add a new subscription of an existing abstract, add its definition according to hub.cloud.subscription.create rules. It should add a new item in an existing device of an ‘abstract’ category with the schema defined.
  • 2) To modify the existing item’s structure, do the same, but change the item’s schema. It should modify an existing item without changing its identifier.
  • 3) To remove a capability/variable, just add fields and WITHOUT all other fields.
Edit
Broadcasts Description
hub.item.added Broadcast when the subscription was changed
hub.item.removed Broadcast when the subscription was removed

Note: If the capability name is too long, then the subscription would not be created. Also, if the variable name is too long, then the same error would occur only will be replaced with . Its example is given below with the error response.

Edit
Edit
Edit
				
					{
    "method": "hub.cloud.subscription.update",
    "id": "_ID_",
    "params": {
        "abstractUUID": "1234-abcd-...",
        "mappings": [
            {
                "capability": "<capability-name-to-add>",
                "variable": "<variable-name-to-add>",
                "valueType": "int",
                "dictionaryType": false,
                "value": 1
            },
            {
                "capability": "<capability-name-to-add>",
                "variable": "<variable-name-to-add>",
                "valueType": "int",
                "dictionaryType": false,
                "value": 20,
                "minValue": 10,
                "maxValue": 30
            },
            {
                "capability": "<capability-name-to-add>",
                "variable": "<variable-name-to-add>",
                "valueType": "token",
                "dictionaryType": false,
                "enum":["one", "two"]
            },
            {
                "capability": "<capability-name-to-remove>",
                "variable": "<variable-name-to-remove>",
            }
        ]
    }
}				
			
Edit
				
					{
    "error": null,
    "id": "_ID_",
    "method": "hub.cloud.subscription.update",
    "result": {},
}				
			
Edit
Edit
				
					{
    "method": "hub.cloud.subscription.update",
    "id": "_ID_",
    "params": {
        "abstractUUID": "13c50adb-e278-4f70-93c9-a468c0ca7bcf",
        "mappings": [
            {
                "capability": "custom_subscription_eyJ1dWlkIjoiMTNjNTBhZGItZTI3OC00ZjcwLTkzYzktYTQ2OGMwY2E3YmNmIiwibmFtZSI6ImNyZWF0ZUlzc3VlQ2FsbGJhY2siLCJwYXJhbXMiOnsicHJvamVjdF9pZCI6InNkMjEzMjEzIn0sImV2ZW50X25hbWUiOiJpc3N1ZSJ9",
                "variable": "value",
                "valueType": "string",
                "dictionaryType": false,
                "value": ""
            }
        ]
    }
}				
			
Edit
				
					{
    "error": {
        "code":-32602,
        "data":"invalid.subscription.capability.name",
        "message":"Capability value doesn't corresponds to the set standards",
        "reason":"value at capability exceeded the max allowed length"
    },
    "id":"_ID_",
    "method":"hub.cloud.subscription.update",
    "result":{},
    "sender": { 
        "conn_id":"1",
        "type":"ui"
    }

}				
			
Edit
| Code | Message | Data | Reason | |——–|————————–|—————————-|——————————————————————————————————————————-| | -32602 | Capability value doesn’t corresponds to the set standards | invalid.subscription.capability.name | value at capability exceeded the max allowed length