How Portals uses Meta fields for Device Clients and Data Sources in One Platform

Follow

The One Platform stores additional information related to devices (clients) or data sources (dataports) in the ‘meta’ field of these two Platform resources. 

Examples are the activetime value used in some widgets to show if a device is 'online' or not and the 'unit' field for data sources in portals.

Device (Client) Meta

The device meta field stores user-configurable data as well as important information about the device type.

Portals sets different information for generic clients and those based on Client Models.

Type: Client Model

{
    "activetime": "<ActiveTimeRange>",
    "timezone": "<Timezone>",
    "location": "<Location>",
    "device": {
        "type": "vendor",
        "vendor": "<VendorID>",
        "model": "<ModelName>",
        "sn": "<SerialNumber>"
    }
}

Type: Generic
{
    "activetime": "<ActiveTimeRange>",
    "timezone": "<Timezone>",
    "location": "<Location>",
    "device": {
        "type": "generic"
    }
}

Creating Client Meta

In order to create Client Meta using the Remote Procedure Call API (RPC), in the body of your RPC call, the Meta JSON object must be converted to a string and included in the "meta" property, as shown below: 

{"procedure": "create", 
 "arguments": [     
     <ResourceID>,
     "client",
     {
       "limits": {
         "client": number | "inherit" = 0,
         "dataport": number | "inherit" = 0,
         "datarule": number | "inherit" = 0,
         "disk": number | "inherit" = 0,
         "dispatch": number | "inherit" = 0,
         "email": number | "inherit" = 0,
         "email_bucket": number | "inherit" = 0,
         "http": number | "inherit" = 0,
         "http_bucket": number | "inherit" = 0,
         "share": number | "inherit" = 0,
         "sms": number | "inherit" = 0,
         "sms_bucket": number | "inherit" = 0,
         "xmpp": number | "inherit" = 0,
         "xmpp_bucket": number | "inherit" = 0
         },
      "locked": boolean = false,
      "meta": string = "",
      "name": string = "",
      "public": boolean = false
    }
 ],
 "id": 1
}

More information can be found in the RPC documentation for creating a device/client.

Data Source (Dataport) Meta

Portals has been configured to render data sources with a ‘visibility’ setting of ‘hidden’ in the data source meta field to not show up in the user’s data source listing page and in widgets.


{
    "datasource": {
         "description":"",
         "unit":"unit"
    }
}

Creating Dataport Meta

In order to create or modify Dataport Meta using the Remote Procedure Call API (RPC), in the body of your call, the Meta JSON object must be converted to a string and included in the "meta" property, as shown below: 

{ "procedure":"create",
   "arguments": [
     "dataport", {
         "format": "float" | "integer" | "string", 
         "meta": string = "",
         "name": string = "",
         "preprocess": list = [],
           "public": boolean = false,
           "retention": { "count": number | "infinity", "duration": number | "infinity" },
           "subscribe": <ResourceID> | null = null
     }
   ],     
   "id": 1 
}

More information can be found in the RPC documentation for creating a dataport. 

Have more questions? Submit a request

Comments