Adam Mróz
Adam Mróz

Reputation: 31

RPC Control widget - What is proper response for getValue method. How to change setValue to react onRelease instead on onClick of mouse?

I am having an issues with thingsboard professional edition. I am using HTML Server Side RPC API.

Basically what I am trying to do is load dashboard and update knob temperature value. The next step is to set temperature value using knob and send it to device.

Issue with getValue method First of all I open dashboard and I am sending GET request

curl -v -X GET https://cloud.thingsboard.io/api/v1/*Device Access/Token*/rpc

Response is:

{"id":241,"method":"getValue","params":null}*

So I respond:

curl -v -X POST -d "{"result":44}" https://cloud.thingsboard.io/api/v1/*Device Access Token*/rpc/241 --header "Content-Type:application/json"

In place of "{"result":44}" I tried (I think) all possibilities like:

"{"method":"getValue","params":44}"
"{"method":"setValue","params":44}"
"{"method":NULL,"params":44}"
"{NULL,44}"
"44"
"{44}" and so on...

Can somebody help me how should proper response look like to update knob value when dashboard loads?

2) setValue issue

When I am trying to change temperature value I noticed that there is something weird happening. Let's say that I want to change value from 50 to 80deg using knob.

If i just "click" and temperature is set somewhere about 80deg when I send GET message response is what i expect:

{"id":273,"method":"setValue","params":"81.37"}*

But when I click on knob and slide the value from 50deg to 80deg and release the button I don't have proper response. Most of the time I have response like that:

{"id":275,"method":"setValue","params":"50.00"}* Closing connection 0

Or very close to 50 deg and it doesn't change anymore. How can i fix that issue?

Upvotes: 2

Views: 1472

Answers (1)

Dewege
Dewege

Reputation: 11

Even though this is more than 2 years old, I think it might help someone never the less:

Regarding GetValue I did many experiments and found that the POST message does not need

--header "Content-Type:application/json"

and the return value does not need to be in JSON format, but just plain text. So if you use

--header "Content-Type:application/text"

and as a return value just send e.g.

40.0

it will be accepted by the knob control.

full command might be something like

curls -v -X POST -d 40.0 https://cloud.thingsboard.io/api/v1/*Device Access Token*/rpc/241 --header "Content-Type:application/text"

Upvotes: 1

Related Questions