Only do unit conversion of met elevation when set in config entry (#88491)

convert met elevation unit only when it exists in config entry

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Chris Xiao 2023-02-20 16:46:13 -05:00 committed by GitHub
parent 30ebc6604f
commit 7a884a9d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,7 @@ class MetWeatherData:
self._coordinates: dict[str, str] | None = None
def set_coordinates(self) -> bool:
"""Weather data inialization - set the coordinates."""
"""Weather data initialization - set the coordinates."""
if self._config.get(CONF_TRACK_HOME, False):
latitude = self.hass.config.latitude
longitude = self.hass.config.longitude
@ -158,15 +158,14 @@ class MetWeatherData:
latitude = self._config[CONF_LATITUDE]
longitude = self._config[CONF_LONGITUDE]
elevation = self._config[CONF_ELEVATION]
if not self._is_metric:
elevation = int(
round(
DistanceConverter.convert(
elevation, UnitOfLength.FEET, UnitOfLength.METERS
if not self._is_metric:
elevation = int(
round(
DistanceConverter.convert(
elevation, UnitOfLength.FEET, UnitOfLength.METERS
)
)
)
)
coordinates = {
"lat": str(latitude),