[SOLVED] Need to multiply a temperature value by 10 without getting an extra decimal


I am trying to define a rule that will send a command to an item with temperatures represented like e.g. 230 for 23.0°C.

This is what I have done:

    rule "UpdatePopp1TemperatureItem"
    	Item Popp1_Temperature_ToBe received update
    	Popp1_V3.sendCommand((Popp1_Temperature_ToBe.state as Number) * 10)

All is ok when I change Popp1_Temperature_ToBe to 23 for example, but when I change it 17.5, instead of sending a command with 175, it sends 175.0 !

Can you please tell me what I’m doing wrong here?


In case it would be needed, my items look like this:

Number Popp1_V3 "Température - Popp1 [%.1f °C]" { zibase="VAR,3" }
Number Popp1_Temperature_ToBe "Température to be - Popp1 [%.1f °C]"

What are you trying to do, and what is the device you are trying to use?

If the device requires a temperature 10x the value (as I suspect from what you’ve posted) then really the binding should sort this out for you. Maybe I’m misinterpreting what you’re doing though…

eg if this is trying to set a temperature on a ZWave device, then I would consider this a bug in the zwave binding if you needed to set the temperature to 175 to get 17.5 degrees…

Hello Chris, thanks a lot for the super fast answer.

I’m trying to set thermostat setpoint value on a zwave valve (Popp). I use an old Zwave box called zibase that is not maintained anymore (and its binding is not maintained either…). I know this is not great, but this is what I have at the moment.

If I would just be able to send the command by taking the temperatures either like 17.5 and multiply it by 10 and get 175 and not 175.0, I would be all set but for some reason when I multiply 17.5 by 10, i get one extra digit after “.”…
When the set temp is like 23, the extra decimal is not added, because I believe as a starting point it is not there, so I really multiply 23 by 10 and not 23.0 by 10…

If I’m able to solve that, I have the full thing pretty much ok (I have tested by hardcoding the values in the send command and it works fine.

Does that make more sense?


Change this line:

Popp1_V3.sendCommand((Popp1_Temperature_ToBe.state as Number) * 10)


Popp1_V3.sendCommand(((Popp1_Temperature_ToBe.state as Number) * 10).intValue)

That will trim the decimal point and send your value as an integer.

Thanks a lot, bartus.