mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Add a configuration validation
All parameters are required
This commit is contained in:
parent
f182f7dccd
commit
6f1a25d8d6
@ -11,6 +11,7 @@ from datetime import timedelta
|
|||||||
from homeassistant.const import (CONF_API_KEY, CONF_USERNAME, CONF_PASSWORD,
|
from homeassistant.const import (CONF_API_KEY, CONF_USERNAME, CONF_PASSWORD,
|
||||||
TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
TEMP_CELCIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers import validate_config
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from homeassistant.util.temperature import celcius_to_fahrenheit
|
from homeassistant.util.temperature import celcius_to_fahrenheit
|
||||||
|
|
||||||
@ -37,6 +38,16 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=600)
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Get the NetAtmo sensor. """
|
""" Get the NetAtmo sensor. """
|
||||||
|
|
||||||
|
if not validate_config({DOMAIN: config},
|
||||||
|
{DOMAIN: [CONF_API_KEY,
|
||||||
|
CONF_USERNAME,
|
||||||
|
CONF_PASSWORD,
|
||||||
|
'secret_key']},
|
||||||
|
_LOGGER):
|
||||||
|
return None
|
||||||
|
|
||||||
|
import lnetatmo
|
||||||
|
|
||||||
SENSOR_TYPES['temperature'][1] = hass.config.temperature_unit
|
SENSOR_TYPES['temperature'][1] = hass.config.temperature_unit
|
||||||
unit = hass.config.temperature_unit
|
unit = hass.config.temperature_unit
|
||||||
authorization = lnetatmo.ClientAuth(config.get(CONF_API_KEY, None),
|
authorization = lnetatmo.ClientAuth(config.get(CONF_API_KEY, None),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user