Hello everyone,
I can’t seem to find the answer to this question, although it appears to have been covered a few times.
I’m still running with OH02, while I work on migrating to OH03 and learn what has changed. Using the BMWConnected Binding to access data from my wife’s Mini I have found a small problem, namely the fuel range which is calculated in Meters rather than Miles. It’s a simple conversion, but the results return with a decimal place. Manipulating this in the sitemap is easy enough, however I’d like to use the whole number within a number of rules.
Is there a way to remove the decimal point from a variable and update the item? For example if the item below
Car_Mini_Range
is 101540 meters the rule below will output 63.09418767942138. I’m not interesting in rounding up or down, I just want to remove everything after the decimal point and be left with the miles as in 63.
Number:Length Car_Mini_Range "Available Fuel Range" { channel="bmwconnecteddrive:CONV:73aee344:VINGOESHERE:range#fuel" }
Number Car_Mini_RangeMiles "Range [%.0f Miles]"
rule "Calculate Range - Mini Cooper"
when
Item Car_Mini_Range changed or
System started
then
val Number vRange = Car_Mini_Range.state
var long vMiles = new DecimalType(vRange / 1609)
logInfo(filename, "Cars: Sarah's Mini has {} Miles of range.", vMiles)
Car_Mini_RangeMiles.postUpdate(vMiles)
end