How to overrule volume_set capability

I would like to overrule the volume_set capability to comply with the following in the UI and flow action screen.

min: -80
max: 12
step: 0.5
label/unit: “dB”

I tried this using capabilitiesoptions and using a custom json.compose for the action. However, for these settings I get -8000% - 1200% instead of -80 - 12dB in steps of 0.5.

How can I accomplish this?

Don’t do it.
For compatibility reasons I highly recommend keeping the percentage range definition for the volume.
Instead map to the devices target scale in the onSetCapability handler.

I agree with @Shakesbeard, I feel most users will understand the percent scale much more, especially as a dB scale should be logarithmic.

However, my first thought is it is something built into the volume slider to multiply by 100 as the normal 0 to 100% scale requires the value to be set between 0 and 1. Therefore, you will probably need to divide the value you set by 100 and multiply the returned value by 100.

Thanks for heb responses. I thought of using the 0-100% scale. However, the device uses -80 - 12dB scale. So when using the remote each increment is 0.5dB. When using the 0-100% scale this would be a loss of precision, because th dB scale has 186 steps en the other scale 100. Which means that each % would be 1 dB instead of 0.5dB.

Is the userfriendly 0-100% scale worth the lost precision? And is it clear enough for the user that it would see dB on the device screen and % in the homey UI.

Definitly. Only audiophiles would care about the details anyways. I highly doubt anyone will care about the slight loss in precision.

And it will spare a lot of trouble when working with other app logics volume stuff. Or the new auto generated set relative volume card and so on.