控制捷豹i-pace
jlrp的Python项目详细描述
jlrpy
用于与JLR远程汽车API交互的Python3库。
文档
JLR InControl API的相关API文档对于任何想要使用此项目的人来说都是一本不错的读物。它目前可用here
安装
直接签出这个存储库或通过pip安装(对于python3)。
pip install jlrpy
用法
首先,实例化一个Connection
对象,并传递与捷豹InControl智能驭享帐户相关的电子邮件地址和密码。
有两种方法可以对InControl进行身份验证。使用用户名和密码或使用有效的刷新令牌。
JLR API要求注册设备ID(Uuid4格式)。如果在实例化Connection
对象时没有指定一个对象,它将自动为您的对象生成一个新对象。
importjlrpy# Authenticate using the username and passwordc=jlrpy.Connection('my@email.com','password')v=c.vehicles[0]# Authenticate using a refresh token (username must still be specified)c=jlrpy.Connection(email='my@email.com',refresh_token='124c3f21-42ds-2e4d-86f8-221v32392a1d')
Connection.vehicles
将列出与您的帐户关联的所有车辆。
# Get user informationc.get_user_info()# Update user information.p=c.get_user_info()p['contact']['userPreferences']['unitsOfMeasurement']="Km Litre Celsius VolPerDist Wh DistPerkWh"c.update_user_info(p)# Refresh access tokenc.refresh_tokens()# Get attributes associated with vehiclev.get_attributes()# Get current status of vehiclev.get_status()# Optionally, you can also specify a status value keyv.get_status("EV_STATE_OF_CHARGE")# Get subscription packesv.get_subscription_packages()# Get trip data (last 1000 trips).v.get_trips()# Get data for a single trip (specified with trip id)v.get_trip(121655021)# Get vehicle health statusv.get_health_status()# Get departure timersv.get_departure_timers()# Get configured wakeup timev.get_wakeup_time()# Honk horn and blink lightsv.honk_blink()# Get current position of vehiclev.get_position()# Start preconditioning at 21.0Cv.preconditioning_start("210")# Stop preconditioningv.preconditioning_stop()# Set vehicle nickname and registration numberv.set_attributes("Name","reg-number")# Lock vehiclev.lock(pin)# pin being the personal master pin# Unlock vehiclev.unlock(pin)# Reset alarmv.reset_alarm(pin)# Start chargingv.charging_start()# Stop chargingv.charging_stop()# Set max soc at 80% (Requires upcoming OTA update)v.set_max_soc(80)# Set max soc for current charging session to 90% (Requires upcoming OTA update)v.set_one_off_max_soc(90)# Add single departure timer (index, year, month, day, hour, minute)v.add_departure_timer(10,2019,1,30,20,30)# Delete a single departure timer index.v.delete_departure_timer(10)# Schedule repeated departure timer.schedule={"friday":false,"monday":true,"saturday":false,"sunday":false,"thursday":false,"tuesday":true,"wednesday":true}v.add_repeated_departure_timer(10,20,30,schedule)# Set wakeup timer (epoch millis)v.set_wakeup_time(1547845200000)# Cancel wakeup timerv.delete_wakeup_time()# Enable service mode (requires personal PIN)v.enable_service_mode("1234",1547551847000)# Enable transport mode (requires personal PIN)v.enable_transport_mode("1234",1547551847000)# Enable privacy modev.enable_privacy_mode("1234")# Disable privacy modev.disable_privacy_mode("1234")# Add charging period with specified index identifier value.v.add_charging_period(1,schedule,0,30,8,45)# Reverse geocodec.reverse_geocode(59.915475,10.733054)
示例
examples目录包含使jlrpy得到良好使用的示例脚本。
最大最小荷电比
^ {< CD5>}脚本允许您指定车辆所需的最大和最小充电状态。一旦达到最大充电状态,充电将停止,如果达到最小充电状态,充电将开始。