Variables¶
There are multiple ways to set/get variables on a data logger. These methods have evolved from early implementations to the current system, and we strive to maintain backward compatibility. However, it is recommended to use current configuration over the alternate method whenever possible.
variable {action:set}¶
Instruct the data logger to set variables to a specified value.
Subscribe <baseTopic>/cc/<deviceID>/variable
Properties
"action": "set""assignments": {}Object containing variable assignments"variable_name":(string) value
Variable access and examples:
"variable_name": "12.3"— Public variable"Public.variable_name": "12.3"— Public variable with explicit scope"variable_name(2)": "2.013"— Array element of a public variable"StructureName.variable_name": "12.3"— Variable inside a structure"StructureName.variable_name(2)": "12.3"— Array element of a variable inside a structure"trigger_event": "true"- Boolean variables
Note
The JSON keys and the values must be type string. The string values will be converted to the appropriate types by the data logger.
Example Command
Subscribe cs/v2/cc/ABCD-EFGH-1234/variable
{
"action": "set",
"assignments": {
"bale_count": "20",
"field_name": "north_40",
"farmall.pto_engaged": "False",
"farmall.engine_rpm": "1780.0"
}
}
Response
Publish cs/v2/cr/ABCD-EFGH-1234/variable
{
"success": "variables set"
}
VariableSet¶
Alias for variable {action:set}. Functionally identical, but the action is
encoded in the topic name instead of an "action" key in the payload.
Subscribe <baseTopic>/cc/<deviceID>/VariableSet
Properties
"assignments": {}Object containing variable assignments"variable_name":(string) value
See variable {action:set} above for variable access examples (public, structure, array element, boolean, etc.).
Example Command
Subscribe cs/v2/cc/ABCD-EFGH-1234/VariableSet
{
"assignments": {
"acres_harvested": "151",
"i_did_a_thing": "False"
}
}
Response
Publish cs/v2/cr/ABCD-EFGH-1234/VariableSet
{
"success": "Variables set"
}
setVar <Alternate>¶
Alternate method to set a single variable
Subscribe <baseTopic>/cc/<deviceID>/setVar
Properties
"name":(string) variable name"value":(string) variable value
Example Command
Subscribe cs/v2/cc/ABCD-EFGH-1234/setVar
{
"name": "bale_count",
"value": "25"
}
Response
Publish cs/v2/cr/ABCD-EFGH-1234/setVar
{
"success":"Set variable succeeded"
}
variable {action:get}¶
Request the data logger to retrieve the current value of one or more variables.
Subscribe <baseTopic>/cc/<deviceID>/variable
Properties
"action": "get""names": []Array containing variable names to retrieve. When empty or omitted, all accessible public variables are requested.
Variable access and examples:
"names": []— Get all public variables"names": ["battery_voltage"]— Single public variable"names": ["battery_voltage", "panel_temperature"]— Multiple public variables"names": ["data_array(1)", "data_array(2)"]— Individual array elements (Note: you cannot request the entire array as"data_array()"; each element must be explicitly listed.)"names": ["structure_1.member_array(1)", "structure_1.member_array(2)"]— Structure members"names": ["structure_2.member_trigger"]— Structure member variable
Example Command: All Variables
Subscribe cs/v2/cc/ABCD-EFGH-1234/variable
{
"action": "get",
"names" : [ ]
}
Example Command: Specified List
Subscribe cs/v2/cc/ABCD-EFGH-1234/variable
{
"action": "get",
"names": [
"buckwheat_storage_level",
"barly_storage_level",
"corn_storage_level",
"lamborghini_R(1).location",
"lamborghini_R(1).engine_rpm",
"lamborghini_R(1).fuel_level",
"lamborghini_R(1).pto_engaged",
"lamborghini_R(1).tire_pressure(1)",
"lamborghini_R(1).tire_pressure(2)",
"lamborghini_R(1).tire_pressure(3)",
"lamborghini_R(1).tire_pressure(4)"
]
}
Response
The response provides an object for each requested variable. Each object includes both the variable’s current value and its data type.
"t"— (string) The variable’s data type (e.g.,"float","int","string","boolean")."v"— (string) The current value of the variable.
Publish cs/v2/cr/ABCD-EFGH-1234/variable
{
"buckwheat_storage_level": {
"t": "float",
"v": "10.1"
},
"barly_storage_level": {
"t": "float",
"v": "10.2"
},
"corn_storage_level": {
"t": "float",
"v": "10.3"
},
"lamborghini_R(1).location": {
"t": "string",
"v": "South 40"
},
"lamborghini_R(1).engine_rpm": {
"t": "int",
"v": "1100"
},
"lamborghini_R(1).fuel_level": {
"t": "float",
"v": "96.31922"
},
"lamborghini_R(1).pto_engaged": {
"t": "boolean",
"v": "True"
},
"lamborghini_R(1).tire_pressure(1)": {
"t": "float",
"v": "32.1"
},
"lamborghini_R(1).tire_pressure(2)": {
"t": "float",
"v": "32.2"
},
"lamborghini_R(1).tire_pressure(3)": {
"t": "float",
"v": "33.1"
},
"lamborghini_R(1).tire_pressure(4)": {
"t": "float",
"v": "33.2"
}
}
VariableGet¶
Alias for variable {action:get}. Functionally identical, but the action is encoded
in the topic name instead of an "action" key in the payload.
Subscribe <baseTopic>/cc/<deviceID>/VariableGet
Properties
"names": []Array containing variable names to retrieve. When empty or omitted, all accessible public variables are requested.
See Get Variable above for variable access examples (public, array element, structure member, etc.).
Example Command: Specified List
Subscribe cs/v2/cc/ABCD-EFGH-1234/VariableGet
{
"names": [
"buckwheat_storage_level",
"barly_storage_level",
"corn_storage_level",
"lamborghini_R(1).location",
"lamborghini_R(1).engine_rpm",
"lamborghini_R(1).fuel_level",
"lamborghini_R(1).pto_engaged",
"lamborghini_R(1).tire_pressure(1)",
"lamborghini_R(1).tire_pressure(2)",
"lamborghini_R(1).tire_pressure(3)",
"lamborghini_R(1).tire_pressure(4)"
]
}
Example Command: All Variables
Subscribe cs/v2/cc/ABCD-EFGH-1234/VariableGet
{
"names" : [ ]
}
Response
The response format is identical to Get Variable — an object per requested
variable containing its data type ("t") and current value ("v").
Publish cs/v2/cr/ABCD-EFGH-1234/VariableGet
GetVar <Alternate>¶
Method to get a single variable
Subscribe <baseTopic>/cc/<deviceID>/getVar
Properties
"name":(string) variable name
Example Command
{
"name": "bale_count"
}
Response
Publish cs/v2/cr/ABCD-EFGH-1234/getVar
{
"name":"bale_count",
"value":"56"
}
List Variables <Alternate>¶
List variables and their types from a table.
Important
Other than the Public Table, all Data Tables must include the MQTTPublishTable() CRBasic instruction.
Tables such as a Structure, Status, CPIStatus, or similar system tables cannot expose their variable names using this method.
Subscribe <baseTopic>/cc/<deviceID>/listVar
Properties
"table":<table_name><table_name>
nullor"public"will return the public variables
Example Command
Subscribe cs/v2/cc/ABCD-EFGH-1234/listVar
{
"table" : "Public"
}
Publish cs/v2/cr/ABCD-EFGH-1234/listVar
{
"juice_level": "float",
"logger_temp": "float",
"extreme_temperature": "boolean",
"message": "string"
}