How to use the regenmaschine.Authenticator function in regenmaschine

To help you get started, we’ve selected a few regenmaschine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / rainmachine.py View on Github external
def setup(hass, config):
    """Set up the RainMachine component."""
    from regenmaschine import Authenticator, Client
    from regenmaschine.exceptions import HTTPError
    from requests.exceptions import ConnectTimeout

    conf = config[DOMAIN]
    ip_address = conf[CONF_IP_ADDRESS]
    password = conf[CONF_PASSWORD]
    port = conf[CONF_PORT]
    ssl = conf[CONF_SSL]

    _LOGGER.debug('Setting up RainMachine client')

    try:
        auth = Authenticator.create_local(
            ip_address, password, port=port, https=ssl)
        client = Client(auth)
        hass.data[DATA_RAINMACHINE] = RainMachine(client)
    except (HTTPError, ConnectTimeout, UnboundLocalError) as exc_info:
        _LOGGER.error('An error occurred: %s', str(exc_info))
        hass.components.persistent_notification.create(
            'Error: {0}<br>'
            'You will need to restart hass after fixing.'
            ''.format(exc_info),
            title=NOTIFICATION_TITLE,
            notification_id=NOTIFICATION_ID)
        return False

    _LOGGER.debug('Setting up switch platform')
    switch_config = conf.get(CONF_SWITCHES, {})
    discovery.load_platform(hass, 'switch', DOMAIN, switch_config, config)

regenmaschine

A simple API for RainMachine sprinkler controllers

MIT
Latest version published 3 months ago

Package Health Score

69 / 100
Full package analysis

Similar packages