Skip to content

Commit

Permalink
Minor Ecobee changes (home-assistant#3131)
Browse files Browse the repository at this point in the history
* Update configuration check, ordering, and constants

* Make API key optional
  • Loading branch information
fabaff authored Sep 7, 2016
1 parent 4d41c5c commit 1af5d4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
13 changes: 8 additions & 5 deletions homeassistant/components/climate/ecobee.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import logging
from os import path

import voluptuous as vol

from homeassistant.components import ecobee
Expand All @@ -16,13 +17,15 @@
from homeassistant.config import load_yaml_config_file
import homeassistant.helpers.config_validation as cv

DEPENDENCIES = ['ecobee']
_LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
_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({
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
vol.Required(ATTR_FAN_MIN_ON_TIME): vol.Coerce(int),
Expand Down
31 changes: 15 additions & 16 deletions homeassistant/components/ecobee.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
from datetime import timedelta

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
Expand All @@ -15,29 +16,30 @@
from homeassistant.loader import get_component
from homeassistant.util import Throttle

DOMAIN = "ecobee"
NETWORK = None
CONF_HOLD_TEMP = 'hold_temp'

REQUIREMENTS = [
'https://github.com/nkgilley/python-ecobee-api/archive/'
'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({
DOMAIN: vol.Schema({
vol.Optional(CONF_API_KEY): cv.string,
vol.Optional(CONF_HOLD_TEMP, default=False): cv.boolean
})
}, 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):
"""Request configuration steps from the user."""
Expand Down Expand Up @@ -97,7 +99,7 @@ def __init__(self, config_file):
def update(self):
"""Get the latest data from pyecobee."""
self.ecobee.update()
_LOGGER.info("ecobee data updated successfully.")
_LOGGER.info("Ecobee data updated successfully")


def setup(hass, config):
Expand All @@ -116,9 +118,6 @@ def setup(hass, config):

# Create ecobee.conf if it doesn't exist
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)}
config_from_file(hass.config.path(ECOBEE_CONFIG_FILE), jsonconfig)

Expand Down

0 comments on commit 1af5d4c

Please sign in to comment.