postgresqlthingsboard

Transform telemetry data with data from another database in Thingsboard


After reading a value from a device I need to calculate something by using that value and some parameters I need to store in another database.

  1. How can I store some extra data (not from devices) in a table in the PostgreSQL database of thingsboard
  2. How can I read that data from that table in the rule chain?

Thanks


Solution

  • In ThingsBoard almost every entity has two types of data that is attached to them. First is timeseries which you use for data that needs to be recorded thru history. Second are attributes which represents values of which we need to know only latest one.

    Before or after "Save timeseries" in Root rule chain you can put "originator attributes" rule node and with it pull server attribute in which you have your additional information.

    For all of this to work, you need to prepare an attribute (on your device ThingsBoard page). This can be done manually (+ sign and than you give it a name and a value) or thru rule chain by giving object like {msg:{attributeName: 123, secondAttributeName: 321},metadata:{},msgType:"POST_ATTRIBUTES_REQUEST"}. Since you can modify that in rule chain, you can make an API call towards your second database in order to get those special numbers that you need.