Chart Y-axis and metric prefixes / UoM

I’m struggling with charts / analyzer disregarding the metric prefixes from the UoM configuration for the Item:

Number:Power    TotalPower    "Total power [%.2f kW]"

Even no luck when I manually set up a chart page and name the Y-axis “kW” in a hope that it will recognize the metrix prefix just like the UoM configuration for the Item:

    - component: oh-time-series
        gridIndex: 0
        item: TotalPower
        name: Total power
        type: line
        xAxisIndex: 0
        yAxisIndex: 0
    - component: oh-value-axis
        gridIndex: 0
        name: kW
    - component: oh-time-axis
        gridIndex: 0

This causes mainly two challenges:

  1. For typical power values in the tens of thousands watts, the Y-axis numbers takes up too much space and reduces readability
  2. Showing related Number:Energy items with its default units of “kWh” on the same Y-axis as Number:Power with its default units of “W” ends up with a factor of 1000 scaling error between them

For the second point one can question why Power defaults to “W” while Energy defaults to “kWh”, but I still appreciate that Energy at least does not defaults to “J” :slight_smile:

My understanding is that this simply is how it’s implemented and not really a bug. But I surely wish the implementation would consider UoM (or at least metric prefixes) also in charts. Tho this would probably need some consideration to not break the possibility to show Power and Energy on the same Y-axis :thinking:

openHAB version 4.1.2

There are a few things to note here:

  1. "Total power [%.2f kW]" sets how the Item is displayed in many places in the UI. It does not change the unit of the state that the Item actually carries and therefore what gets saved to the database. If you want the Item’s state to actually be kW instead of just converting the Item’s state to kW in some places in the UIs, you need to set the unit metadata on the Item to be what you want the Item to carry.

  2. UoM is implemented wholly on the server side. Charts are implemented wholly on the client side (i.e. in the browser) and there is no equivalent UoM library that can run on the client side. This means that changing the unit of the values charted to be different from what is stored is not technically feasible at this time.

If you set the unit metadata it doesn’t matter what the default is.