Converting a Watt Channel to KwH without rules

Hi All

Is this possible? I have a device which is using about 900 watts, which I’d prefer to display as 0.9kWh

Number AeonSocket6Num1  "Garage Miner Socket - Current Consumption [%.1f kW]"      (gAllSwitchUsage,gEnergyRealTime)                               { channel="zwave:device:1a3feba2:node11:meter_watts" }

It refuses to do so! Is there a way to do this within the item ?


See How to change the item's UoM in MainUI?
Units Of Measurement | openHAB

You have defined your Item as a plain Number type, so you won’t get any of the UoM features like auto conversion.
You should examine the type of the channel you have linked it to, and try to link like-for-like.

If you must use a Number -

For display only, use a transformation in the [state presentation] field.

Number AeonSocket6Num1  "Garage Miner Socket - Current Consumption [JS(divide1000.js):%s kW]" ....

You’ll find example javascripts to put in your transform folder in this forum.


Thanks Rossko, yep in the mean time I found some info on the forum, i’ve added Energy/Power where needed.

Do the transformation states effect what would be displayed in grafana for example? or only in the UIs

Yes, because they have been “hijacked” from their display-only role to also provide the Item with a default unit, when given.
This affects persistence, and so affects charting. It’s all a bit clumsy in this area.
Bottom line is to pick your type/unit early then don’t fiddle with it, or you will ruin your persistence history.

1 Like

OK great! Will fiddle with this tomorrow, some items report in watts (with VERY large numbers) - kw seems more logical