Esempio n. 1
0
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Skybell component."""
    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)

    try:
        cache = hass.config.path(DEFAULT_CACHEDB)
        skybell = Skybell(
            username=username,
            password=password,
            get_devices=True,
            cache_path=cache,
            agent_identifier=AGENT_IDENTIFIER,
        )

        hass.data[DOMAIN] = skybell
    except (ConnectTimeout, HTTPError) as ex:
        _LOGGER.error("Unable to connect to Skybell service: %s", str(ex))
        hass.components.persistent_notification.create(
            "Error: {}<br />"
            "You will need to restart hass after fixing."
            "".format(ex),
            title=NOTIFICATION_TITLE,
            notification_id=NOTIFICATION_ID,
        )
        return False
    return True
Esempio n. 2
0
def setup(hass, config):
    """Set up the Skybell component."""
    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)

    try:
        from skybellpy import Skybell

        cache = hass.config.path(DEFAULT_CACHEDB)
        skybell = Skybell(username=username,
                          password=password,
                          get_devices=True,
                          cache_path=cache)

        hass.data[DOMAIN] = skybell
    except (ConnectTimeout, HTTPError) as ex:
        _LOGGER.error("Unable to connect to Skybell service: %s", str(ex))
        hass.components.persistent_notification.create(
            'Error: {}<br />'
            'You will need to restart hass after fixing.'
            ''.format(ex),
            title=NOTIFICATION_TITLE,
            notification_id=NOTIFICATION_ID)
        return False
    return True