2019-02-14 04:35:12 +00:00
|
|
|
"""Support for NuHeat thermostats."""
|
2017-11-11 06:22:37 +00:00
|
|
|
import logging
|
|
|
|
|
2019-10-23 15:30:38 +00:00
|
|
|
import nuheat
|
2017-11-11 06:22:37 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2019-10-23 15:30:38 +00:00
|
|
|
from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME
|
|
|
|
from homeassistant.helpers import config_validation as cv, discovery
|
2017-11-11 06:22:37 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
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,
|
|
|
|
)
|
2017-11-11 06:22:37 +00:00
|
|
|
|
2017-11-11 22:47:12 +00:00
|
|
|
|
2017-11-11 06:22:37 +00:00
|
|
|
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)
|
2017-11-14 04:40:18 +00:00
|
|
|
|
2017-11-11 06:22:37 +00:00
|
|
|
api = nuheat.NuHeat(username, password)
|
|
|
|
api.authenticate()
|
2017-12-26 19:12:28 +00:00
|
|
|
hass.data[DOMAIN] = (api, devices)
|
2017-11-11 06:22:37 +00:00
|
|
|
|
|
|
|
discovery.load_platform(hass, "climate", DOMAIN, {}, config)
|
|
|
|
return True
|