From be8e12a4ab6d0f795d22ee6add1f11dc4c3ac5ed Mon Sep 17 00:00:00 2001 From: jlayec Date: Thu, 11 Feb 2021 12:49:48 +0000 Subject: [PATCH] add offline mode limited to dashboard --- server.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/server.py b/server.py index 88f2950..b2fb1e0 100755 --- a/server.py +++ b/server.py @@ -26,7 +26,8 @@ def parse_args(): parser.add_argument("-r", "--record", help="save vehicle data to db", action='store_true') parser.add_argument("-m", "--mail", help="set the email address") parser.add_argument("-P", "--password", help="set the password") - parser.add_argument("--remote-disable", help="disable remote control") + parser.add_argument("--remote-disable", help="disable remote control", action='store_true') + parser.add_argument("--offline", help="offline limited mode", action='store_true') parser.add_argument("-b", "--base-path", help="base path for web app",default="/") parser.parse_args() return parser @@ -46,24 +47,27 @@ if __name__ == "__main__": atexit.register(web.app.myp.save_config) if args.record: web.app.myp.set_record(True) - try: - web.app.myp.manager._refresh_token() - except OAuthError: - if args.mail and args.password: - client_email = args.mail - client_password = args.password - else: - client_email = input("mypeugeot email: ") - client_password = input("mypeugeot password: ") - web.app.myp.connect(client_email, client_password) - logger.info(web.app.myp.get_vehicles()) + if args.offline: + logger.info("offline mode") + else: + try: + web.app.myp.manager._refresh_token() + except OAuthError: + if args.mail and args.password: + client_email = args.mail + client_password = args.password + else: + client_email = input("mypeugeot email: ") + client_password = input("mypeugeot password: ") + web.app.myp.connect(client_email, client_password) + logger.info(web.app.myp.get_vehicles()) t1 = Thread(target=start_app, args=["My car info", args.base_path, args.debug < 20, args.listen, int(args.port)]) t1.start() - if args.remote_disable: + if args.offline or args.remote_disable: logger.info("mqtt disabled") else: web.app.myp.start_mqtt() if args.charge_control: web.app.chc = ChargeControls.load_config(web.app.myp, name=args.charge_control) web.app.chc.start() - save_config(web.app.myp) \ No newline at end of file + save_config(web.app.myp)