diff --git a/examples/allVehicles.py b/examples/allVehicles.py index e4dbea9..5892859 100644 --- a/examples/allVehicles.py +++ b/examples/allVehicles.py @@ -2,7 +2,6 @@ from weconnect import weconnect - def main(): """ Simple example showing how to retrieve all vehciles from the account """ parser = argparse.ArgumentParser( @@ -10,11 +9,20 @@ def main(): description='Example retrieving all vehciles in the account') parser.add_argument('-u', '--username', help='Username of Volkswagen id', required=True) parser.add_argument('-p', '--password', help='Password of Volkswagen id', required=True) + parser.add_argument('-s', '--servicetype', help='The type of service to be used.', required=False) args = parser.parse_args() print('# Initialize WeConnect') - weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False) + if args.servicetype is not None: + # switching to user defined servicetype (e.g. "MyCupra") + print("Selected servicetype is: " + str(args.servicetype)) + stype=weconnect.Service(args.servicetype) + weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False, servicetype=stype) + else: + # using default servicetype ("WeConnect") + weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False) + print('# Login') weConnect.login() print('# update') diff --git a/weconnect/weconnect.py b/weconnect/weconnect.py index 5b507b8..238e6d3 100644 --- a/weconnect/weconnect.py +++ b/weconnect/weconnect.py @@ -42,6 +42,7 @@ def __init__( # noqa: C901 # pylint: disable=too-many-arguments updateCapabilities: bool = True, updatePictures: bool = True, numRetries: int = 3, + servicetype=Service.WE_CONNECT, # make service-type controllable by caller. Defaulting to VW WeConnect timeout: bool = None, selective: Optional[list[Domain]] = None, forceReloginAfter: Optional[int] = None @@ -104,7 +105,7 @@ def __init__( # noqa: C901 # pylint: disable=too-many-arguments self.tokenfile = tokenfile self.__manager = SessionManager(tokenstorefile=tokenfile) - self.__session = self.__manager.getSession(Service.WE_CONNECT, SessionUser(username=username, password=password)) + self.__session = self.__manager.getSession(servicetype, SessionUser(username=username, password=password)) self.__session.proxies.update(self.proxystring) self.__session.timeout = timeout self.__session.retries = numRetries