thing_def.create
The thing_def.create command is used to create a new Thing Definition.
TR50 Request
{
"cmd": {
"command": "thing_def.create",
"params": {
"key": "sample_def",
"name": "Sample Definition",
"autoDefProps": false,
"autoDefAttrs": false,
"properties": {
"temp": {
"name": "Temperature",
"suffix": "F",
"unit": "F"
}
},
"alarms": {
"temp": {
"name": "Temperature Alarm",
"states": [
{
"name": "Too Cold",
"color": "#0084FF"
},
{
"name": "Just Right",
"color": "#00D92B"
},
{
"name": "Too Warm",
"color": "#E07F00"
},
{
"name": "Too Hot",
"color": "#B80000"
}
]
}
},
"methods": {
"test": {
"name": "Test",
"notificationVariables": {
"test1": {
"name": "Test1",
"type": "int"
}
}
}
},
"tunnels": {
"workbench": {"name":"test", "port":4012},
"ssh": {"name":"SSH", "port":22},
"rdp": {"name":"RDP", "port":3389},
"vnc": {"name":"VNC", "port":5900}
},
"locations": {
"ignoreFixTypes": ["gps", "gnss"],
"noDecode": true
}
}
}
}
Request Parameters
Name |
Type |
Required |
Description |
---|---|---|---|
key |
String |
Yes |
The key of the new Thing Definition. |
name |
String |
Yes |
The name of the Thing Definition. |
autoDefAttrs |
Boolean |
|
Whether to automatically define attributes as they're published. |
autoDefProps |
Boolean |
|
Whether to automatically define properties as they're published. |
alarms |
Object |
|
Key-value pairs where the key is the alarm key and the value is an alarm definition object. |
attributes |
Object |
|
Key-value pairs where the key is the attribute key and the value is an attribute definition object. |
methods |
Object |
|
Key-value pairs where the key is the method key and the value is a method definition object. |
properties |
Object |
|
Key-value pairs where the key is the property key and the value is a property definition object. |
tunnels |
Object |
|
Key-value pairs where the key is the tunnel key and the value is a tunnel definition object. |
locations |
Object |
|
Key-value pairs of the location setting and value of the setting. |
Alarm Definition Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The name of the alarm. |
states |
Array |
|
Array of alarm state objects, directly correlating with the array's indices. |
viewTags |
Array |
|
Security "read" tags for this alarm. |
updateTags |
Array |
|
Security "write" tags for this alarm |
Alarm State Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The state's name. |
color |
String |
|
Color value used for UI display. |
Attribute Definition Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The name of the attribute. |
default |
String |
|
The default value of the attribute when it is not set. |
viewTags |
Array |
|
Security "read" tags for this attribute. |
updateTags |
Array |
|
Security "write" tags for this attribute. |
Method Definition Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The name of the method. |
tags |
String |
|
Array of tags by which the method is associated. |
notificationVariables |
Object |
|
Key-value pairs where the key is the variable key and the value is a method variable object. |
completionVariables |
Object |
|
Key-value pairs where the key is the variable key and the value is a method variable object. |
handler |
String |
|
The handler is set to either a method or a trigger.
|
defaultAckTimeout |
Integer |
The default acknowledge timeout (in seconds) to use when the method is executed. This can be overridden. The maximum value is 300 seconds. |
Method Variable Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The variable's proper name. |
type |
String |
Yes |
The variable's type. Must be one of: bool, float, int or string. |
uiType |
String |
|
Type used for UI display only. |
uiTypeOptions |
Object |
|
Unstructured params used for UI display only. |
count |
Integer |
|
The variable value's count. |
length |
Integer |
|
The variable value's length. |
Property Definition Object
Name |
Type |
Required |
Description |
---|---|---|---|
name |
String |
Yes |
The name of the property. |
prefix |
String |
|
The prefix used for displaying this property's values. |
suffix |
String |
|
The suffix used for displaying this property's values. |
unit |
String |
|
The unit used for displaying this property's values. |
viewTags |
Array |
|
Security "read" tags for this property. |
updateTags |
Array |
|
Security "write" tags for this property. |
calcAggregates |
Bool |
|
If values of the property are to be aggregated. If set to True, all the seven types of aggregates (Average, Weighted Average, Non-zero time weighted average, Sum, Max, Min, and Count) are calculated. |
deDuplicate |
Bool |
If a duplicate property is published (that is, a newly published property value with the same timestamp as an existing property value), it is ignored when this parameter is set to true. |
Location Definition Object
Name |
Type |
Required |
Description |
---|---|---|---|
ignoreFixTypes |
Array |
|
An array of fix type strings to be ignored. Typically fix types include "gps", "gnss", "manual", and "m2m-locate" |
noDecode |
Bool |
When set to true, the platform will not attempt to use reverse-geolocation to decode the lat/lng pair to an address when a lat/lng pair is supplied to the location.publish and location.batch commands. The noDecode setting will be overridden for a single location.publish if the decodeAddress parameter is set to true for the command. |
TR50 Response
If the command is sent successfully a success message is returned. Otherwise, an error and error message will be returned.
{
"cmd": {
"success": true,
"params": {
"id": "537a3fa6d15a702de0000008"
}
}
}
Response Parameters
Name |
Type |
Description |
---|---|---|
id |
String |
The unique identifier of the new Thing Definition. |