Scale item directly in items file


I’m trying to scale a value of an item in my sitemap. This can be done using a rule which works fine.
However I was hoping that somehow it would be possible to scale the value directly in the items file.
This is the basic item:

Number nCpuLoad_1_minute "Load (1 min)" <none> (gSystem) { channel="systeminfo:computer:raspi:cpu#load1" }

Now I would like to add another item that has the value of the basic item multiplied by 100:

Number nCpuLoad_1_minute_scaled "Load (1 min) scaled" <none>          (gSystem)

Is there a way to scale the value of nCpuLoad_1_minute_scaled directly in the items file?

Thanks for looking into this.

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Buster
    • Java Runtime Environment: Zulu 1.8.0_302
    • openHAB version: 2.5.12

You can add a transformation to show the value of the Item scaled. You probably need to use the JS transformation which means you’ll have to put it in a separate .js file. The Scale transformation doesn’t do what you are after here.

You could modify the value coming from the channel by applying a profile. But here again you’d need to use the transform profile with a JS transformation which puts the actual multiplication in another file.

So the short answer is no, you can’t do it wholly within the .items file. You’ll either need a JS transformation or you’ll need a rule.

NOTE: OH 2.5 does not have the the same set of profiles as are available in OH 3. Make sure you look at the OH 2.5 version of the docs.

1 Like

I wrote recently for my own use very basic scale profile (which works also with quantities): ScaleProfile, maybe some day similar thing will come into openHAB core without pulling gain/offset profile from modbus binding? :wink:

Anyhow, above can be easily ported to OH 2.5 where APIs are pretty much the same.


If it really is just that, leave your Item alone altogether.
Add another sitemap widget to include your for-display transformation.

Text item=nCpuLoad_1_minute label="scaled [JS(mutiply100.js):%s]" 

Bu if you scale to a real Item you also get persistence. charting etc. available.

Not documented, but noteworthy here; the transform profile will not work with Number type Items in OH2.

1 Like