rulesthingsboard

THINGSBOARD: How to modify (simple math) a value before I show it in a dashboard


I just landed into the thingsboard world, and so far I've been able to integrate it with our Chirpstack server and show a very basic dashboard with the received telemetry. All good for now, but I foresee a very complete (and complex!) tool I will have to slowly learn.

Our first necesity is we are sending a value which is a 4-20mA value from a pH sensor, and we need to transform it into a 0-14 value. So far it already shows a bar with the original value in the range 4-20.

How can I add a simple math expresion (ma-4)/16*14 to show real pH values? Does it involve rule chains? I have tried to understand them but they seem complex...hopefully there's a way to do so without them, or there a very simple way involving them.... Thanks in advance!!


Solution

  • It's actually very simple to do, it doesn't invilve rule chain modifications.

    You can use post processing function of your widget: https://thingsboard.io/docs/user-guide/widgets/#:~:text=The%20data%20post%2Dprocessing%20function,function%20in%20the%20field%20below.

    return (value-4)/16*14;