Built-in GET/SET RPC Methods
Built-in GET/SET RPC methods let you read and write telemetry and attribute values on connected devices without any additional connector configuration. The method name and parameter string are sent as the RPC payload from the ThingsBoard RPC debug terminal on the gateway dashboard.
The following connectors support built-in GET/SET RPC methods:
The built-in GET and SET methods read and write any node by its node ID, for example the one in the value
of a telemetry entry in the connector configuration.
For example, given a timeseries entry:
{ "timeseries": [ { "key": "temperature", "type": "identifier", "value": "${ns=3;i=1001}" } ]}Read the current value of a node by its OPC-UA node ID:
get ns=3;i=1001;Response:
{"result": {"value": 25.34}}Write a numeric value to a node:
set ns=3;i=1001; 23Write a string value to an attribute node (e.g. set model to T3000):
set ns=3;i=1008; T3000Response:
{"result": {"value": "T3000"}}Read the value of a Modbus slave register:
get type=<type>;functionCode=<functionCode>;objectsCount=<objectsCount>;address=<address>;| Parameter | Description |
|---|---|
type |
Data type of the value to read |
functionCode |
Modbus function code |
objectsCount |
Number of objects to read |
address |
Register address |
Example — read a 16-bit integer from register 1 (outdoor temperature):
get type=16int;functionCode=3;objectsCount=1;address=1;Response:
{"result": 13}Write a value to a Modbus slave register:
set type=<type>;functionCode=<functionCode>;objectsCount=<objectsCount>;address=<address>;value=<value>;| Parameter | Description |
|---|---|
type |
Data type of the value to write |
functionCode |
Modbus function code |
objectsCount |
Number of objects to write |
address |
Register address |
value |
Value to write |
Example — write 80 to register 2 (room light level):
set type=16int;functionCode=6;objectsCount=1;address=2;value=80;Response:
{"result": "80"}Verify by reading the register back:
get type=16int;functionCode=3;objectsCount=1;address=2;Response:
{"result": 80}Subscribe to a response topic and publish a request to read a value:
get requestTopicExpression=<requestTopic>;responseTopicExpression=<responseTopic>;value=<value>;| Parameter | Description |
|---|---|
requestTopicExpression |
Topic to publish the request to |
responseTopicExpression |
Topic to subscribe to for the response (optional) |
value |
Value to send with the request |
Example — read the room light level from data/get_light_level, receiving the response on data/response:
get requestTopicExpression=data/get_light_level;responseTopicExpression=data/response;value=light_level;Publish a message to an MQTT topic:
set requestTopicExpression=<requestTopic>;value=<value>;| Parameter | Description |
|---|---|
requestTopicExpression |
Topic to publish the value to |
value |
Value to send |
Example — set the room light level to 80:
set requestTopicExpression=data/set_light_level;value=80;Verify by sending a GET request:
get requestTopicExpression=data/get_light_level;responseTopicExpression=data/response;value=light_level;Read a property value from a BACnet device:
get objectType=<objectType>;objectId=<objectId>;propertyId=<propertyId>;| Parameter | Description |
|---|---|
objectType |
BACnet object type |
objectId |
BACnet object ID |
propertyId |
BACnet property ID |
Example — read the current room light level (analogValue, object 1, presentValue):
get objectType=analogValue;objectId=1;propertyId=presentValue;Response:
{"result": "30.5"}Write a property value to a BACnet device:
set objectType=<objectType>;objectId=<objectId>;propertyId=<propertyId>;priority=<priority>;value=<value>;| Parameter | Description |
|---|---|
objectType |
BACnet object type |
objectId |
BACnet object ID |
propertyId |
BACnet property ID |
priority |
Write priority (optional, integer 1–16) |
value |
Value to write |
Example — set the room light level to 31.5:
set objectType=analogValue;objectId=1;propertyId=presentValue;value=31.5;Response:
{"result": "31.5"}Verify with GET:
get objectType=analogValue;objectId=1;propertyId=presentValue;Response:
{"result": "31.5"}Reserved GET/SET RPC methods work differently depending on the PLC family. S7 PLCs support both
data and tag addressing, while Siemens Logo! PLCs are addressed using vmAddress.
data type addressing
Section titled “data type addressing”Read a value from an S7 PLC using data type addressing:
get type=data;dbNumber=<dbNumber>;start=<start>;dataType=<dataType>;size=<size>;bit=<bit>;| Parameter | Description |
|---|---|
dbNumber |
DB number for S7 PLCs |
start |
Start address for S7 PLCs |
dataType |
Data type of the value to read |
size |
Size of the parameter in bytes for S7 PLCs |
bit |
Bit number for S7 PLCs. Only for boolean values |
Example — read a boolean status flag from DB1, byte 0, bit 1:
get type=data;dbNumber=1;start=0;dataType=bool;size=1;bit=1;Response:
{"result": true}tag type addressing
Section titled “tag type addressing”Read a value from an S7 PLC using tag type addressing:
get type=tag;tag=<tag>;| Parameter | Description |
|---|---|
tag |
Tag address for S7 PLCs |
Example:
get type=tag;tag=DB1.DBD104:REAL;data type addressing
Section titled “data type addressing”Write a value to an S7 PLC using data type addressing:
set type=data;dbNumber=<dbNumber>;start=<start>;dataType=<dataType>;size=<size>;bit=<bit>;value=<value>;| Parameter | Description |
|---|---|
dbNumber |
DB number for S7 PLCs |
start |
Start address for S7 PLCs |
dataType |
Data type of the value to write |
size |
Size of the parameter in bytes for S7 PLCs (optional) |
bit |
Bit number for S7 PLCs. Only for boolean values |
value |
Value that will be written to the device |
Example — set a boolean status flag at DB1, byte 0, bit 1 to false:
set type=data;dbNumber=1;start=0;dataType=bool;size=1;bit=1;value=false;Response:
{"result":"Successfully wrote value bytearray(b'\\x00') to device Demo Device for RPC method set"}tag type addressing
Section titled “tag type addressing”Write a value to an S7 PLC using tag type addressing:
set type=tag;tag=<tag>;value=<value>;| Parameter | Description |
|---|---|
tag |
Tag address for S7 PLCs |
value |
Value that will be written to the device |
Example:
set type=tag;tag=DB1.DBD104:REAL;value=12345;Read a value from a Siemens Logo! PLC by VM address:
get type=vm;vmAddress=<vmAddress>;| Parameter | Description |
|---|---|
vmAddress |
VM address for Siemens Logo! PLCs |
Example — read the temperature at VW30:
get type=vm;vmAddress=VW30;Response:
{"result":12}Write a value to a Siemens Logo! PLC by VM address:
set type=vm;vmAddress=<vmAddress>;value=<value>;| Parameter | Description |
|---|---|
vmAddress |
VM address for Siemens Logo! PLCs |
value |
Value that will be written to the device |
Example — set the temperature at VW30 to 35:
set type=vm;vmAddress=VW30;value=35;Response:
{"result":"Successfully wrote value 35 to device Demo Device for RPC method set"}Send a GET request to a REST endpoint:
get requestUrlExpression=<url>;| Parameter | Description |
|---|---|
requestUrlExpression |
REST endpoint URL |
Example — read the room light level from http://127.0.0.1:8000/light-level:
get requestUrlExpression=http://127.0.0.1:8000/light-level;Response:
{"result": {"light-level": 30}}Send a POST (or other HTTP method) request to a REST endpoint:
set requestUrlExpression=<url>;HTTPMethod=<method>;value=<value>;| Parameter | Description |
|---|---|
requestUrlExpression |
REST endpoint URL |
HTTPMethod |
HTTP method to use, for example POST or PUT (optional, default GET) |
value |
Value to send in the request body |
Example — set the room light level to 80:
set requestUrlExpression=http://127.0.0.1:8000/light-level;HTTPMethod=POST;value=80;Response:
{"result": {"status": "ok"}}Verify with GET:
get requestUrlExpression=http://127.0.0.1:8000/light-level;Response:
{"result": {"light-level": 80}}Send a GET request to an external API endpoint configured in the connector:
get requestUrlExpression=<path>;| Parameter | Description |
|---|---|
requestUrlExpression |
Path or URL of the external API endpoint |
Example — read the room light level from the configured base URL:
get requestUrlExpression=light-level;Response:
{"result": {"light-level": 30}}Send a POST (or other HTTP method) request to an external API endpoint:
set requestUrlExpression=<path>;httpMethod=<method>;value=<value>;| Parameter | Description |
|---|---|
requestUrlExpression |
Path or URL of the external API endpoint |
httpMethod |
HTTP method to use, for example POST or PUT (optional, default GET) |
value |
Value to send |
Example — set the room light level to 80:
set requestUrlExpression=light-level;httpMethod=POST;value=80;Response:
{"result": {"status": "ok"}}Verify with GET:
get requestUrlExpression=light-level;Response:
{"result": {"light-level": 80}}Read a file from the FTP server:
get filePath=<filePath>;| Parameter | Description |
|---|---|
filePath |
Path to the file on the FTP server |
Example — read light_level.txt:
get filePath=./light_level.txt;Response:
{"result": "30"}Write a value to a file on the FTP server:
set filePath=<filePath>;value=<value>;| Parameter | Description |
|---|---|
filePath |
Path to the file on the FTP server |
value |
Value to write |
Example — update light_level.txt to 80:
set filePath=./light_level.txt;value=80;Response:
{"result": "80"}Verify with GET:
get filePath=./light_level.txt;Response:
{"result": "80"}Which variables are readable or writable depends entirely on what the Charge Point’s Device Model
implements — not every Charge Point exposes every variable, and a request can come back as
Rejected, UnknownComponent, or UnknownVariable instead of Accepted.
Read the current value of an OCPP variable:
get component=<component>;componentInstance=<instance>;evseId=<id>;variable=<variable>;variableInstance=<instance>;timeout=<seconds>;| Parameter | Description |
|---|---|
component |
OCPP component name the variable belongs to |
componentInstance |
Instance name, if the component has multiple instances (optional) |
evseId |
EVSE id, if the component is scoped to a specific EVSE (optional) |
variable |
OCPP variable name to read |
variableInstance |
Instance name, if the variable has multiple instances (optional) |
timeout |
Seconds to wait for the Charge Point’s response (optional, default 5) |
Example — read the heartbeat interval of the Charging Station:
get component=OCPPCommCtrlr;variable=HeartbeatIntervalWrite a new value to an OCPP variable:
set component=<component>;componentInstance=<instance>;evseId=<id>;variable=<variable>;variableInstance=<instance>;timeout=<seconds>;value=<value>;| Parameter | Description |
|---|---|
component |
OCPP component name the variable belongs to |
componentInstance |
Instance name, if the component has multiple instances (optional) |
evseId |
EVSE id, if the component is scoped to a specific EVSE (optional) |
variable |
OCPP variable name to write |
variableInstance |
Instance name, if the variable has multiple instances (optional) |
timeout |
Seconds to wait for the Charge Point’s response (optional, default 5) |
value |
New value to set |
Example — set the heartbeat interval to 30 seconds:
set component=OCPPCommCtrlr;variable=HeartbeatInterval;value=30Verify with GET:
get component=OCPPCommCtrlr;variable=HeartbeatIntervalThe Socket connector supports only the SET method — sending data to a TCP socket endpoint.
Send data to a TCP socket:
set address=<address>;port=<port>;encoding=<encoding>;value=<value>;| Parameter | Description |
|---|---|
address |
IP address of the socket target |
port |
TCP port of the socket target |
encoding |
Character encoding of the value, for example utf-8 |
value |
Value to send |
Example — send a light level of 80 to a sensor listening on 192.168.0.200:50003:
set address=192.168.0.200;port=50003;encoding=utf-8;value=80;Response:
{"result": "ok"}Read the value of a GATT characteristic:
get characteristicUUID=<uuid>;| Parameter | Description |
|---|---|
characteristicUUID |
UUID of the characteristic, full (00002A00-0000-1000-8000-00805F9B34FB) or short (2A00) |
The response contains the characteristic value decoded as UTF-8 text.
Example — read the manufacturer name characteristic:
get characteristicUUID=00002A29-0000-1000-8000-00805F9B34FB;Response:
{"result": "EFENTO_GROUP"}Write a value to a GATT characteristic:
set characteristicUUID=<uuid>;value=<value>;| Parameter | Description |
|---|---|
characteristicUUID |
UUID of the characteristic, in the same forms as for GET |
value |
Value to write. The connector sends it as UTF-8 text |
Example:
set characteristicUUID=226CAA55-6476-4566-7562-66734470666D;value=1;Response:
{"result": "Ok"}The CAN connector supports only the SET method: sending a message to the CAN bus. A get request
returns an error.
Send a CAN message:
set nodeId=<id>;type=<type>;byteorder=<byteorder>;isExtendedId=<isExtendedId>;value=<value>;| Parameter | Description |
|---|---|
nodeId |
CAN arbitration ID, decimal (291) or hexadecimal with the 0x prefix (0x123) |
type |
How to encode value: hex, string, bool, 8int, 8uint, 16int, 16uint, 32int, 32uint, 64int, 64uint, or 32float |
byteorder |
Byte order for numeric types: big or little (optional, default big) |
isExtendedId |
true for a 29-bit extended ID, false for an 11-bit standard ID (optional, default false) |
value |
Value to send |
With type=hex, value is the message payload as hex digits, for example 0A1B. With type=string, the
value is sent as ASCII text. Integer types take as many bytes as their size: 16int takes 2 bytes, and so on.
Example — send the light level 80 as one unsigned byte to node 0x400:
set nodeId=0x400;type=8uint;value=80;Response:
{"result": {"success": true}}As you can see in the screenshot below, the lightLevel telemetry value of the device has changed to 80:
get and set work the same way: both run an SQL query or call a stored procedure.
get query=<query>;value=<arg1>,<arg2>;with_result=<true|false>;get procedure_name=<name>;value=<arg1>,<arg2>;with_result=<true|false>;| Parameter | Description |
|---|---|
query |
SQL query to run. Use ? placeholders for arguments. Either query or procedure_name is required |
procedure_name |
Name of the stored procedure to call |
value |
Comma-separated arguments for the ? placeholders or the procedure (optional) |
with_result |
true to return the first row of the result set (optional, default false) |
With with_result=true, the response contains the first row of the result set as an object with column
names as keys, or null if the query returns no rows. A statement that returns no result set, such as UPDATE,
gives an error with with_result=true. Without it, the response is {"result": {"success": true}}.
Example — read the latest value of a column:
get query=SELECT temperature FROM telemetry WHERE device = ? ORDER BY ts DESC LIMIT 1;value=thermostat-1;with_result=true;Response, for example:
{"result": {"temperature": 18.04}}Example — call the set_setpoint function to change the target temperature:
set procedure_name=set_setpoint;value=23.5;Response:
{"result": {"success": true}}On PostgreSQL, procedure_name works only for functions: a procedure fails with <name>() is a procedure.
Example — call a PostgreSQL procedure by passing a CALL statement in query:
set query=CALL <name>(?,?);value=<arg1>,<arg2>;A procedure without output parameters returns no result set, so do not set with_result=true for it.
Read the value of an OID:
get oid=<oid>;timeout=<seconds>;| Parameter | Description |
|---|---|
oid |
Object identifier |
timeout |
Seconds to wait for the response (optional, default 5) |
Example — read the system description:
get oid=1.3.6.1.2.1.1.1.0;Response:
{"result": "Demo Device"}Write a value to an OID:
set oid=<oid>;type=<type>;timeout=<seconds>;value=<value>;| Parameter | Description |
|---|---|
oid |
Object identifier |
type |
SNMP data type of the value (optional, default OCTETSTRING) |
timeout |
Seconds to wait for the response (optional, default 5) |
value |
Value to write |
Example — set the system location:
set oid=1.3.6.1.2.1.1.6.0;type=OCTETSTRING;value=Data center;Response:
{"result": "Data center"}Read the value of a group address:
get groupAddress=<groupAddress>;dataType=<dataType>;requestType=read;| Parameter | Description |
|---|---|
groupAddress |
KNX group address |
dataType |
KNX data type used to decode the value, for example temperature or string (optional) |
requestType |
Must be read |
Example — read the temperature from group address 1/0/6:
get groupAddress=1/0/6;dataType=temperature;requestType=read;Response:
{"result": "21.4"}Write a value to a group address:
set groupAddress=<groupAddress>;dataType=<dataType>;value=<value>;| Parameter | Description |
|---|---|
groupAddress |
KNX group address |
dataType |
KNX data type used to encode the value, for example percentU8 or string (optional) |
value |
Value to write |
Example — set the brightness on group address 1/0/9 to 50%:
set groupAddress=1/0/9;dataType=percentU8;value=50;Response:
{"result": "50"}The XMPP connector supports only the SET method: sending a message to the device.
Send a JSON message to the device:
set <key>=<value>;Each <key>=<value> pair becomes a field of the message. Values are sent as strings.
Example — send the value 25 to the device:
set value=25;The device receives {"value": "25"}.
Response:
{"result": "success"}Was this helpful?