Forum Samochody Elektryczne
Fora
Nowe posty
Search forums
Pokaż najnowsze
Nowe posty
New media
New media comments
New resources
Najnowsze aktywności
Media
Nowe multimedia
Nowe komentarze
Search media
Resources
Najnowsze recenzje
Search resources
Log in
Register
What's new
Szukaj...
Szukaj...
Szukaj tylko w tytułach
By:
Nowe posty
Search forums
Menu
Log in
Register
Install the app
Install
Forum Samochody Elektryczne
Fora
TESLA
Tesla Model 3 Forum • Tesla 3, TM3 SR+, LR, Perf
Szybkie pytanie - szybka odpowiedź
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Napisz odpowiedź
Message
[QUOTE="dawidgora, post: 137684, member: 1529"] Myślę, że dałoby się to jakoś zautomatyzować. Nie ma chyba gotowego rozwiązania, ale skoro jest API (oficjalne, czy też wrapper od Tessie, albo inny) i z tego poziomu mamy dostęp do: - odczytu natężenia ładowania - odczytu lokalizacji - zatrzymywania i startu ładowania to możemy napisać samodzielnie prosty skrypt, który po wykryciu spadku natężenia prądu ładowania, będąc w zadanej lokalizacji, przerwie ładowanie i uruchomi je ponownie. Jak znajdę czas to mogę takie coś nawet napisać, z tym, że muszę wymyślić jak zasymulować taki spadek napięcia u siebie. EDIT: Wrzucam poglądowy kod w pythonie, napisany na szybko przez chat gpt [CODE=python]import requests import time from geopy.distance import geodesic # Constants TESLA_CLIENT_ID = 'your-client-id' TESLA_CLIENT_SECRET = 'your-client-secret' USERNAME = 'your-tesla-username' PASSWORD = 'your-tesla-password' VEHICLE_ID = 'your-vehicle-id' # Function to get an access token def get_access_token(username, password): url = "https://owner-api.teslamotors.com/oauth/token" payload = { "grant_type": "password", "client_id": TESLA_CLIENT_ID, "client_secret": TESLA_CLIENT_SECRET, "email": username, "password": password } response = requests.post(url, data=payload) return response.json()['access_token'] # Function to get vehicle data def get_vehicle_data(access_token, vehicle_id): url = f"https://owner-api.teslamotors.com/api/1/vehicles/{vehicle_id}/vehicle_data" headers = {'Authorization': f'Bearer {access_token}'} response = requests.get(url, headers=headers) return response.json() # Function to send command to the vehicle def send_vehicle_command(access_token, vehicle_id, command): url = f"https://owner-api.teslamotors.com/api/1/vehicles/{vehicle_id}/command/{command}" headers = {'Authorization': f'Bearer {access_token}'} response = requests.post(url, headers=headers) return response.json() # Main function to manage charging def manage_charging(target_location, range_km, interval, max_attempts): access_token = get_access_token(USERNAME, PASSWORD) attempts = 0 while attempts < max_attempts: vehicle_data = get_vehicle_data(access_token, VEHICLE_ID) current_location = (vehicle_data['drive_state']['latitude'], vehicle_data['drive_state']['longitude']) charging_state = vehicle_data['charge_state'] if charging_state['charging_state'] == 'Charging' and charging_state['charger_actual_current'] < 16: if geodesic(current_location, target_location).km <= range_km: send_vehicle_command(access_token, VEHICLE_ID, 'stop_charge') time.sleep(60) # Wait for 60 seconds send_vehicle_command(access_token, VEHICLE_ID, 'start_charge') time.sleep(interval) attempts += 1 # Example usage target_location = (latitude, longitude) # Replace with actual latitude and longitude manage_charging(target_location, 5, 300, 10) [/CODE] [/QUOTE]
Verification
Wyślij odpowiedź
Forum Samochody Elektryczne
Fora
TESLA
Tesla Model 3 Forum • Tesla 3, TM3 SR+, LR, Perf
Szybkie pytanie - szybka odpowiedź
Top