Replace the weconnect library with carconnectivity and carconnectivity-connector-volkswagen. The connector is configured via a dict passed to CarConnectivity(); startup()/fetch_all() replace login()/update(). All domain extractors in data_model.py are rewritten for the new object model (vehicle.charging.*, vehicle.get_electric_drive(), vehicle.climatization.*, etc.). Remaining time fields are now derived from estimated_date_reached DateAttributes. Battery temperatures are read directly in °C (no Kelvin conversion). Auth error handling drops the manual re-login since the connector manages token refresh internally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
import logging
|
|
import sys
|
|
|
|
try:
|
|
from carconnectivity.carconnectivity import CarConnectivity
|
|
except ImportError:
|
|
print(
|
|
"carconnectivity is not installed. Run: "
|
|
"pip install carconnectivity carconnectivity-connector-volkswagen",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def connect(username: str, password: str) -> CarConnectivity:
|
|
config = {
|
|
"carConnectivity": {
|
|
"connectors": [
|
|
{
|
|
"type": "volkswagen",
|
|
"config": {
|
|
"username": username,
|
|
"password": password,
|
|
},
|
|
}
|
|
]
|
|
}
|
|
}
|
|
cc = CarConnectivity(config=config)
|
|
cc.startup()
|
|
cc.fetch_all()
|
|
return cc
|
|
|
|
|
|
def select_vehicle(cc: CarConnectivity, vin: str | None):
|
|
"""Return (vehicle, error_message). error_message is None on success."""
|
|
vehicles = list(cc.get_garage().list_vehicles())
|
|
if not vehicles:
|
|
return None, "No vehicles found in this CarConnectivity account"
|
|
if vin:
|
|
vehicle = next((v for v in vehicles if v.vin.value == vin), None)
|
|
if not vehicle:
|
|
available = [v.vin.value for v in vehicles]
|
|
return None, f"VIN {vin} not found. Available: {available}"
|
|
return vehicle, None
|
|
return vehicles[0], None
|
|
|
|
|
|
def update(cc: CarConnectivity) -> None:
|
|
cc.fetch_all() |