[RE-RELEASE] EcoWitt and Wittboy Weather Stations And Sensors (Local)

That is an interesting bug. Seems like a minor typo in the code though, right?

private Boolean unitSystemIsMetric() {
  //
  // Return true if the selected unit system is metric
  //
  def isM = parent.unitSystemIsMetric()

-  if (ism == null)
+  if (isM == null)
     return false
  else return isM

  //return (getParent().unitSystemIsMetric());
}

That being said, it looks like the rest of the sensor code handles the null / falsiness of the unitSystemIsMetric() everywhere else just fine.

It looks like it's only the attributeUpdateLightningDistance which is explicitly comparing it to false rather than using the implicit falsiness of the value directly (like the other functions do). So just updating that one function's comparison would be enough too:

private Boolean attributeUpdateLightningDistance(String val, String attrib) {

  if (!val) val = "0";

  BigDecimal distance = val.toBigDecimal();
  String measure = "km";

  // Convert to imperial if requested
-  if (unitSystemIsMetric() == false) {
+  if (!unitSystemIsMetric()) {
    distance = convert_km_to_mi(distance);
    measure = "mi";
  }

  return (attributeUpdateNumber(distance, attrib, measure, 1));
}
2 Likes