pyporscheconnectapi-bartolije 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyporscheconnectapi_bartolije-0.3.0/LICENSE +21 -0
- pyporscheconnectapi_bartolije-0.3.0/PKG-INFO +136 -0
- pyporscheconnectapi_bartolije-0.3.0/README.md +103 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/__init__.py +10 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/account.py +66 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/cli.py +394 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/connection.py +179 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/const.py +159 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/exceptions.py +72 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/oauth2.py +402 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/remote_services.py +364 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi/vehicle.py +395 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/PKG-INFO +136 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/SOURCES.txt +25 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/dependency_links.txt +1 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/entry_points.txt +2 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/requires.txt +4 -0
- pyporscheconnectapi_bartolije-0.3.0/pyporscheconnectapi_bartolije.egg-info/top_level.txt +1 -0
- pyporscheconnectapi_bartolije-0.3.0/pyproject.toml +19 -0
- pyporscheconnectapi_bartolije-0.3.0/setup.cfg +19 -0
- pyporscheconnectapi_bartolije-0.3.0/setup.py +35 -0
- pyporscheconnectapi_bartolije-0.3.0/tests/test_account.py +129 -0
- pyporscheconnectapi_bartolije-0.3.0/tests/test_connection.py +294 -0
- pyporscheconnectapi_bartolije-0.3.0/tests/test_oauth2.py +227 -0
- pyporscheconnectapi_bartolije-0.3.0/tests/test_remote_services.py +420 -0
- pyporscheconnectapi_bartolije-0.3.0/tests/test_vehicle.py +334 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Johan Isacsson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyporscheconnectapi-bartolije
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Python library and CLI for communicating with Porsche Connect API.
|
|
5
|
+
Home-page: https://github.com/cjne/pyporscheconnectapi
|
|
6
|
+
Author: Johan Isaksson
|
|
7
|
+
Author-email: johan@generatorhallen.se
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: aiofiles
|
|
19
|
+
Requires-Dist: httpx<1
|
|
20
|
+
Requires-Dist: beautifulsoup4
|
|
21
|
+
Requires-Dist: rich
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
Dynamic: summary
|
|
33
|
+
|
|
34
|
+
# pyporscheconnectapi
|
|
35
|
+
A python library for Porsche Connect API
|
|
36
|
+
|
|
37
|
+
This library will let you access your car equipped with Porsche Connect. It does not work with the predecessor Porsche Car Connect.
|
|
38
|
+
Porsche Connect is available for the following Porsche models:
|
|
39
|
+
|
|
40
|
+
* Boxster & Cayman (718)
|
|
41
|
+
* 911 (from 992)
|
|
42
|
+
* Taycan
|
|
43
|
+
* Panamera (from 2021, G2 PA)
|
|
44
|
+
* Macan (EV, from 2024)
|
|
45
|
+
* Cayenne (from 2017, E3)
|
|
46
|
+
|
|
47
|
+
You can also take a look here, select your model and see if your model has support for Porsche Connect:
|
|
48
|
+
https://connect-store.porsche.com/
|
|
49
|
+
|
|
50
|
+
A Porsche Connect subscription alse needs to be active for it to work.
|
|
51
|
+
|
|
52
|
+
*NOTE:* This work is not officially supported by Porsche and functionality can stop working at any time without warning.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
The easiest method is to install using pip3/pip (venv is also a good idea).
|
|
57
|
+
```
|
|
58
|
+
pip install pyporscheconnectapi
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
to update to the latest version
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
pip install pyporscheconnectapi -U
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Setup will add a cli under the name porschecli, see below for usage.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## CLI usage
|
|
71
|
+
|
|
72
|
+
A simple cli is provided with this library, it will cache tokens to a file to speed up invocations.
|
|
73
|
+
|
|
74
|
+
If no email or password is supplied as input arguments and no config file with those details is found you will be prompted.
|
|
75
|
+
```
|
|
76
|
+
usage: porschecli [-h] [-d] [-j] [-e EMAIL] [-p PASSWORD] [-s SESSION_FILE] [--nowait]
|
|
77
|
+
{list,token,capabilities,currentoverview,storedoverview,trip_statistics,pictures,location,climatise_on,climatise_off,direct_charge_on,direct_charge_off,flash_indicators,honk_and_flash,lock_vehicle,unlock_vehicle,vehicle_closed,doors_and_lids,tire_pressure_status,tire_pressures,chargingprofile}
|
|
78
|
+
...
|
|
79
|
+
|
|
80
|
+
Porsche Connect CLI
|
|
81
|
+
|
|
82
|
+
positional arguments:
|
|
83
|
+
{list,token,capabilities,currentoverview,storedoverview,trip_statistics,pictures,location,climatise_on,climatise_off,direct_charge_on,direct_charge_off,flash_indicators,honk_and_flash,lock_vehicle,unlock_vehicle,vehicle_closed,doors_and_lids,tire_pressure_status,tire_pressures,chargingprofile}
|
|
84
|
+
command help
|
|
85
|
+
battery Prints the main battery level (BEV)
|
|
86
|
+
capabilities Get vehicle capabilities
|
|
87
|
+
chargingprofile Update parameters in configured charging profile
|
|
88
|
+
climatise_off Stop remote climatisation
|
|
89
|
+
climatise_on Start remote climatisation
|
|
90
|
+
connected Check if vehicle is on-line
|
|
91
|
+
currentoverview Get stored overview for vehicle
|
|
92
|
+
direct_charge_off Disable direct charging
|
|
93
|
+
direct_charge_on Enable direct charging
|
|
94
|
+
doors_and_lids List status of all doors and lids
|
|
95
|
+
flash_indicators Flash indicators
|
|
96
|
+
honk_and_flash Flash indicators and sound the horn
|
|
97
|
+
location Show location of vehicle
|
|
98
|
+
lock_vehicle Lock vehicle
|
|
99
|
+
pictures Get vehicle pictures url
|
|
100
|
+
storedoverview Poll vehicle for current overview
|
|
101
|
+
tire_status Check if tire pressure are ok
|
|
102
|
+
tire_pressures Get tire pressure readings
|
|
103
|
+
trip_statistics Get trip statistics from backend
|
|
104
|
+
unlock_vehicle Unlock vehicle
|
|
105
|
+
vehicle_closed Check if all doors and lids are closed
|
|
106
|
+
|
|
107
|
+
options:
|
|
108
|
+
-h, --help show this help message and exit
|
|
109
|
+
-d, --debug
|
|
110
|
+
-j, --json output in JSON format
|
|
111
|
+
-e EMAIL, --email EMAIL
|
|
112
|
+
-p PASSWORD, --password PASSWORD
|
|
113
|
+
-s SESSION_FILE, --sessionfile SESSION_FILE
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Config file (for CLI)
|
|
118
|
+
|
|
119
|
+
A config file is searched for in ~/.porscheconnect.cfg and ./.porscheconnect.cfg
|
|
120
|
+
The format is:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
[porsche]
|
|
124
|
+
email=<your email>
|
|
125
|
+
password=<your password>
|
|
126
|
+
session_file=<file to store session information>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Library usage
|
|
130
|
+
|
|
131
|
+
Install pyporscheconnectapi using pip (requires python >= 3.10)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### Example client usage
|
|
135
|
+
|
|
136
|
+
Please refer to the examples provided in the repository.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# pyporscheconnectapi
|
|
2
|
+
A python library for Porsche Connect API
|
|
3
|
+
|
|
4
|
+
This library will let you access your car equipped with Porsche Connect. It does not work with the predecessor Porsche Car Connect.
|
|
5
|
+
Porsche Connect is available for the following Porsche models:
|
|
6
|
+
|
|
7
|
+
* Boxster & Cayman (718)
|
|
8
|
+
* 911 (from 992)
|
|
9
|
+
* Taycan
|
|
10
|
+
* Panamera (from 2021, G2 PA)
|
|
11
|
+
* Macan (EV, from 2024)
|
|
12
|
+
* Cayenne (from 2017, E3)
|
|
13
|
+
|
|
14
|
+
You can also take a look here, select your model and see if your model has support for Porsche Connect:
|
|
15
|
+
https://connect-store.porsche.com/
|
|
16
|
+
|
|
17
|
+
A Porsche Connect subscription alse needs to be active for it to work.
|
|
18
|
+
|
|
19
|
+
*NOTE:* This work is not officially supported by Porsche and functionality can stop working at any time without warning.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
The easiest method is to install using pip3/pip (venv is also a good idea).
|
|
24
|
+
```
|
|
25
|
+
pip install pyporscheconnectapi
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
to update to the latest version
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
pip install pyporscheconnectapi -U
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Setup will add a cli under the name porschecli, see below for usage.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## CLI usage
|
|
38
|
+
|
|
39
|
+
A simple cli is provided with this library, it will cache tokens to a file to speed up invocations.
|
|
40
|
+
|
|
41
|
+
If no email or password is supplied as input arguments and no config file with those details is found you will be prompted.
|
|
42
|
+
```
|
|
43
|
+
usage: porschecli [-h] [-d] [-j] [-e EMAIL] [-p PASSWORD] [-s SESSION_FILE] [--nowait]
|
|
44
|
+
{list,token,capabilities,currentoverview,storedoverview,trip_statistics,pictures,location,climatise_on,climatise_off,direct_charge_on,direct_charge_off,flash_indicators,honk_and_flash,lock_vehicle,unlock_vehicle,vehicle_closed,doors_and_lids,tire_pressure_status,tire_pressures,chargingprofile}
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
Porsche Connect CLI
|
|
48
|
+
|
|
49
|
+
positional arguments:
|
|
50
|
+
{list,token,capabilities,currentoverview,storedoverview,trip_statistics,pictures,location,climatise_on,climatise_off,direct_charge_on,direct_charge_off,flash_indicators,honk_and_flash,lock_vehicle,unlock_vehicle,vehicle_closed,doors_and_lids,tire_pressure_status,tire_pressures,chargingprofile}
|
|
51
|
+
command help
|
|
52
|
+
battery Prints the main battery level (BEV)
|
|
53
|
+
capabilities Get vehicle capabilities
|
|
54
|
+
chargingprofile Update parameters in configured charging profile
|
|
55
|
+
climatise_off Stop remote climatisation
|
|
56
|
+
climatise_on Start remote climatisation
|
|
57
|
+
connected Check if vehicle is on-line
|
|
58
|
+
currentoverview Get stored overview for vehicle
|
|
59
|
+
direct_charge_off Disable direct charging
|
|
60
|
+
direct_charge_on Enable direct charging
|
|
61
|
+
doors_and_lids List status of all doors and lids
|
|
62
|
+
flash_indicators Flash indicators
|
|
63
|
+
honk_and_flash Flash indicators and sound the horn
|
|
64
|
+
location Show location of vehicle
|
|
65
|
+
lock_vehicle Lock vehicle
|
|
66
|
+
pictures Get vehicle pictures url
|
|
67
|
+
storedoverview Poll vehicle for current overview
|
|
68
|
+
tire_status Check if tire pressure are ok
|
|
69
|
+
tire_pressures Get tire pressure readings
|
|
70
|
+
trip_statistics Get trip statistics from backend
|
|
71
|
+
unlock_vehicle Unlock vehicle
|
|
72
|
+
vehicle_closed Check if all doors and lids are closed
|
|
73
|
+
|
|
74
|
+
options:
|
|
75
|
+
-h, --help show this help message and exit
|
|
76
|
+
-d, --debug
|
|
77
|
+
-j, --json output in JSON format
|
|
78
|
+
-e EMAIL, --email EMAIL
|
|
79
|
+
-p PASSWORD, --password PASSWORD
|
|
80
|
+
-s SESSION_FILE, --sessionfile SESSION_FILE
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Config file (for CLI)
|
|
85
|
+
|
|
86
|
+
A config file is searched for in ~/.porscheconnect.cfg and ./.porscheconnect.cfg
|
|
87
|
+
The format is:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
[porsche]
|
|
91
|
+
email=<your email>
|
|
92
|
+
password=<your password>
|
|
93
|
+
session_file=<file to store session information>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Library usage
|
|
97
|
+
|
|
98
|
+
Install pyporscheconnectapi using pip (requires python >= 3.10)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
### Example client usage
|
|
102
|
+
|
|
103
|
+
Please refer to the examples provided in the repository.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Library to integrate with the Porsche Connect API.
|
|
2
|
+
|
|
3
|
+
This library provides a Python interface to Porsche Connect API, with
|
|
4
|
+
abilities to read vechicle status data and access to remote services
|
|
5
|
+
to control certain vechicle functions.
|
|
6
|
+
|
|
7
|
+
NOTE: This work is not officially supported by Porsche and functionality
|
|
8
|
+
can stop working at any time without warning.
|
|
9
|
+
|
|
10
|
+
"""
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Accesses Porsche Connect account and retrieves connected vehicles."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
from pyporscheconnectapi.connection import Connection
|
|
8
|
+
from pyporscheconnectapi.vehicle import PorscheVehicle
|
|
9
|
+
|
|
10
|
+
_LOGGER = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PorscheConnectAccount:
|
|
14
|
+
"""Establishes a connection to a Porsche Connect account."""
|
|
15
|
+
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
username: str | None = None,
|
|
19
|
+
password: str | None = None,
|
|
20
|
+
token: dict | None = None,
|
|
21
|
+
connection: Connection | None = None,
|
|
22
|
+
) -> None:
|
|
23
|
+
"""Initialize the account."""
|
|
24
|
+
self.vehicles: list[PorscheVehicle] = []
|
|
25
|
+
self.token = token
|
|
26
|
+
if connection is None:
|
|
27
|
+
self.connection = Connection(username, password, token=token)
|
|
28
|
+
else:
|
|
29
|
+
self.connection = connection
|
|
30
|
+
|
|
31
|
+
async def _init_vehicles(self) -> None:
|
|
32
|
+
"""Initialize vehicles from API endpoint."""
|
|
33
|
+
_LOGGER.debug("Building vehicle list")
|
|
34
|
+
|
|
35
|
+
if self.connection is not None:
|
|
36
|
+
vehicle_list = await self.connection.get("/connect/v1/vehicles")
|
|
37
|
+
|
|
38
|
+
for vehicle in vehicle_list:
|
|
39
|
+
_LOGGER.debug("Got vehicle %s", vehicle)
|
|
40
|
+
v = PorscheVehicle(
|
|
41
|
+
vin=vehicle["vin"],
|
|
42
|
+
data=vehicle,
|
|
43
|
+
status={},
|
|
44
|
+
connection=self.connection,
|
|
45
|
+
)
|
|
46
|
+
self.vehicles.append(v)
|
|
47
|
+
|
|
48
|
+
self.token = self.connection.token
|
|
49
|
+
|
|
50
|
+
async def get_vehicles(self, *, force_init: bool = False) -> list[PorscheVehicle]:
|
|
51
|
+
"""Retrieve available vehicles from API endpoints."""
|
|
52
|
+
_LOGGER.debug("Retrieving vehicle list")
|
|
53
|
+
|
|
54
|
+
if len(self.vehicles) == 0 or force_init:
|
|
55
|
+
await self._init_vehicles()
|
|
56
|
+
|
|
57
|
+
return self.vehicles
|
|
58
|
+
|
|
59
|
+
async def get_vehicle(self, vin: str) -> PorscheVehicle | None:
|
|
60
|
+
"""Retrieve vehicle data from API endpoints."""
|
|
61
|
+
if len(self.vehicles) == 0:
|
|
62
|
+
await self._init_vehicles()
|
|
63
|
+
filtered = [v for v in self.vehicles if v.vin == vin]
|
|
64
|
+
if len(filtered) > 0:
|
|
65
|
+
return filtered[0]
|
|
66
|
+
return None
|