-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchargepoint.py
More file actions
41 lines (32 loc) · 1.53 KB
/
Copy pathchargepoint.py
File metadata and controls
41 lines (32 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
# Liste der Geräte-IDs, die du abfragen möchtest
device_ids = [1005629165, 1005954355, 1005954365, 1005954345] # Füge hier die gewünschten IDs hinzu
# Basis-URL der API
base_url = "https://mc.chargepoint.com/map-prod/v3/station/info"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Connection": "keep-alive",
}
# https://mc.chargepoint.com/map-prod/v3/station/info?deviceId=1005954365
# Leerer Dictionary, um die Ergebnisse zu speichern
sensor_data = {}
# Schleife durch die Liste der Geräte-IDs
for device_id in device_ids:
# Erstelle die vollständige URL für die Abfrage
url = f"{base_url}?deviceId={device_id}"
# Führe die GET-Anfrage durch
response = requests.get(url, headers=headers, timeout=10)
# Überprüfe, ob die Anfrage erfolgreich war (Statuscode 200)
if response.status_code == 200:
# Lese die JSON-Daten aus der Antwort
data = response.json()
# Speichere die Daten im Dictionary mit der Geräte-ID als Schlüssel
sensor_data[device_id] = data
else:
print(f"Fehler bei der Abfrage der Geräte-ID {device_id}")
# Jetzt kannst du auf die Sensor-Daten für jede Geräte-ID zugreifen
for device_id, data in sensor_data.items():
print(f"Sensor-Daten für Geräte-ID {device_id}:")
print(data)