What I want to achieve with the distance sensor is to monitor the amount of fluid level in a tank. What I get is a distance reading to the surface of the fluid. So I need to do some calculations:
($TANK_HEIGHT - $SENSOR_READING) x CONSTANT
to get the amount of fluid in the tank.
Where is the typical place to do such a thing? Should I modify the Payload Decoder or is there any other place to do this kind of stuff?
What do you mean by “receive the sensors reading in Cayenne”?
Are the sensor values encoded using the Cayenne format? Or are you watching the sensor values in a “Cayenne” dashboard or something like that?
In my personal opinion, the role of TTN should be primarily a data transport mechanism, to get the data from your node to your backend. I would put any validation, calculations, interpretations, etc in the backend application.
I can see a use case for the payload decoder to hide small differences in payload format, that (for example) occur because of historical reasons, different firmware versions in the field, etc.
But in my opinion it’s a mostly avoidable piece of software in the chain. It just adds extra work in version control, deployment, documentation, etc.