mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Add schema (#2226)
This commit is contained in:
parent
9a7ea72fa0
commit
f69c900977
@ -7,7 +7,12 @@ https://home-assistant.io/components/sensor.openweathermap/
|
|||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.const import CONF_API_KEY, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.const import (CONF_API_KEY, TEMP_CELSIUS, TEMP_FAHRENHEIT,
|
||||||
|
CONF_PLATFORM, CONF_LATITUDE, CONF_LONGITUDE,
|
||||||
|
CONF_MONITORED_CONDITIONS)
|
||||||
|
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
|
||||||
|
|
||||||
@ -24,6 +29,15 @@ SENSOR_TYPES = {
|
|||||||
'snow': ['Snow', 'mm']
|
'snow': ['Snow', 'mm']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(CONF_PLATFORM): 'openweathermap',
|
||||||
|
vol.Required(CONF_API_KEY): vol.Coerce(str),
|
||||||
|
vol.Optional(CONF_MONITORED_CONDITIONS, default=[]):
|
||||||
|
[vol.In(SENSOR_TYPES.keys())],
|
||||||
|
vol.Optional(CONF_LATITUDE): cv.latitude,
|
||||||
|
vol.Optional(CONF_LONGITUDE): cv.longitude
|
||||||
|
})
|
||||||
|
|
||||||
# Return cached results if last scan was less then this time ago.
|
# Return cached results if last scan was less then this time ago.
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
|
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user