Skip to content

Commit

Permalink
v0.0.16 fixing #17 and removing units in attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenterheerdt committed May 27, 2020
1 parent ee6feb0 commit d7f7885
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/smart_irrigation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DOMAIN = "smart_irrigation"
NAME = "Smart Irrigation"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.15"
VERSION = "0.0.16"

ISSUE_URL = "https://github.com/jeroenterheerdt/HASmartIrrigation/issues"

Expand Down
21 changes: 11 additions & 10 deletions custom_components/smart_irrigation/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ def get_precipitation(self, data):
self.snow = float(data["snow"])
_LOGGER.info("rain: {}, snow: {}".format(self.rain, self.snow))
retval = self.rain + self.snow
if retval.count(".") > 1:
retval = retval.split(".")[0] + "." + retval.split(".")[1]
if isinstance(retval, str):
if retval.count(".") > 1:
retval = retval.split(".")[0] + "." + retval.split(".")[1]
retval = float(retval)
return retval

Expand Down Expand Up @@ -357,7 +358,7 @@ def get_evapotranspiration(self, d):
)
return fao56

def show_liter_or_gallon(self, value, show_unit=True):
def show_liter_or_gallon(self, value, show_unit=False):
"""Return nicely formatted liters or gallons."""
if value is None:
return "unknown"
Expand All @@ -373,7 +374,7 @@ def show_liter_or_gallon(self, value, show_unit=True):
retval = retval + f" {UNIT_OF_MEASUREMENT_GALLONS}"
return retval

def show_liter_or_gallon_per_minute(self, value, show_unit=True):
def show_liter_or_gallon_per_minute(self, value, show_unit=False):
"""Return nicely formatted liters or gallons."""
if value is None:
return "unknown"
Expand All @@ -389,7 +390,7 @@ def show_liter_or_gallon_per_minute(self, value, show_unit=True):
retval = retval + f" {UNIT_OF_MEASUREMENT_GPM}"
return retval

def show_mm_or_inch(self, value, show_unit=True):
def show_mm_or_inch(self, value, show_unit=False):
"""Return nicely formatted mm or inches."""
if value is None:
return "unknown"
Expand All @@ -409,7 +410,7 @@ def show_mm_or_inch(self, value, show_unit=True):
retval = retval + f" {UNIT_OF_MEASUREMENT_INCHES}"
return retval

def show_mm_or_inch_per_hour(self, value, show_unit=True):
def show_mm_or_inch_per_hour(self, value, show_unit=False):
"""Return nicely formatted mm or inches per hour."""
if value is None:
return "unknown"
Expand All @@ -428,7 +429,7 @@ def show_mm_or_inch_per_hour(self, value, show_unit=True):
retval = retval + f" {UNIT_OF_MEASUREMENT_INCHES_HOUR}"
return retval

def show_m2_or_sq_ft(self, value, show_unit=True):
def show_m2_or_sq_ft(self, value, show_unit=False):
"""Return nicely formatted m2 or sq ft."""
if value is None:
return "unknown"
Expand All @@ -444,7 +445,7 @@ def show_m2_or_sq_ft(self, value, show_unit=True):
retval = retval + f" {UNIT_OF_MEASUREMENT_SQ_FT}"
return retval

def show_percentage(self, value, show_unit=True):
def show_percentage(self, value, show_unit=False):
"""Return nicely formatted percentages."""
if value is None:
return "unknown"
Expand All @@ -455,7 +456,7 @@ def show_percentage(self, value, show_unit=True):
else:
return retval

def show_seconds(self, value, show_unit=True):
def show_seconds(self, value, show_unit=False):
"""Return nicely formatted seconds."""
if value is None:
return "unknown"
Expand All @@ -464,7 +465,7 @@ def show_seconds(self, value, show_unit=True):
else:
return value

def show_minutes(self, value, show_unit=True):
def show_minutes(self, value, show_unit=False):
"""Return nicely formatted minutes."""
if value is None:
return "unknown"
Expand Down

0 comments on commit d7f7885

Please sign in to comment.