示例#1
0
    def test_general_attributes(self, mock):
        """Test PyArlo without preloading videos."""
        from pyarlo import PyArlo
        from pyarlo.camera import ArloCamera

        mock.post(LOGIN_ENDPOINT,
                  text=load_fixture('pyarlo_authentication.json'))
        mock.get(DEVICES_ENDPOINT, text=load_fixture('pyarlo_devices.json'))
        mock.post(LIBRARY_ENDPOINT, text=load_fixture('pyarlo_videos.json'))
        mock.get(RESET_ENDPOINT, json={'success': True})

        arlo = PyArlo(USERNAME, PASSWORD, days=1)

        self.assertEqual(arlo.__repr__(), '<PyArlo: 999-123456>')
        self.assertIsInstance(arlo.lookup_camera_by_id('48B14CAAAAAAA'),
                              ArloCamera)
        self.assertRaises(IndexError, arlo.lookup_camera_by_id, 'FAKEID')
        self.assertTrue(arlo.is_connected)
        self.assertTrue(arlo.unseen_videos_reset)
        self.assertIsNone(arlo.update())
示例#2
0
def setup(hass, config):
    """Set up an Arlo component."""
    conf = config[DOMAIN]
    username = conf.get(CONF_USERNAME)
    password = conf.get(CONF_PASSWORD)

    try:
        from pyarlo import PyArlo

        arlo = PyArlo(username, password, preload=False)
        if not arlo.is_connected:
            return False
        arlo.update = Throttle(timedelta(seconds=10))(arlo.update)
        hass.data[DATA_ARLO] = arlo
    except (ConnectTimeout, HTTPError) as ex:
        _LOGGER.error("Unable to connect to Netgear Arlo: %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