How to use the calculated attributes tab?

MarcusRosendo6 months ago

Hy!

I have a doubt. How to use the calculated attributes tab?
In my aplication, my suntech send the signal in third input pin. This input pin have of the ADC function. So, how do I insert the equation in calculated attributes tab and where I see the result of the equation?

Thank you very much in advance.

Anton Tananaev6 months ago

Have you read the documentation? What is not clear specifically?

https://www.traccar.org/computed-attributes/

MarcusRosendo6 months ago

Yes, I read. I followed the step by step and it doesn't work.

When I select which attribute tath I need, the type of this attribute, is automactically selected to boolean type. But I don't need this type, I need to number type. Another problem I came across is that when I go to designate this calculated attribute to my device, I can't save this function because there is no save option in the tab.

My equation is this:

(io7 != null && !io7.isEmpty()) ? java.lang.Math.round(0.1856 * (
        java.lang.Math.pow(Double.parseDouble(io7), 6)
        - 4.8729 * java.lang.Math.pow(Double.parseDouble(io7), 5)
        + 51.867 * java.lang.Math.pow(Double.parseDouble(io7), 4)
        - 285.27 * java.lang.Math.pow(Double.parseDouble(io7), 3)
        + 853.52 * java.lang.Math.pow(Double.parseDouble(io7), 2)
        - 1305 * Double.parseDouble(io7)
        + 793.79
    ) / 100.0) : null;

I left an image attached so you can see what I'm doing.

Tank you so much.

Captura de tela 2024-06-26 110223.png

Anton Tananaev6 months ago

You cannot change types for our standard attributes. Also your expression is almost definitely invalid.

MarcusRosendo6 months ago

So, what I need to do?

Anton Tananaev6 months ago

Not sure because I don't know what you're trying to achieve.

MarcusRosendo6 months ago

I need to calculate the coolant temperature. In ADC input, I get a voltage value in this input. This input variable is an "io7" from the suntech protocol. So, I need to get this variable ("io7") and calculate the coolant temperature. The function that calculates the temperature is this:

y = 0,1856*pow(x; 6) - 4,8729*pow(x; 5) + 51,867*pow(x; 4) - 285,27*pow(x; 3) + 853,52*pow(x; 2) - 1305*pow(x) + 793,79.

How I inseart this function in calculated attribute tab?

Anton Tananaev6 months ago

It seems like you're confused about what the attribute value is for. It's the resulting attribute, as outlined in our documentation.