From d3a4e21cb5731103bf4d6a1587b2fa190400e11c Mon Sep 17 00:00:00 2001 From: rianadon Date: Wed, 9 Jun 2021 05:06:24 -0700 Subject: [PATCH] Convert ecobee pressure to local units (#51379) * Convert ecobee pressure to local units * Round inHg to 2 places --- homeassistant/components/ecobee/weather.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/ecobee/weather.py b/homeassistant/components/ecobee/weather.py index 7774a6648a5..fc93ebffb95 100644 --- a/homeassistant/components/ecobee/weather.py +++ b/homeassistant/components/ecobee/weather.py @@ -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