Format Number Item

Hello,

i use Modbus Binding to get a Value from my PLC.

Number ist_Temperature_Raum_1 "Test2  [%.1f]" (EG_Flur) {modbus="slave1:0"}

The Value in the Modbus Register is 251. I need to convert it to 25.1 °C. How can i do this in the Items File ?

Kind Regards
Kay

1 Like

The following will give you the °C.

"Test2  [%.1f]°C"

Because the mobus Binding doesn’t appear to support transforms so you will have to create a proxy Item and a rule to divide it by 10.

Number TempProxy "Test2  [%.1f]°C" (EG_Flur)
Number ist_Temperature_Raum_1 {modbus="slave1:0"}

rule "Adjust Temp"
when
    Item ist_Temperature_Raum_1 received update
then
    TempProxy.sendCommand((istTemperature_Raum_1.state as DecimalType) / 10)
end

Put TempProxy on your sitemap.

2 Likes

Thanks for your Reply.

Kay

I have same problem from modbus, need to divide by 10.

If one have multiple numers, is it possible to use a function that can be called or do one have to re-write the same rule for every item?

You could create a lambda (i.e. function) but if all you are doing is dividing by 10 it will probably be less work and less lines of code to just do it inline in the rule.

Thanks for prompt reply as usual Rich!