Decimal places in oh-stepper-item

Hi,
I’d like to have more decimal places with an oh-stepper-item than it provides.
The definition below results in a format xx.y to be shown inside the field inbetween “+” and “-” and I haven’t found out how to tell it to use 2 decimal places. Anyone, please ?
The step: definition meanwhile seems to apply I need to click several times before the shown value increases.
The stateDescription (metadata) pattern of the item is %.4f €/kWh but does not seem to affect this.


component: oh-stepper-item
config:
  style:
    font-size: 0.8em
  autorepeat: true
  icon: iconify:material-symbols:euro
  item: dynTarifBasispreis
  raised: true
  max: 200
  min: 0
  step: 0.01
  title: Basispreis dynamischer Tarif ct/kWh
1 Like

The f7-stepper has a property to provide a function that formats the displayed value, however, the oh version writes that explicitly and doesn’t process a user supplied value. So I don’t think there’s any way of controlling that format directly.

It is strange, however, that the displayed number of decimals doesn’t match the number of decimals on the step property because that is exactly what the oh version’s value format function is supposed to do:

Presumably, this setup is specifically intended to prevent the exact behavior you are seeing with multiple clicks required to see an actual change in the value.

I don’t think that the stateDescription of the item is supposed to play a role here, but I wonder if UoM conversions are interfering somehow.

EDIT: sorry I had missed to put up the code, here it is.

@mstormi i was thinking of creating a bug because of this topic. Can you define a “oh point something” value for the stepping?? I’m on 3.3 R4, and I can only put whole numbers. 0.5 or similar, is a no go :confused:

I don’t think there’s anything wrong with your configuration. Now that I look more carefully, I think you’ve actually found a bug.

Looks to me like the return value on the toStepFixed referenced above should be

parseFloat(Number(value).toFixed(nbDecimals.length))

I’m not in a position where I can put in even a simple PR for this at the moment but you could certainly file this on the webUI repo.