Hi all,
I have been connecting an arduino-like device to Thingsboard for a couple of weeks, and I have a bette view of how it works.
I guess you already know how to send MQTT telemetry to TB : just connect to the device (name, login, empty password) then send :
Topic : "v1/devices/me/telemetry"
Payload : "{[entity name in device]": String([entity value to transmit) }"
Receiving a server setpoint or digital command is a bit more complicated :
First the server will send you something like this if you subscribe to v1/devices/me/rpc/request/+ :
Topic : "v1/devices/me/request/12345"
Payload : "{"method":"[What you wrote in advanced-set value method in your widget], "params":[Value of the command]}"
where :
12345 changes with each request
[Value of the command] is either boolean (switch) and has no "" around it or numeric and has "" on either side
You will have to parse that, write to your device I/O, then submit to v1/devices/me/rpc/request/+ or v1/devices/me/rpc/response/+ (both seem to work) :
Topic : "v1/devices/me/response/12345"
Payload : "{"method":"[What you wrote in advanced-set value method in your widget], "params":[Value of the command]}"
12345 is the request number of the request you received from the server, so you will have to parse it too.
[Value of the command] has the same format as in the received request
Now on opening your panel, your server tries to initialise its active controls by sending you something like :
Topic : "v1/devices/me/request/12345"
Payload : "{"method":"[What you wrote in advanced-get value method in your widget]}"
And I am still trying and figure out what the hell the godforsaken son of a bitch is waiting for as an answer. I posted an issue about this yesterday.
can anyone help me to understand this?