[SOLVED] Need help on OH2 with postupdate rule

Hi i am running OH2 in Win 10.
I have a rule that updates the value of a item.
The Rule seems to be working but the value changes back immediately.

items is

Number Aquara_Press_Wohn "Luftdruck. Wohn. [%.2f hPa]" {channel="mihome:sensor_weather_v1:158d0002c78578:pressure"}

and the Rule

rule "kpa in Hpa" 
    when   
   		 Item Aquara_Press_Wohn received update
   		 
    then   
 			
			var Number hpa = Aquara_Press_Wohn.state as DecimalType*10

    		Aquara_Press_Wohn.postUpdate(hpa)
			logInfo("Rulesxxxxxxxxxxxxx", "Aquara_Press_Wohn value updated to: "+ hpa)
end

logs generates this output

14:15:25.461 [INFO ] [smarthome.event.ItemStateChangedEvent] - Aquara_Hum_Wohn changed from 38.49 to 38.59
14:15:25.461 [INFO ] [thome.model.script.Rulesxxxxxxxxxxxxx] - Aquara_Press_Wohn value updated to: 998.10
14:15:25.461 [INFO ] [smarthome.event.ItemStateChangedEvent] - Aquara_Press_Wohn changed from 99.81 to 998.10
14:15:25.496 [INFO ] [smarthome.event.ItemStateChangedEvent] - Aquara_Press_Schlaf changed from 99.81 to 99.84
14:15:25.496 [INFO ] [smarthome.event.ItemStateChangedEvent] - mihome_sensor_weather_v1_158d0002c78578_pressure changed 

Can someone plese help?

Basically you can’t do that.
The items reverts immediately because it gets updated by the device
What you need is another item:

Number Aquara_Press_Wohn "Luftdruck. Wohn. [%.2f kPa]" {channel="mihome:sensor_weather_v1:158d0002c78578:pressure"}
Number Aquara_Press_Wohn_hPa "Luftdruck. Wohn. [%.2f hPa]" 

And then the rule is:

rule "kpa in Hpa" 
when   
    Item Aquara_Press_Wohn received update
then   
    var Number hpa = (Aquara_Press_Wohn.state as Number) * 10
    Aquara_Press_Wohn_hPa.postUpdate(hpa)
    logInfo("Rulesxxxxxxxxxxxxx", "Aquara_Press_Wohn value updated to: " + hpa)
end
2 Likes

OK. It was a logic error .
Thanks for the hint.
It worked perfectly.

Thank you very much