[Question] How to creat entity or update entity by Rule Engine
Component
- Rule Engine
Description
How to creat entity or update entity by Rule Engine ?
Environment
- OS: OS: ubuntu 18.04.4 LTS
- ThingsBoard: 3.01
for those reasons you can use the REST API requests. For example, refer to the below.
the enrichment originator node can be used to fetch the values of the entity fields and then the rest api call can be used
you can use the attribute update widgets, though, you will need to split those processing, using different filtering to be pre-applied.
It will also require to have the authorization process being handled, to receive the JWT_TOKEN and use the Rest API Calls to the ThingsBoard using the JWT_TOKEN. Those can be done with an additional Rest API Call request before the processing/on the processing.
You can refer on how to proceed with the REST API requests on this link: https://thingsboard.io/docs/reference/rest-api/
Thank you for your answer, let me test it.
In my test, I use "rest api call" to get the entity and must use the setting "x-authorization",
but the setting of "x-authorization" must know the user's token, and the token validity is 2 hours.
Is there any other way to solve the problem of token timeliness is 2 hours.
you can adjust the parameter for the token. you can refer to the jwt topic in the thingsboard.yml for those.
security:
# JWT Token parameters
jwt:
tokenExpirationTime: "${JWT_TOKEN_EXPIRATION_TIME:9000}" # Number of seconds (2.5 hours)
refreshTokenExpTime: "${JWT_REFRESH_TOKEN_EXPIRATION_TIME:604800}" # Number of seconds (1 week)
tokenIssuer: "${JWT_TOKEN_ISSUER:thingsboard.io}"
tokenSigningKey: "${JWT_TOKEN_SIGNING_KEY:thingsboardDefaultSigningKey}"
So that you can you can increase the tokenExpirationTime, though, you will still require to set the name and the password for the corresponding processing of the gaining of the token to be handled within the rule engine.