Minor Ecobee changes (#3131)

* Update configuration check, ordering, and constants

* Make API key optional
This commit is contained in:
Fabian Affolter 2016-09-07 20:21:42 +02:00 committed by GitHub
parent 4d41c5cd0f
commit 1af5d4c8b8
2 changed files with 23 additions and 21 deletions

View File

@ -6,6 +6,7 @@ https://home-assistant.io/components/climate.ecobee/
""" """
import logging import logging
from os import path from os import path
import voluptuous as vol import voluptuous as vol
from homeassistant.components import ecobee from homeassistant.components import ecobee
@ -16,13 +17,15 @@ from homeassistant.const import (
from homeassistant.config import load_yaml_config_file from homeassistant.config import load_yaml_config_file
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
DEPENDENCIES = ['ecobee']
_LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
_CONFIGURING = {} _CONFIGURING = {}
_LOGGER = logging.getLogger(__name__)
ATTR_FAN_MIN_ON_TIME = 'fan_min_on_time'
DEPENDENCIES = ['ecobee']
SERVICE_SET_FAN_MIN_ON_TIME = 'ecobee_set_fan_min_on_time'
ATTR_FAN_MIN_ON_TIME = "fan_min_on_time"
SERVICE_SET_FAN_MIN_ON_TIME = "ecobee_set_fan_min_on_time"
SET_FAN_MIN_ON_TIME_SCHEMA = vol.Schema({ SET_FAN_MIN_ON_TIME_SCHEMA = vol.Schema({
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
vol.Required(ATTR_FAN_MIN_ON_TIME): vol.Coerce(int), vol.Required(ATTR_FAN_MIN_ON_TIME): vol.Coerce(int),

View File

@ -7,6 +7,7 @@ https://home-assistant.io/components/ecobee/
import logging import logging
import os import os
from datetime import timedelta from datetime import timedelta
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -15,14 +16,23 @@ from homeassistant.const import CONF_API_KEY
from homeassistant.loader import get_component from homeassistant.loader import get_component
from homeassistant.util import Throttle from homeassistant.util import Throttle
DOMAIN = "ecobee"
NETWORK = None
CONF_HOLD_TEMP = 'hold_temp'
REQUIREMENTS = [ REQUIREMENTS = [
'https://github.com/nkgilley/python-ecobee-api/archive/' 'https://github.com/nkgilley/python-ecobee-api/archive/'
'4856a704670c53afe1882178a89c209b5f98533d.zip#python-ecobee==0.0.6'] '4856a704670c53afe1882178a89c209b5f98533d.zip#python-ecobee==0.0.6']
_CONFIGURING = {}
_LOGGER = logging.getLogger(__name__)
CONF_HOLD_TEMP = 'hold_temp'
DOMAIN = 'ecobee'
ECOBEE_CONFIG_FILE = 'ecobee.conf'
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=180)
NETWORK = None
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({ DOMAIN: vol.Schema({
vol.Optional(CONF_API_KEY): cv.string, vol.Optional(CONF_API_KEY): cv.string,
@ -30,14 +40,6 @@ CONFIG_SCHEMA = vol.Schema({
}) })
}, extra=vol.ALLOW_EXTRA) }, extra=vol.ALLOW_EXTRA)
_LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
_CONFIGURING = {}
# Return cached results if last scan was less then this time ago.
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=180)
def request_configuration(network, hass, config): def request_configuration(network, hass, config):
"""Request configuration steps from the user.""" """Request configuration steps from the user."""
@ -97,7 +99,7 @@ class EcobeeData(object):
def update(self): def update(self):
"""Get the latest data from pyecobee.""" """Get the latest data from pyecobee."""
self.ecobee.update() self.ecobee.update()
_LOGGER.info("ecobee data updated successfully.") _LOGGER.info("Ecobee data updated successfully")
def setup(hass, config): def setup(hass, config):
@ -116,9 +118,6 @@ def setup(hass, config):
# Create ecobee.conf if it doesn't exist # Create ecobee.conf if it doesn't exist
if not os.path.isfile(hass.config.path(ECOBEE_CONFIG_FILE)): if not os.path.isfile(hass.config.path(ECOBEE_CONFIG_FILE)):
if config[DOMAIN].get(CONF_API_KEY) is None:
_LOGGER.error("No ecobee api_key found in config.")
return
jsonconfig = {"API_KEY": config[DOMAIN].get(CONF_API_KEY)} jsonconfig = {"API_KEY": config[DOMAIN].get(CONF_API_KEY)}
config_from_file(hass.config.path(ECOBEE_CONFIG_FILE), jsonconfig) config_from_file(hass.config.path(ECOBEE_CONFIG_FILE), jsonconfig)