Convert ecobee pressure to local units (#51379)

* Convert ecobee pressure to local units

* Round inHg to 2 places
This commit is contained in:
rianadon 2021-06-09 05:06:24 -07:00 committed by GitHub
parent c21895facb
commit d3a4e21cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,8 +12,9 @@ from homeassistant.components.weather import (
ATTR_FORECAST_WIND_SPEED,
WeatherEntity,
)
from homeassistant.const import TEMP_FAHRENHEIT
from homeassistant.const import PRESSURE_HPA, PRESSURE_INHG, TEMP_FAHRENHEIT
from homeassistant.util import dt as dt_util
from homeassistant.util.pressure import convert as pressure_convert
from .const import (
_LOGGER,
@ -113,7 +114,11 @@ class EcobeeWeather(WeatherEntity):
def pressure(self):
"""Return the pressure."""
try:
return int(self.get_forecast(0, "pressure"))
pressure = self.get_forecast(0, "pressure")
if not self.hass.config.units.is_metric:
pressure = pressure_convert(pressure, PRESSURE_HPA, PRESSURE_INHG)
return round(pressure, 2)
return round(pressure)
except ValueError:
return None