问题
I am trying to create the following in Thingsboard:
In a dashboard create a button, when it is clicked a rest api call to an external server is made.
So far I have found that it is possible to define a rule chain with "rest api call" node, but I am unable to find a good rule which will lead to its execution (sending an api each time an entity is created obviously is a bad option)
In the "control widgets" I was not able to create a working solution but it looks like the correct way.
回答1:
I have figured a way to do it, not the best but it works:
- Create a board
- Create an "Update Device Attribute" control widget
- Go to "Edit" in the "Update Device Attribute" control widget, pick an unused device (it might be possible to pick a used device but i am not sure if the operation might alter it), go to "Advanced" and set "Device attribute parameters to any valid json, for example: {"rest":1}
- Go to "Rule Chains" and create the following rule: Input -> Message Type Switch -(Attribute Updated)-> Rest Api Call (choose from nodes-external)
- In the "Rest Api Call" set the required endpoint url and method, then apply change
If you have configured everything properly, every time the button is clicked an api call will be made
来源:https://stackoverflow.com/questions/63683220/thingsboard-create-a-rest-api-call-button-in-a-dashboard