mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Update yweather.py (#8820)
Fix missing weather unit support. Move some weather code to their correct classes.
This commit is contained in:
parent
96f8c37dcd
commit
77cdc833f0
@ -37,16 +37,16 @@ CONDITION_CLASSES = {
|
|||||||
'fog': [19, 20, 21, 22, 23],
|
'fog': [19, 20, 21, 22, 23],
|
||||||
'hail': [17, 18, 35],
|
'hail': [17, 18, 35],
|
||||||
'lightning': [37],
|
'lightning': [37],
|
||||||
'lightning-rainy': [38, 39, 47],
|
'lightning-rainy': [3, 4, 38, 39, 47],
|
||||||
'partlycloudy': [44],
|
'partlycloudy': [44],
|
||||||
'pouring': [40, 45],
|
'pouring': [40, 45],
|
||||||
'rainy': [9, 11, 12],
|
'rainy': [9, 11, 12],
|
||||||
'snowy': [8, 13, 14, 15, 16, 41, 42, 43],
|
'snowy': [8, 13, 14, 15, 16, 41, 42, 43],
|
||||||
'snowy-rainy': [5, 6, 7, 10, 46],
|
'snowy-rainy': [5, 6, 7, 10, 46],
|
||||||
'sunny': [32, 33, 34],
|
'sunny': [32, 33, 34, 25, 36],
|
||||||
'windy': [24],
|
'windy': [24],
|
||||||
'windy-variant': [],
|
'windy-variant': [],
|
||||||
'exceptional': [0, 1, 2, 3, 4, 25, 36],
|
'exceptional': [0, 1, 2],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,16 +86,17 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
for condi in condlst:
|
for condi in condlst:
|
||||||
hass.data[DATA_CONDITION][condi] = cond
|
hass.data[DATA_CONDITION][condi] = cond
|
||||||
|
|
||||||
add_devices([YahooWeatherWeather(yahoo_api, name)], True)
|
add_devices([YahooWeatherWeather(yahoo_api, name, unit)], True)
|
||||||
|
|
||||||
|
|
||||||
class YahooWeatherWeather(WeatherEntity):
|
class YahooWeatherWeather(WeatherEntity):
|
||||||
"""Representation of Yahoo! weather data."""
|
"""Representation of Yahoo! weather data."""
|
||||||
|
|
||||||
def __init__(self, weather_data, name):
|
def __init__(self, weather_data, name, unit):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._data = weather_data
|
self._data = weather_data
|
||||||
|
self._unit = unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -119,7 +120,7 @@ class YahooWeatherWeather(WeatherEntity):
|
|||||||
@property
|
@property
|
||||||
def temperature_unit(self):
|
def temperature_unit(self):
|
||||||
"""Return the unit of measurement."""
|
"""Return the unit of measurement."""
|
||||||
return TEMP_CELSIUS
|
return self._unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pressure(self):
|
def pressure(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user