Fix wind speed change in NWS (#37222)

pull/37250/head
MatthewFlamm 2020-06-29 18:41:52 -04:00 committed by GitHub
parent b0942d86fe
commit 11debb1568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -190,17 +190,16 @@ class NWSWeather(WeatherEntity):
@property
def wind_speed(self):
"""Return the current windspeed."""
wind_m_s = None
wind_km_hr = None
if self.observation:
wind_m_s = self.observation.get("windSpeed")
if wind_m_s is None:
wind_km_hr = self.observation.get("windSpeed")
if wind_km_hr is None:
return None
wind_m_hr = wind_m_s * 3600
if self.is_metric:
wind = convert_distance(wind_m_hr, LENGTH_METERS, LENGTH_KILOMETERS)
wind = wind_km_hr
else:
wind = convert_distance(wind_m_hr, LENGTH_METERS, LENGTH_MILES)
wind = convert_distance(wind_km_hr, LENGTH_KILOMETERS, LENGTH_MILES)
return round(wind)
@property

View File

@ -60,7 +60,7 @@ EXPECTED_OBSERVATION_IMPERIAL = {
),
ATTR_WEATHER_WIND_BEARING: 180,
ATTR_WEATHER_WIND_SPEED: round(
convert_distance(10, LENGTH_METERS, LENGTH_MILES) * 3600
convert_distance(10, LENGTH_KILOMETERS, LENGTH_MILES)
),
ATTR_WEATHER_PRESSURE: round(
convert_pressure(100000, PRESSURE_PA, PRESSURE_INHG), 2
@ -74,9 +74,7 @@ EXPECTED_OBSERVATION_IMPERIAL = {
EXPECTED_OBSERVATION_METRIC = {
ATTR_WEATHER_TEMPERATURE: 10,
ATTR_WEATHER_WIND_BEARING: 180,
ATTR_WEATHER_WIND_SPEED: round(
convert_distance(10, LENGTH_METERS, LENGTH_KILOMETERS) * 3600
),
ATTR_WEATHER_WIND_SPEED: 10,
ATTR_WEATHER_PRESSURE: round(convert_pressure(100000, PRESSURE_PA, PRESSURE_HPA)),
ATTR_WEATHER_VISIBILITY: round(
convert_distance(10000, LENGTH_METERS, LENGTH_KILOMETERS)