### Start and Stop Climate Control and Preconditioning Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Remotely initiate or terminate climate control and preconditioning for electric vehicles. Requires a py-uconnect client instance and vehicle VIN. Handles potential exceptions during command execution. ```python from py_uconnect import Client, brands from py_uconnect.command import ( COMMAND_PRECOND_ON, COMMAND_PRECOND_OFF, COMMAND_HVAC_ON, COMMAND_HVAC_OFF ) client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.refresh() vehicles = client.get_vehicles() vin = list(vehicles.keys())[0] # Start preconditioning (for EVs) try: success = client.command_verify(vin, COMMAND_PRECOND_ON) if success: print("Preconditioning started") except Exception as e: print(f"Failed to start preconditioning: {e}") # Turn on HVAC try: correlation_id = client.command(vin, COMMAND_HVAC_ON) print(f"HVAC command sent: {correlation_id}") except Exception as e: print(f"HVAC command failed: {e}") # Stop climate control client.command_verify(vin, COMMAND_PRECOND_OFF) ``` -------------------------------- ### Execute Remote Door Lock/Unlock Commands Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Provides examples of sending remote commands to lock or unlock vehicle doors using `client.command()` (fire-and-forget) and `client.command_verify()` (waits for completion). Includes error handling for command execution. ```python from py_uconnect import Client, brands from py_uconnect.command import COMMAND_DOORS_LOCK, COMMAND_DOORS_UNLOCK client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.refresh() vehicles = client.get_vehicles() vin = list(vehicles.keys())[0] # Lock doors (fire-and-forget) try: correlation_id = client.command(vin, COMMAND_DOORS_LOCK) print(f"Lock command queued with ID: {correlation_id}") except Exception as e: print(f"Lock command failed: {e}") # Unlock doors with verification (waits for completion) try: success = client.command_verify(vin, COMMAND_DOORS_UNLOCK) if success: print("Doors unlocked successfully") else: print("Unlock command failed") except Exception as e: print(f"Error executing unlock command: {e}") ``` -------------------------------- ### Manage Electric Vehicle Charging Operations Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Control EV charging, including starting a charging session and setting preferred charging levels. This function retrieves current charging status and attempts to initiate charging or update preferences. ```python from py_uconnect import Client, brands from py_uconnect.command import COMMAND_CHARGE from py_uconnect.api import ( CHARGING_LEVEL_ONE, CHARGING_LEVEL_TWO, CHARGING_LEVEL_THREE, CHARGING_LEVEL_FOUR, CHARGING_LEVEL_FIVE ) client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.refresh() vehicles = client.get_vehicles() vin = list(vehicles.keys())[0] vehicle = vehicles[vin] # Check current charging status print(f"State of Charge: {vehicle.state_of_charge}%") print(f"Charging: {vehicle.charging}") print(f"Plugged In: {vehicle.plugged_in}") print(f"Time to L2 Full Charge: {vehicle.time_to_fully_charge_l2} minutes") print(f"Time to L3 Full Charge: {vehicle.time_to_fully_charge_l3} minutes") # Start charging now try: success = client.command_verify(vin, COMMAND_CHARGE) if success: print("Charging initiated") except Exception as e: print(f"Failed to start charging: {e}") # Set charging level preference try: success = client.set_charging_level_verify(vin, CHARGING_LEVEL_FOUR) if success: print("Charging level set to LEVEL_FOUR") except Exception as e: print(f"Failed to set charging level: {e}") ``` -------------------------------- ### Python Client Initialization and Vehicle Data Fetch Source: https://github.com/hass-uconnect/py-uconnect/blob/master/README.md Demonstrates how to initialize the py-uconnect client with user credentials and brand, refresh vehicle data from the cache, and retrieve a list of vehicles. It also shows how to print individual vehicle details in JSON format. ```Python from py_uconnect import brands, Client # Create client client = Client('foo@bar.com', 'very_secret', pin='1234', brand=brands.FIAT_EU) # Fetch the vehicle data into cache client.refresh() # List vehicles vehicles = client.get_vehicles() for vehicle in vehicles.values(): print(vehicle.to_json(indent=2)) ``` -------------------------------- ### Initialize py-uconnect Client and Authentication Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Demonstrates how to initialize the py-uconnect client with credentials for different brands and regions (e.g., Fiat EU, Jeep US). It also shows how to enable debug logging and optionally disable TLS verification. ```python from py_uconnect import Client, brands # Initialize client for a Fiat vehicle in Europe client = Client( email='user@example.com', password='your_password', pin='1234', brand=brands.FIAT_EU ) # For US Jeep vehicles jeep_client = Client( email='user@example.com', password='your_password', pin='1234', brand=brands.JEEP_US ) # Enable debug logging client.set_debug(True) # Disable TLS verification (not recommended for production) client.set_tls_verification(False) ``` -------------------------------- ### Error Handling and Debugging in py-uconnect Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Demonstrates error handling for authentication failures and command execution, and enables library debugging. It involves setting up logging, initializing the client, and using try-except blocks to catch potential exceptions during data refresh and command execution. PIN updates can be handled within error blocks. ```python from py_uconnect import Client, brands from py_uconnect.command import COMMAND_DOORS_LOCK import logging # Enable library logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('py_uconnect') client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.set_debug(True) try: # Attempt to refresh vehicle data client.refresh() vehicles = client.get_vehicles() if not vehicles: print("No vehicles found in account") else: vin = list(vehicles.keys())[0] # Execute command with error handling try: correlation_id = client.command(vin, COMMAND_DOORS_LOCK) print(f"Command queued: {correlation_id}") except Exception as cmd_error: print(f"Command execution failed: {cmd_error}") # Check if PIN is correct client.set_pin('0000') # Update PIN except Exception as auth_error: print(f"Authentication or data retrieval failed: {auth_error}") # Handle login failure - check credentials, network, brand selection ``` -------------------------------- ### Command-Line Interface for Vehicle Status Checks Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Provides a command-line tool for quick vehicle status checks. It requires the brand name, email, and password as arguments. An optional fourth argument can enable debug mode, and the output is provided in JSON format. ```bash # Basic usage ./cli.py BRAND_NAME email@example.com password # Examples for different brands ./cli.py FIAT_EU user@example.com mypassword ./cli.py JEEP_US user@example.com mypassword ./cli.py RAM_US user@example.com mypassword # Enable debug mode (add any 4th argument) ./cli.py FIAT_EU user@example.com mypassword debug # Output shows all vehicles in JSON format with complete status information ``` -------------------------------- ### Connect to Different Automotive Brands and Regions Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Demonstrates how to instantiate the py-uconnect Client with different brand and region configurations. Provides a mapping of available brand identifiers for flexible multi-brand support. ```python from py_uconnect import Client, brands # Available brands available_brands = { 'FIAT_EU': brands.FIAT_EU, 'FIAT_US': brands.FIAT_US, 'FIAT_CANADA': brands.FIAT_CANADA, 'FIAT_ASIA': brands.FIAT_ASIA, 'JEEP_EU': brands.JEEP_EU, 'JEEP_US': brands.JEEP_US, 'JEEP_ASIA': brands.JEEP_ASIA, 'DODGE_US': brands.DODGE_US, 'RAM_US': brands.RAM_US, 'CHRYSLER_US': brands.CHRYSLER_US, 'CHRYSLER_CANADA': brands.CHRYSLER_CANADA, 'ALFA_ROMEO_EU': brands.ALFA_ROMEO_EU, 'ALFA_ROMEO_US_CANADA': brands.ALFA_ROMEO_US_CANADA, 'ALFA_ROMEO_ASIA': brands.ALFA_ROMEO_ASIA, 'MASERATI_EU': brands.MASERATI_EU, 'MASERATI_US_CANADA': brands.MASERATI_US_CANADA, 'MASERATI_ASIA': brands.MASERATI_ASIA, } # Example of initializing client for a specific brand # client = Client('user@example.com', 'password', pin='1234', brand=available_brands['JEEP_US']) ``` -------------------------------- ### Access Tire Pressure Monitoring Data with py-uconnect Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Retrieves and displays tire pressure data and warning status for all four wheels of a vehicle. It requires client initialization with credentials and brand, followed by fetching vehicle data. Tire pressures are presented in their respective units, with warnings indicated. ```python from py_uconnect import Client, brands client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.refresh() vehicles = client.get_vehicles() vehicle = list(vehicles.values())[0] # Check tire pressures tires = { 'Front Left': { 'pressure': vehicle.wheel_front_left_pressure, 'unit': vehicle.wheel_front_left_pressure_unit, 'warning': vehicle.wheel_front_left_pressure_warning }, 'Front Right': { 'pressure': vehicle.wheel_front_right_pressure, 'unit': vehicle.wheel_front_right_pressure_unit, 'warning': vehicle.wheel_front_right_pressure_warning }, 'Rear Left': { 'pressure': vehicle.wheel_rear_left_pressure, 'unit': vehicle.wheel_rear_left_pressure_unit, 'warning': vehicle.wheel_rear_left_pressure_warning }, 'Rear Right': { 'pressure': vehicle.wheel_rear_right_pressure, 'unit': vehicle.wheel_rear_right_pressure_unit, 'warning': vehicle.wheel_rear_right_pressure_warning } } for position, data in tires.items(): if data['pressure'] is not None: status = "WARNING" if data['warning'] else "OK" print(f"{position}: {data['pressure']} {data['unit']} [{status}]") else: print(f"{position}: No data available") ``` -------------------------------- ### Retrieve and Process Vehicle Data Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Shows how to fetch all vehicle data by calling `client.refresh()`, access individual vehicles by VIN, and iterate through vehicle attributes like VIN, nickname, make, model, odometer, battery status, charging status, range, and location. It also demonstrates converting vehicle data to JSON format. ```python from py_uconnect import Client, brands client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) # Fetch all vehicle data from the API and cache locally client.refresh() # Get dictionary of all vehicles keyed by VIN vehicles = client.get_vehicles() # Iterate through vehicles and access data for vin, vehicle in vehicles.items(): print(f"VIN: {vehicle.vin}") print(f"Nickname: {vehicle.nickname}") print(f"Make/Model: {vehicle.make} {vehicle.model} ({vehicle.year})") print(f"Odometer: {vehicle.odometer} {vehicle.odometer_unit}") print(f"Battery State of Charge: {vehicle.state_of_charge}%") print(f"Charging: {vehicle.charging}") print(f"Plugged In: {vehicle.plugged_in}") print(f"Range: {vehicle.distance_to_empty} {vehicle.distance_to_empty_unit}") print(f"Location: {vehicle.location.latitude}, {vehicle.location.longitude}") print(f"All Doors Locked: {vehicle.door_driver_locked}") # Convert vehicle data to JSON json_output = vehicle.to_json(indent=2) print(json_output) ``` -------------------------------- ### Access and Execute Supported Remote Vehicle Commands Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Retrieve a list of all remote commands supported by a specific vehicle and conditionally execute them. This includes actions like flashing lights, honking, unlocking the trunk, and refreshing vehicle data. ```python from py_uconnect import Client, brands from py_uconnect.command import ( COMMAND_ENGINE_ON, COMMAND_ENGINE_OFF, COMMAND_LIGHTS, COMMAND_LIGHTS_HORN, COMMAND_TRUNK_UNLOCK, COMMAND_TRUNK_LOCK, COMMAND_DEEP_REFRESH, COMMAND_REFRESH_LOCATION, COMMANDS_BY_NAME ) client = Client('user@example.com', 'password', pin='1234', brand=brands.JEEP_US) client.refresh() vehicles = client.get_vehicles() vin = list(vehicles.keys())[0] vehicle = vehicles[vin] # Check which commands are supported for this vehicle print("Supported commands:") for cmd_name in vehicle.supported_commands: print(f" - {cmd_name}") # Flash lights if 'ROLIGHTS' in vehicle.supported_commands: client.command_verify(vin, COMMAND_LIGHTS) print("Lights flashed") # Flash lights and honk horn if 'HBLF' in vehicle.supported_commands: client.command_verify(vin, COMMAND_LIGHTS_HORN) print("Lights flashed and horn honked") # Unlock trunk if 'ROTRUNKUNLOCK' in vehicle.supported_commands: client.command_verify(vin, COMMAND_TRUNK_UNLOCK) print("Trunk unlocked") # Refresh location if 'VF' in vehicle.supported_commands: client.command_verify(vin, COMMAND_REFRESH_LOCATION) print("Location refresh requested") # Deep refresh all vehicle data if 'DEEPREFRESH' in vehicle.supported_commands: client.command_verify(vin, COMMAND_DEEP_REFRESH) print("Deep refresh completed") ``` -------------------------------- ### Track Vehicle Location Data Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Explains how to retrieve and display detailed location information for a vehicle, including latitude, longitude, altitude, bearing, and last updated timestamp. It also shows how to construct a Google Maps URL for visualizing the location. ```python from py_uconnect import Client, brands client = Client('user@example.com', 'password', pin='1234', brand=brands.FIAT_EU) client.refresh() vehicles = client.get_vehicles() vehicle = list(vehicles.values())[0] if vehicle.location: location = vehicle.location print(f"Latitude: {location.latitude}") print(f"Longitude: {location.longitude}") print(f"Altitude: {location.altitude}m") print(f"Bearing: {location.bearing}°") print(f"Is Approximate: {location.is_approximate}") print(f"Last Updated: {location.updated}") # Use location in mapping applications map_url = f"https://maps.google.com/?q={location.latitude},{location.longitude}" print(f"View on map: {map_url}") ``` -------------------------------- ### Connect to Different Car Brands using py-uconnect Source: https://context7.com/hass-uconnect/py-uconnect/llms.txt Connects to various car brands supported by py-uconnect. It requires brand name, user email, password, and PIN. The function returns a list of connected vehicles. ```python from py_uconnect import Client, brands brand_name = 'ALFA_ROMEO_EU' brand = brands.get(brand_name) if brand: client = Client( email='user@example.com', password='password', pin='1234', brand=brand ) client.refresh() vehicles = client.get_vehicles() print(f"Connected to {brand_name}, found {len(vehicles)} vehicle(s)") else: print(f"Brand {brand_name} not found") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.