Metadata-Version: 2.4
Name: py-stellantis-ssdp
Version: 0.2.0
Summary: Async Python client for the Stellantis SSDP connected-car cloud API (Jeep 2.0 app)
Author-email: Igor Novgorodov <igor@novg.net>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/hass-uconnect/py-stellantis-ssdp
Project-URL: Issues, https://github.com/hass-uconnect/py-stellantis-ssdp/issues
Keywords: jeep,stellantis,ssdp,space,connected car,api,cloud
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.9
Requires-Dist: cryptography>=41
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-asyncio>=0.24; extra == "test"
Provides-Extra: dev
Requires-Dist: py-stellantis-ssdp[test]; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: mypy>=1.10; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

# py-stellantis-ssdp

Async Python client for the Stellantis **SSDP** connected-car cloud. This is the
backend of the "Jeep® 2.0" app, used by STLA-platform cars such as the Jeep Compass
MY2026.

Older Jeeps (and Fiat, Alfa Romeo, Ram, …) use the Uconnect cloud. For those, see
[py-uconnect](https://github.com/hass-uconnect/py-uconnect).

See [docs/API.md](docs/API.md).

## Install

```sh
pip install py-stellantis-ssdp
```

## Command line

```sh
# 1. Log in with the account email and password (prompted for, or SSDP_EMAIL
#    and SSDP_PASSWORD). "login --browser" logs in with a browser instead.
stellantis-ssdp login

stellantis-ssdp vehicles
stellantis-ssdp trips VIN --pages 0

# 2. Set up remote commands once: an SMS is sent to the account's phone
stellantis-ssdp enroll

# 3. Send commands (the PIN is needed when the remote token has to be renewed)
stellantis-ssdp --pin 1234 command VIN preconditioning_on
```

Tokens and the soft-token state are saved in `ssdp-state.json` (`--state`), with
permissions 0600. **Keep this file private**: it gives access to the car. The email
and password are never saved. If they are set (`--email`/`--password` or the
environment variables), the tool logs in again by itself when the saved login
expires.

## Library

```python
from stellantis_ssdp import JEEP_EU, Client, State, password_login
from stellantis_ssdp.remote import preconditioning

# Login (once)
state = State(token=await password_login(JEEP_EU, email, password))

# Later: the state changes as tokens are renewed, persist it every time. With the
# email and password the client logs in again if the refresh token stops working.
async with Client(
    JEEP_EU,
    state,
    pin="1234",
    email=email,
    password=password,
    on_state_change=save,
) as client:
    vehicles = await client.refresh()
    for vin, vehicle in vehicles.items():
        print(vin, vehicle.state_of_charge, vehicle.locked, vehicle.location)

    if not client.enrolled:
        await client.enroll_start()  # sends the SMS
        await client.enroll_finish(sms_code, "1234")

    await client.command_verify(vin, preconditioning(True))
```

`State.to_dict()` and `State.from_dict()` serialize everything that needs to be
kept. If the state is lost, the user has to log in and enroll again.
`Client.from_credentials()` does the login and creates the client in one step.

To log in with a browser instead, show `login_request(JEEP_EU).url` to the user and
pass the final `sp4je://oauth2redirect/?code=...` URL to `exchange_code()`.

## How it works

- **Login**: OAuth2 + PKCE against ForgeRock AM (`idpcvs.stellantis.com`) and the
  Stellantis Central Login Page (Gigya). The library replays the browser's steps
  with the email and password, so no browser is needed. After that, the tokens
  are renewed automatically.
- **Data**: the SSDP gateway (`apic-token-eu.ssdp.stellantis.com`): vehicle list,
  latest telemetry, trips and charging sessions.
- **Remote commands**: a second token (RCZ) is needed. It is obtained with a one-time
  password from an inWebo soft token, which is activated once with an SMS code and
  the user's PIN. The inWebo client is a clean-room implementation of the protocol
  used by the app.

## License

Apache-2.0
