[OH3] Binding Modbus | Modbus Data - Transformation HowTo Output Number:Power?

i just migrate my openhab 2.5 instance to OH3, the OH2.5 run many years and i did not used the unit feature consequent. the migration ow should be a good reason to introduce it and use it.

i have some modbus devices directly supported by the modbus / sunspec binding and i have some device not directly supported. for the not directly supported devices i use the generic modbus bindings/things (Poller / Data)

Modbus/Data maps the Modbus Value to different datatyps, e.g. Number ho do i transform that to Number:Power ?

Without that transformation my group aggregations based on Number:Power seems to fail

I already searched in the forum more or less found mqtt transformation, they are support by the GUI, how do i add the dimension to value with a transformation script ?

needed Transformation:

Value → Value Unit

350 → 350 Watt and how to define the result as Number:Power ?

Does someone has already such a script, does not seem to be compicated or point my to the right place ?

thanks a lot!

You can do it like this

worked perfect!

thanks a lot!

By way of explanation what is actually happening;
You should post ‘quantities’ like “200 W” to a quantity type Item like Number:Power.
Posting just “200” would go wrong.
Unless …
you give the Item a default unit, like “W”. Then if you post just “200” the framework will make it into “200 W”.
There is no special place to assign a default unit to an Item
it will use a unit found in metadata ‘pattern’ (which should really only be about display) as a default.

It’s a sort of historical quirk.

The Modbus binding will have a profile allowing designation of units, but it’s not in general release yet.

you are talking about: