«
Rule languages supports OpenHAB units of measurement
type | name | state | pattern |
---|---|---|---|
Number:Temperature | NumberC | 23 | %.5f °C |
Number:Temperature | NumberF | 70 | %.5f °F |
Number | Dimensionless | 2 |
result = <convert_line>
logger.info("#{NumberC.id} is #{result.format('%.1f %unit%')} in Fahrenheit")
convert_line | |
---|---|
NumberC |ImperialUnits::FAHRENHEIT | |
NumberC |'°F' |
result = <convert_line>
logger.info("#{Dimensionless.id} is #{result.format('%.1f %unit%')} in Fahrenheit")
convert_line | |
---|---|
Dimensionless |ImperialUnits::FAHRENHEIT | |
Dimensionless |'°F' |
result = <code_line>
logger.info("Result is #{result.format('%.1f %unit%')}")
code_line | result | |
---|---|---|
NumberF * Dimensionless | 140.0 °F | |
NumberF / Dimensionless | 35.0 °F | |
Dimensionless * NumberF | 140.0 °F | |
2 * NumberF | 140.0 °F |
result = NumberC > NumberF
logger.info("Result is #{result}")
result = (NumberC |'°F') - (NumberF |'°F') < '4 °F'
logger.info("Result is #{result}")
result = <code_line>
logger.info("Result is #{result.is_a?(QuantityType) ? result.format('%.1f %unit%') : result}")
code_line | result | |
---|---|---|
unit('°F') { NumberC - NumberF < 4 } | true | |
unit('°F') { NumberC - '24 °C' < 4 } | true | |
unit('°F') { QuantityType.new('24 °C') - NumberC < 4 } | true | |
unit('°C') { NumberF - '20 °C' < 2 } | true | |
unit('°C') { NumberF - Dimensionless } | 19.1 °C | |
unit('°C') { NumberC + NumberF } | 44.1 °C | |
unit('°C') { NumberF - Dimensionless < 20 } | true | |
unit('°C') { Dimensionless + NumberC == 25 } | true | |
unit('°C') { 2 + NumberC == 25 } | true | |
unit('°C') { Dimensionless * NumberC == 46 } | true | |
unit('°C') { 2 * NumberC == 46 } | true | |
unit('°C') { ( (2 * (NumberF + NumberC)) / Dimensionless ) < 45 } | true | |
unit('°C') { [NumberC, NumberF, Dimensionless].min } | 2 |