Diefferson Koderer Môro 14be60e5bf Move imports in nuheat component (#28038)
* Move imports in nuheat component

* Fix tox tests

* Fix tox tests

* Update tests/components/nuheat/test_init.py

@Balloob suggested the change because direct replacement, the mock would never be reverted and impact the other tests.

Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
2019-10-23 08:30:38 -07:00

43 lines
1.1 KiB
Python

"""Support for NuHeat thermostats."""
import logging
import nuheat
import voluptuous as vol
from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers import config_validation as cv, discovery
_LOGGER = logging.getLogger(__name__)
DOMAIN = "nuheat"
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_DEVICES, default=[]): vol.All(
cv.ensure_list, [cv.string]
),
}
)
},
extra=vol.ALLOW_EXTRA,
)
def setup(hass, config):
"""Set up the NuHeat thermostat component."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)
password = conf.get(CONF_PASSWORD)
devices = conf.get(CONF_DEVICES)
api = nuheat.NuHeat(username, password)
api.authenticate()
hass.data[DOMAIN] = (api, devices)
discovery.load_platform(hass, "climate", DOMAIN, {}, config)
return True