#!/usr/bin/env python #IMPORTS import time import asyncio #inspired on https://www.domoticz.com/forum/viewtopic.php?f=65&p=283902 from bimmer_connected.account import MyBMWAccount from bimmer_connected.api.regions import get_region_from_name from bimmer_connected.vehicle.remote_services import ExecutionState USERNAME = 'xxx' PASSWORD = 'xx' VIN = 'xxx' t = time.localtime() print ('{} START ----------------------------------------------------'.format(time.strftime("%H:%M:%S", t))) myBMW = MyBMWAccount(USERNAME, PASSWORD, get_region_from_name('rest_of_world')) print('Login done! MyBMW object: {}'.format(myBMW)) if myBMW: try: asyncio.run(myBMW.get_vehicles()) except Exception as err: print('Error login in MyBMW!') import traceback print('Login error TRACEBACK: {}'.format(traceback.format_exc())) else: myVehicle = myBMW.get_vehicle(VIN) if myVehicle: print('Login successful! Car {} (VIN:{}) found!'.format(myVehicle.name, VIN)) print('Car {} status: {}'.format(myVehicle.name, myVehicle)) else: print('Error VIN {} not found for user.'.format(VIN)) #while myBMW: t = time.localtime() print ('{} UPDATE ---------------------------------------------------'.format(time.strftime("%H:%M:%S", t))) myVehicle = None try: asyncio.run(myBMW.get_vehicles()) except: import traceback print('StatusUpdate TRACEBACK: {}'.format(traceback.format_exc())) myBMW = MyBMWAccount(USERNAME, PASSWORD, get_region_from_name('rest_of_world')) print('Login done! MyBMW object: {}'.format(myBMW)) else: myVehicle = myBMW.get_vehicle(VIN) if myVehicle: print('Car {} found after update!'.format(myVehicle.name)) print('Mileage: {} {}'.format(myVehicle.mileage[0], myVehicle.mileage[1])) print('Car {} status: {}'.format(myVehicle.name, myVehicle)) print('Horn car...') Status = asyncio.run(myVehicle.remote_services.trigger_remote_horn()) print('Horn car status: {}'.format(Status)) if Status.state != ExecutionState.EXECUTED: print('Error executing remote service: Horn') print('Start Charging...') Status = asyncio.run(myVehicle.remote_services.trigger_charge_start()) print('Start Charging status: {}'.format(Status)) if Status.state != ExecutionState.EXECUTED: print('Error executing remote service: Start Charging') print('Stop Charging...') Status = asyncio.run(myVehicle.remote_services.trigger_charge_stop()) print('Stop Charging status: {}'.format(Status)) if Status.state != ExecutionState.EXECUTED: print('Error executing remote service: Stop Charging') else: print('Error VIN {} not found for user.'.format(VIN)) # time.sleep(240)