How to change Energy units from J to kWh

Hi,

After upgrade to 3.4 M5 Shelly EM3 change unit of Accumulated Total Power from kWh to J - how to change it ? I’m using influxdb persistence.

Thanks

1 Kilowatthour = 3600 Kilojoule

You can transform the item’s channel using a js-transformation
#nano /etc/openhab/transform/kWhtokJ.js
(function(i) {
var nVal= parseFloat(i) * 3600;
return nVal.toFixed(0)
})(input)

1 Like

see

from openHAB 3.4 onwards Number:xxx items now have a default UoM if none is given, in case of energy its Joule. You have to define your own UoM (Units of Measuerment) for all those item types, if you’re not using the defaults.

There was a ‘bug’ in the milestone release where channels which had %unit% displayed in the default unit. This was most visible with energy channels that displayed in J. Best to update to the released version. That should fix this issue.

Just for completeness, to define your own UoM, set the Item’s State Description Pattern with the unit desired.

Upgrade helped. Thanks. No need to define own UoM in this case.