Async version of melissa (#17721)

* rebase upstream

* Fixed tests

* Fixing lint
This commit is contained in:
kennedyshead 2018-10-30 21:29:11 +01:00 committed by Martin Hjelmare
parent 9565c0bd1d
commit 4073f63256
7 changed files with 481 additions and 317 deletions

View file

@ -10,9 +10,9 @@ import voluptuous as vol
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers.discovery import async_load_platform
REQUIREMENTS = ["py-melissa-climate==1.0.6"]
REQUIREMENTS = ["py-melissa-climate==2.0.0"]
_LOGGER = logging.getLogger(__name__)
@ -28,17 +28,19 @@ CONFIG_SCHEMA = vol.Schema({
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
async def async_setup(hass, config):
"""Set up the Melissa Climate component."""
import melissa
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)
password = conf.get(CONF_PASSWORD)
api = melissa.Melissa(username=username, password=password)
api = melissa.AsyncMelissa(username=username, password=password)
await api.async_connect()
hass.data[DATA_MELISSA] = api
load_platform(hass, 'sensor', DOMAIN, {}, config)
load_platform(hass, 'climate', DOMAIN, {}, config)
hass.async_create_task(
async_load_platform(hass, 'sensor', DOMAIN, {}, config))
hass.async_create_task(
async_load_platform(hass, 'climate', DOMAIN, {}, config))
return True