mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Update yahooweather 0.8 / change request time (#3352) [Breaking change]
This commit is contained in:
parent
727b756054
commit
b78e98702a
@ -11,26 +11,28 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, CONF_MONITORED_CONDITIONS, STATE_UNKNOWN)
|
TEMP_CELSIUS, CONF_MONITORED_CONDITIONS, CONF_NAME, STATE_UNKNOWN)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
REQUIREMENTS = ["yahooweather==0.7"]
|
REQUIREMENTS = ["yahooweather==0.8"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_FORECAST = 'forecast'
|
CONF_FORECAST = 'forecast'
|
||||||
CONF_WOEID = 'woeid'
|
CONF_WOEID = 'woeid'
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
|
DEFAULT_NAME = 'Yweather'
|
||||||
|
|
||||||
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=600)
|
||||||
|
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
'weather_current': ['Current', None],
|
'weather_current': ['Current', None],
|
||||||
'weather': ['Condition', None],
|
'weather': ['Condition', None],
|
||||||
'temperature': ['Temperature', "temperature"],
|
'temperature': ['Temperature', "temperature"],
|
||||||
'temp_min': ['Temperature', "temperature"],
|
'temp_min': ['Temperature min', "temperature"],
|
||||||
'temp_max': ['Temperature', "temperature"],
|
'temp_max': ['Temperature max', "temperature"],
|
||||||
'wind_speed': ['Wind speed', "speed"],
|
'wind_speed': ['Wind speed', "speed"],
|
||||||
'humidity': ['Humidity', "%"],
|
'humidity': ['Humidity', "%"],
|
||||||
'pressure': ['Pressure', "pressure"],
|
'pressure': ['Pressure', "pressure"],
|
||||||
@ -39,6 +41,7 @@ SENSOR_TYPES = {
|
|||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_WOEID, default=None): cv.string,
|
vol.Optional(CONF_WOEID, default=None): cv.string,
|
||||||
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_FORECAST, default=0):
|
vol.Optional(CONF_FORECAST, default=0):
|
||||||
vol.All(vol.Coerce(int), vol.Range(min=0, max=5)),
|
vol.All(vol.Coerce(int), vol.Range(min=0, max=5)),
|
||||||
vol.Required(CONF_MONITORED_CONDITIONS, default=[]):
|
vol.Required(CONF_MONITORED_CONDITIONS, default=[]):
|
||||||
@ -53,6 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
unit = hass.config.units.temperature_unit
|
unit = hass.config.units.temperature_unit
|
||||||
woeid = config.get(CONF_WOEID)
|
woeid = config.get(CONF_WOEID)
|
||||||
forecast = config.get(CONF_FORECAST)
|
forecast = config.get(CONF_FORECAST)
|
||||||
|
name = config.get(CONF_NAME)
|
||||||
|
|
||||||
# convert unit
|
# convert unit
|
||||||
yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F
|
yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F
|
||||||
@ -86,7 +90,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
dev = []
|
dev = []
|
||||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||||
dev.append(YahooWeatherSensor(yahoo_api, forecast, variable))
|
dev.append(YahooWeatherSensor(yahoo_api, name, forecast, variable))
|
||||||
|
|
||||||
add_devices(dev)
|
add_devices(dev)
|
||||||
|
|
||||||
@ -95,9 +99,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class YahooWeatherSensor(Entity):
|
class YahooWeatherSensor(Entity):
|
||||||
"""Implementation of an Yahoo! weather sensor."""
|
"""Implementation of an Yahoo! weather sensor."""
|
||||||
|
|
||||||
def __init__(self, weather_data, forecast, sensor_type):
|
def __init__(self, weather_data, name, forecast, sensor_type):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._client = 'Weather'
|
self._client = name
|
||||||
self._name = SENSOR_TYPES[sensor_type][0]
|
self._name = SENSOR_TYPES[sensor_type][0]
|
||||||
self._type = sensor_type
|
self._type = sensor_type
|
||||||
self._state = STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
|
@ -511,7 +511,7 @@ xboxapi==0.1.1
|
|||||||
xmltodict==0.10.2
|
xmltodict==0.10.2
|
||||||
|
|
||||||
# homeassistant.components.sensor.yweather
|
# homeassistant.components.sensor.yweather
|
||||||
yahooweather==0.7
|
yahooweather==0.8
|
||||||
|
|
||||||
# homeassistant.components.zeroconf
|
# homeassistant.components.zeroconf
|
||||||
zeroconf==0.17.6
|
zeroconf==0.17.6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user