Files
home-assistant-core/homeassistant/components/totalconnect/__init__.py
T
Austin Mroczek 369e6a3905 Move totalconnect from platform to component config (#24427)
* Move totalconnect component toward being a multi-platform integration.  Bump total_connect_client to 0.28.

* add missing total-connect alarm state mappings

* Made recommended changes of MartinHjelmare at
https://github.com/home-assistant/home-assistant/pull/24427

* Update __init__.py

* Updates per MartinHjelmare comments

* flake8/pydocstyle fixes

* removed . at end of log message

* added blank line between logging and voluptuous

* more fixes
2019-07-14 09:24:40 +02:00

55 lines
1.4 KiB
Python

"""The totalconnect component."""
import logging
import voluptuous as vol
from total_connect_client import TotalConnectClient
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import discovery
from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME)
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'totalconnect'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}),
}, extra=vol.ALLOW_EXTRA)
TOTALCONNECT_PLATFORMS = ['alarm_control_panel']
def setup(hass, config):
"""Set up TotalConnect component."""
conf = config[DOMAIN]
username = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD]
client = TotalConnectClient.TotalConnectClient(username, password)
if client.token is False:
_LOGGER.error("TotalConnect authentication failed")
return False
hass.data[DOMAIN] = TotalConnectSystem(username, password, client)
for platform in TOTALCONNECT_PLATFORMS:
discovery.load_platform(hass, platform, DOMAIN, {}, config)
return True
class TotalConnectSystem:
"""TotalConnect System class."""
def __init__(self, username, password, client):
"""Initialize the TotalConnect system."""
self._username = username
self._password = password
self.client = client