We had a similar requirement in the past and it was done using a synthetic variable, based on the formula available here, the readings of the tank level sensor indicated the level of liquid but the volume was calculated using the formula. Keep in mind that the synthetic variables editor allows mathematical expressions as indicated here.
When using the Ubifuncton, you may need to make an API request on a regular basis to obtain the last value make the calculations, and then send the value to a new variable.
Thanks Santiago - the formula is behind an intercom account and I don’t have intercom. I have seen several formulas for doing this, but would love to see what this one says. I’ll go ahead and use the synthetic variable then. I worry about using them too much.
On synthetics - I ASSUME that the LAST value on the stack is what is returned. I could not find a basic how-to or syntax for the synthetic variables - OR the language they use. Makes debug very hard.
Here is my synthetic variable calc - which is NOT validating:
length = 15000
height = 10000
radius = height / 2
rsquare = radius ** 2
specialheight = where( liquidheight > radius , height - liquidheight , radius - liquidheight )
thetaradians = 2 * arcos( specialheight / radius )
specialvolume = rsquare * ( thetaradians - sin( thetaradians )) * length / 2
volumemm3 = where( liquidheight > radius , ( rsquare * pi * length) - specialvolume , specialvolume )
volumegallons = volumemm3 * 0.00000026417
specialheight ## put here as a spoof so I could save the formula in the synth variable
Just an idea - it looks like your expression validator isn’t tracking that the result of the {{sensorreading}} is going through the arcos() function. If you put the value thetaradians at the end of the list of calculations, the validator will not validate. So specialheight is the last variable to validate.
This is an example of a similar calculation based on the formula found on the website. there the arccos() function is used just like suggested on the formula, for a more updated reference on synthetic variables please check this link. The value returned is indeed the last line.
We are glad that it works now and we can definitively update or documentation and perhaps post an example of a calculation for a tank’s volume.