I have a hardware knx temperature value like:
Number Weather_Pressure “Water pressure [%.1f Pa]” {knx=“1/1/63”}
Diplaying is the raw variable value:154992.2 Pa.
Really should be the value divided by 1000000 to display 1.55 Pa.
How should be created a rule or can be specified a format for diplaying the 1.55 value ?
Thanks.
Number Weather_Pressure "Water pressure (wrong) [%.1f Pa]" {knx="1/1/63"}
Number Weather_Pressure_corrected "Water pressure [%.1f Pa]"
your.rules
import java.math.BigDecimal
// uncomment on OH1:
// import org.openhab.core.library.types.DecimalType
rule CorrectPressure
when
Item Weather_Pressure changed
then
val BigDecimal corrected = (Weather_Pressure.state as DecimalType).toBigDecimal.movePointLeft(5)
Weather_Pressure_Corrected.postUpdate(new DecimalType(corrected))
end
items
Number Water_Pressure “Tlak vody (surovy) [%.1f Pa]” (Temperature, GF_Obyvacka) {knx=“1/1/63”}
Number Water_Pressure_corrected “Tlak vody [%.1f Pa]” (Temperature, GF_Obyvacka)
rules
// This rule will be used to divide raw value to format pressure
rule "Round water pressure"
when
Item Water_Pressure changed or
System started
then
var Number P = Water_Pressure.state as DecimalType / 100000
postUpdate(Water_Pressure_corrected, P)
end