Esempio n. 1
0
    def __init__(self,
                 username=None,
                 password=None,
                 auto_login=False,
                 get_devices=False,
                 get_automations=False):
        """Init Abode object."""
        self._username = username
        self._password = password
        self._session = None
        self._token = None
        self._panel = None
        self._user = None

        self._event_controller = AbodeEventController(self)

        self._default_alarm_mode = CONST.MODE_AWAY

        self._devices = None

        self._automations = None

        # Create a requests session to persist the cookies
        self._session = requests.session()

        if (self._username is not None and self._password is not None
                and auto_login):
            self.login()

        if get_devices:
            self.get_devices()

        if get_automations:
            self.get_automations()
Esempio n. 2
0
    def __init__(self,
                 username=None,
                 password=None,
                 auto_login=False,
                 get_devices=False,
                 get_automations=False,
                 cache_path=CONST.CACHE_PATH,
                 disable_cache=False):
        """Init Abode object."""
        self._session = None
        self._token = None
        self._panel = None
        self._user = None
        self._cache_path = cache_path
        self._disable_cache = disable_cache

        self._event_controller = AbodeEventController(self,
                                                      url=CONST.SOCKETIO_URL)

        self._default_alarm_mode = CONST.MODE_AWAY

        self._devices = None

        self._automations = None

        # Create a requests session to persist the cookies
        self._session = requests.session()

        # Create a new cache template
        self._cache = {
            CONST.ID: None,
            CONST.PASSWORD: None,
            CONST.UUID: UTILS.gen_uuid()
        }

        # Load and merge an existing cache
        if not disable_cache:
            self._load_cache()

        # If the username and password were passed in, update
        # the cache and save
        if username:
            self._cache[CONST.ID] = username

        if password:
            self._cache[CONST.PASSWORD] = password

        self._save_cache()

        if (self._cache[CONST.ID] is not None
                and self._cache[CONST.PASSWORD] is not None and auto_login):
            self.login()

        if get_devices:
            self.get_devices()

        if get_automations:
            self.get_automations()