Skip to content

Commit

Permalink
Fixed Rounding on Temperature values
Browse files Browse the repository at this point in the history
  • Loading branch information
“Bjarne committed Apr 16, 2019
1 parent 1fe1a63 commit 6b2d34f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pysmartweatherudp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, data, units):
self.type = 'air'
self.timestamp = data[0]
self.pressure = UnitConversion.pressure(self, data[1], units)
self.temperature = data[2]
self.temperature = round(data[2],1)
self.humidity = data[3]
self.lightning_count = data[4]
self.lightning_distance = UnitConversion.distance(self, data[5], units)
Expand Down Expand Up @@ -176,10 +176,10 @@ def getDewPoint(self, temperature, humidity):
def getWindChill(self, wind_speed, temperature):
""" Returns Wind Chill in Celcius """
if wind_speed < 1.3:
return temperature
return round(temperature,1)
else:
windKmh = wind_speed * 3.6
return round(13.12 + (0.6215 * temperature) - (11.37 * math.pow(windKmh, 0.16)) + (0.3965 * temperature * math.pow(windKmh, 0.16)), 2)
return round(13.12 + (0.6215 * temperature) - (11.37 * math.pow(windKmh, 0.16)) + (0.3965 * temperature * math.pow(windKmh, 0.16)), 1)

def getHeatIndex(self, temperature, humidity):
""" Returns Heat Index in Celcius """
Expand Down Expand Up @@ -222,4 +222,4 @@ def getFeelsLike(self, temperature, wind_chill, heat_index):
elif temperature < 10:
return wind_chill
else:
return temperature
return round(temperature,1)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.1.4',
version='0.1.5',

description='Receive data from Smart Weather via UDP',
long_description=" ".join(
Expand Down

0 comments on commit 6b2d34f

Please sign in to comment.