I have my ESP32 sending two int values, now I want to Thinger.io two multiply them and present in a new value inside a Dashboard Text/Value Widget.
Is there a way?
I have my ESP32 sending two int values, now I want to Thinger.io two multiply them and present in a new value inside a Dashboard Text/Value Widget.
Is there a way?
Hi @Leonardo
Data transformations are available through products or Node-RED plugin.
However, for this simple simple task, it’s easier to do the operation in the esp32 and send the 3 values
Yes, I know that I can manage inside the ESP32, but through time I want to update the values manipulation without the need to update the ESP32.
Do you have an exemple of how to do this math inside a product? I studied a bit, but couldn’t figure out how variables are managed inside the “Product Script”.
Hi @Leonardo
Given this example resource:
client["operands"] = [](iotmp::output& out) {
out["op1"] = rand() % 10;
out["op2"] = rand() % 10;
};
You can add an api resource in products with the following settings:
And the product function:
function multiply(payload) {
payload['result'] = payload.op1 * payload.op2;
return payload;
}
The operands resource will be extended to show also the result
: