Enriching device settings

Hi,

I have a water tank sensor that tells me the water level in a tank (in cm). In my homey driver i want to translate this into the amount of water stored in the tank, so i need to multiply the height reported by the number of liters per cm of water (computed from the tank capacity and height when full). In order to do this i need to store an editable setting somewhere against the device that stores this conversion factor.
The way I implemented this is to define a device settings in the driver.settings.compose.json file - which then exposes this setting via the Homey GUI. When the setting is updated, in the onSettings method I then use the setStoreValue API to store these settings. When I receive a level update from the device I retrieve the conversion factor using the getStoreValue and then multiply the reported value and set a new capability to store the amount of water in the tank.
This works, but I don’t think that is the best way to do this - is there a better way?

Sounds okay to me. If you really want to optimize, instead of using getStoreValue() every time you can load the value into an instance variable in your device’s onInit and update it when the setting is changed.

If you already have device setting, you use/read it directly. You don’t need to store it in device store in addition.

Yea - figured that, but was hoping to keep them out of settings as the driver is now attempting to send these to the device. It would be nice if there was a way to indicate that a setting was on the driver side only.