Skip to content

Commit

Permalink
fix: ha actually shows all decimal places. lets round that
Browse files Browse the repository at this point in the history
  • Loading branch information
lhw committed Jun 1, 2024
1 parent fedb00e commit fbf792b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions aiocloudweather/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,45 @@ def decorator(func):
@unit(UnitOfTemperature.CELSIUS)
def fahrenheit_to_celsius(temp_f: float) -> float:
"""Convert Fahrenheit to Celsius."""
return (temp_f - 32) * 5.0 / 9.0
return round((temp_f - 32) * 5.0 / 9.0, 2)


@unit(UnitOfPressure.HPA)
def inhg_to_hpa(pressure: float) -> float:
"""Convert inches of mercury (inHg) to hectopascals (hPa)."""
return pressure * 33.864
return round(pressure * 33.864, 2)


@unit(UnitOfPrecipitationDepth.MILLIMETERS)
def in_to_mm(length: float) -> float:
"""Convert inches to millimeters (mm)."""
return length * 25.4
return round(length * 25.4, 2)


@unit(UnitOfSpeed.METERS_PER_SECOND)
def mph_to_ms(speed: float) -> float:
"""Convert miles per hour (mph) to meters per second (m/s)."""
return speed * 0.44704
return round(speed * 0.44704, 2)


@unit(UnitOfPressure.INHG)
def hpa_to_inhg(pressure: float) -> float:
"""Convert hectopascals (hPa) to inches of mercury (inHg)."""
return pressure * 0.02953
return round(pressure * 0.02953, 2)


@unit(UnitOfTemperature.FAHRENHEIT)
def celsius_to_fahrenheit(temp_c: float) -> float:
"""Convert Celsius to Fahrenheit."""
return temp_c * 9.0 / 5.0 + 32
return round(temp_c * 9.0 / 5.0 + 32, 2)


@unit(UnitOfPrecipitationDepth.INCHES)
def mm_to_in(length: float) -> float:
"""Convert millimeters (mm) to inches."""
return length * 0.0393701
return round(length * 0.0393701, 2)

@unit(UnitOfSpeed.MILES_PER_HOUR)
def ms_to_mph(speed: float) -> float:
"""Convert meters per second (m/s) to miles per hour (mph)."""
return speed * 2.23694
return round(speed * 2.23694, 2)

0 comments on commit fbf792b

Please sign in to comment.