Add SCAN_INTERVAL (#19186)

* Add SCAN_INTERVAL

* More clean-up
This commit is contained in:
Fabian Affolter 2018-12-11 14:12:27 +01:00 committed by Pascal Vizeli
parent eb4a44535c
commit 3e7b908a61

View File

@ -4,6 +4,7 @@ Weather component that handles meteorological data for your location.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
https://home-assistant.io/components/weather/ https://home-assistant.io/components/weather/
""" """
from datetime import timedelta
import logging import logging
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
@ -14,11 +15,6 @@ from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = []
DOMAIN = 'weather'
ENTITY_ID_FORMAT = DOMAIN + '.{}'
ATTR_CONDITION_CLASS = 'condition_class' ATTR_CONDITION_CLASS = 'condition_class'
ATTR_FORECAST = 'forecast' ATTR_FORECAST = 'forecast'
ATTR_FORECAST_CONDITION = 'condition' ATTR_FORECAST_CONDITION = 'condition'
@ -26,8 +22,8 @@ ATTR_FORECAST_PRECIPITATION = 'precipitation'
ATTR_FORECAST_TEMP = 'temperature' ATTR_FORECAST_TEMP = 'temperature'
ATTR_FORECAST_TEMP_LOW = 'templow' ATTR_FORECAST_TEMP_LOW = 'templow'
ATTR_FORECAST_TIME = 'datetime' ATTR_FORECAST_TIME = 'datetime'
ATTR_FORECAST_WIND_SPEED = 'wind_speed'
ATTR_FORECAST_WIND_BEARING = 'wind_bearing' ATTR_FORECAST_WIND_BEARING = 'wind_bearing'
ATTR_FORECAST_WIND_SPEED = 'wind_speed'
ATTR_WEATHER_ATTRIBUTION = 'attribution' ATTR_WEATHER_ATTRIBUTION = 'attribution'
ATTR_WEATHER_HUMIDITY = 'humidity' ATTR_WEATHER_HUMIDITY = 'humidity'
ATTR_WEATHER_OZONE = 'ozone' ATTR_WEATHER_OZONE = 'ozone'
@ -37,10 +33,17 @@ ATTR_WEATHER_VISIBILITY = 'visibility'
ATTR_WEATHER_WIND_BEARING = 'wind_bearing' ATTR_WEATHER_WIND_BEARING = 'wind_bearing'
ATTR_WEATHER_WIND_SPEED = 'wind_speed' ATTR_WEATHER_WIND_SPEED = 'wind_speed'
DOMAIN = 'weather'
ENTITY_ID_FORMAT = DOMAIN + '.{}'
SCAN_INTERVAL = timedelta(seconds=30)
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the weather component.""" """Set up the weather component."""
component = hass.data[DOMAIN] = EntityComponent(_LOGGER, DOMAIN, hass) component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
await component.async_setup(config) await component.async_setup(config)
return True return True