OH 4.0.1 - KNX - Unit of Measurement - where to do what

I am still trying to fully understand where to do what kind of setting.
According to the KNX Binding documentation for OH 4.0.1 Unit of Measurement (UoM) is fully supported, which is great.

The number channel is fully supporting this as well, but has the Default DTP 9.001.
I have some KNX actors which return the consumed energy as DataType DTP 12.001 (4 byte unsigned integer).

As an end result I would like to see the consumed kW/h on my sidemap.
My current (old OH 3.4.4) channel definition is like this:

Type number        : EnergieVerbrauch_EG_Flur_LichtDecke 		"Verbrauch Flur EG Licht Decke:    [%.1f W] "         [ ga="12.001:<11/1/0"  ]

… and the item is defined like this:

Number EnergieVerbrauch_EG_Flur_LichtDecke 		"Verbrauch Flur EG Licht Decke:    [%.1f W] " <energy>	(Stromverbrauch) { channel="knx:device:bridge:Energie_Device:EnergieVerbrauch_EG_Flur_LichtDecke" }

This currently returns me “26801.0” = which could be 26.8 kWh

I now wonder if I need to change my Channel definition or keep it the same. Is there a way to tell the Channel to calculate it in kWh instead of Wh

Do I change my item like this:

Number:Energy EnergieVerbrauch_EG_Flur_LichtDecke 		"Verbrauch Flur EG Licht Decke:    [%.1f %unit%] " <energy>	(Stromverbrauch) { channel="knx:device:bridge:Energie_Device:EnergieVerbrauch_EG_Flur_LichtDecke" }

… and all is fine?
(I did not try out as I have some charts showing values already and I am not sure if I mess them up when I experiment with this.)

Thanks for helping me understand the concept better.

Does this help?
https://github.com/openhab/openhab-addons/issues/4490

Not really … or I don’t get what you try to tell.
I understand the idea of transforming something.

Well you either tansform what you get from the channel as is. Now does the group adress in ets is defined and displayed ? Show what’s inside ets group adress. And then we go from there.

Sorry, but you try to resolve the kWh vs Wh issue, which is my second thing to do. the main topic I was interested in is if the Channel definition has to change or stays the same.
For the item I meanwhile found that I need to set it up like this:

Number:Energy EnergieVerbrauch_EG_Flur_LichtDecke_Test	"Test Verbrauch Flur EG Licht Decke:    [%.1f %unit%] " <energy> { channel="knx:device:bridge:Energie_Device:EnergieVerbrauch_EG_Flur_LichtDecke", unit="Wh" }

to get it back in Wh and yes with that I could now work on a transformation or something to make it kWh.
Still I wonder if the Channel itself needs to contain a definition of the UoM, which then would allow me maybe to define unit=“kWh” on item level to auto convert it from Wh to kWh? (Just a wild guess.)

It’s not very complex, but there are some caveats when it comes to knx and UoM (at least for now and these are my experiences :slight_smile: )

First, create a number channel:

Type number : EnergieVerbrauch_EG_Flur_LichtDecke "Verbrauch Flur EG Licht Decke" [ ga="12.001:<11/1/0"  ]

Maybe consider not to duplicate information (here "EnergieVerbrauch, as it’s already set through the thing id)
Please be aware that the label of the channel is static. It makes no sense to add a state format, as it won’t be used at all.
Now, the DPT is set to 12.001, which is dimensionless. I’m pretty sure this is the wrong DPT, please tell us about the device. Wh is 13.010 (both 12 and 13 are 4 Btyte values, but 12 is unsigned and 13 is signed, so please take a deeper look at it).

Now for the item:

Number:Energy EnergieVerbrauch_EG_Flur_LichtDecke "Verbrauch Flur EG Licht Decke" <energy> (Stromverbrauch) { channel="knx:device:bridge:Energie_Device:EnergieVerbrauch_EG_Flur_LichtDecke", unit="Wh", stateDescription=""[pattern="%.1f Wh"] }  

So it’s vital to set the unit parameter (this is how the value is stored within the Item itself) AND the stateDescription pattern (this is how the Item will present its status in the UI).
With most bindings, you don’t need to set the pattern, as it will be set automagically by openHAB, but for knx you’ll have to. But afaik you do not need to set the label format any longer.

1 Like

Thanks for the feedback @Udo_Hartmann. This is very helpful.
I am using a Merten 647895 Actor in this case. The documentation says
"
Der Energieverbrauch kann in Wh oder Ws(J) gesendet werden. Für Wh wird ein 4 Byte ohne Vorzeichen und für Ws(J) wird 4 Byte Gleitkomma Objekt verwendet.
"
In ETS on the Parameter tab you can choose between Ws(J) and Wh -


There is says DPT 12.001
This is Programversion 1.1 of the actors ETS application program.
As the description says unsigned and the ETS also points to DPT 12.001 I guess this is the correct DPT at least from KNX bus point of view.
I’ll do the enhancement of the item definition according to your explanation.

Shame on Merten, then :slight_smile: there is no Wh unit defined in DPT 12 - at least knx System Specifications Version 02.02.01 from 2021-05-27 do not know about such a subDPT.

afaik the unit should be used even if the unit delivered from the channel does not match, so in theory it should work anyway…