In ThingsBoard I am trying to create several buttons, each buttons will generate a different REST API call. For now I created a single button like this post suggested, but according to the post every button click will generate the same REST API call. I want to differentiate each call. There probably is another way to do it but do not know how.
Thingsboard version: 3.2
Figured a way to do this:
I used Javascript fetch API to send the REST API request to a server that I used The information that I received I sent to the relevant devices, all is done in this specific widget that I created.
After creating our custom widget we can place it in our dashboard, notice that a static type widget cannot be attached to a telemetry data (because it is static). Everything that we wrote in the Javascript section regarding the widget we developed will only be executed as long as we are in the dashboard page that the widget we developed is "alive". When we leave the page everything will be "destroyed" and will be recreated when we reopen the page. For example if we use setInterval function it will be dropped when we leave the page.
So if we want something that will occur periodically like REST API call every certain amount of time we should use an external server that will send the information to the devices (on Thingsboard) and will function constantly. If the action that we need is on demand like a button click that we perform a single REST API call we can use the method above.
This Widgets Development Guide in Thingsboard website was very useful.