Skip to content

Commit

Permalink
Fix wind speed change in NWS (home-assistant#37222)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewFlamm authored Jun 29, 2020
1 parent b0942d8 commit 11debb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 5 additions & 6 deletions homeassistant/components/nws/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,16 @@ def humidity(self):
@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
Expand Down
6 changes: 2 additions & 4 deletions tests/components/nws/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
),
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
Expand All @@ -74,9 +74,7 @@
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)
Expand Down

0 comments on commit 11debb1

Please sign in to comment.