Skip to main content

Library for interaction with the MySkoda APIs.

Project description

Version PyPi Downloads PyPi

MySkoda

This Python library can be used to work with the MySkoda API.

Getting Started

The MySkoda package is published to Pypi and can be found here.

It can be installed the usual way:

pip install myskoda

Primer

MySkoda relies on two ways to connect to the Skoda servers:

  • MQTT (For realtime information and for checking whether operations were performed by the car.)
  • HTTP Api (For retrieving detailed information and initiating operations.)

Performing Operations

Every operation is executed the following way:

  1. An HTTP request to the MySkoda servers is executed, initiating the desired operation (e.g. starting window heating)
  2. The HTTP request will immediately return status 200, no matter whether it is successful or not.
  3. An MQTT message with an OperationRequest is is published. It will be status IN_PROGRESS.
  4. At some point, the vehicle will pick up the operation and perform it.
  5. An MQTT message with an OperationRequest and status COMPLETED_SUCCESS will be published.
  6. The operation is completed.

Subscribing to Events

The vehicle will proactively send ServiceEvent messages to the MQTT broker. These events are very generic and most of them contain no meaningful data or information about what exactly happened.

When a message with ServiceEvent is received, detailed information can be gathered from the Rest API.

As Library

MySkoda relies on aiohttp which must be installed. A ClientSession must be opened and passed to MySkoda upon initialization.

After connecting, operations can be performed, events can be subscribed to and data can be loaded from the API.

Don't forget to close the session and disconnect MySkoda after you're done.

Basic example

from aiohttp import ClientSession
from myskoda import MySkoda

session = ClientSession()
myskoda = MySkoda(session)
await myskoda.connect(email, password)

for vin in await myskoda.list_vehicle_vins():
    print(vin)

myskoda.disconnect()
await session.close()

As CLI

The MySkoda package features a CLI. You will have to install it with extras cli:

pip install myskoda[cli]

Afterwards, the CLI is available in your current environment by invoking myskoda.

Username and password must be provided to the CLI for every request as options, before selecting a sub command:

myskoda --user "user@example.com" --password "super secret" list-vehicles

Help can be accessed the usual way:

myskoda --help

Usage

Subscribing to Events

After initializing (see basic example), it is possible to subscribe to events for a specific vehicle.

Internally, MySkoda will always connect to all MQTT topics that it can subscribe to, after loading a list of all vehicle identification numbers.

from myskoda.event import Event

def on_event(event: Event):
    pass

myskoda.subscribe(on_event)

The suggested approach is to check the event's type field to see what it contains. If you're using mypy or pyright, this will also narrow down the event's type and allow you to access specific fields:

from myskoda.event import Event, EventType, ServiceEventTopic

def on_event(event: Event):
    if event.type == EventType.SERVICE_EVENT:
        print("Received service event.")
        if event.topic == ServiceEventTopic.CHARGING:
            print(f"Battery is {event.event.data.soc}% charged.")

There is three types of events:

  • EventType.SERVICE_EVENT: Sent proactively by the vehicle, when something changed.
  • EventType.OPERATION: Sent by Skoda's server as response to an operation executed on the vehicle. It will track the operation's status.
  • EventType.ACCOUNT_EVENT

Fetching data

After initializing (see basic example), it is possible to fetch data directly from the MySkoda object. Simply call and await the getter for whatever data is needed.

Info

This endpoint contains static information about the vehicle, such as the engine type, the model and model year, settings and other things that seldomly change.

from myskoda.models.info import Info

vin = "TMBJB9NY6RF999999" # See `MySkoda.list_vehicle_vins()`.
info = await myskoda.get_info(vin)
print(f"Vehicle is a {info.get_model_name()}.")

Charging

Charging related information such as current battery soc and so on.

from myskoda.models.charging import Charging

vin = "TMBJB9NY6RF999999" # See `MySkoda.list_vehicle_vins()`.
charging: Charging = await myskoda.get_charging(vin)
soc = charging.status.battery.state_of_charge_in_percent
print(f"Vehicle is {soc}% charged.")

Status

All temporary status information for a vehicle, such whether it is locked or opened, the lights are on and therelike.

from myskoda.models.status import Status
from myskoda.models.common import DoorLockedState

vin = "TMBJB9NY6RF999999" # See `MySkoda.list_vehicle_vins()`.
status: Status = await myskoda.get_status(vin)
if status.overall.doors_locked == DoorLockedState.UNLOCKED:
    print("Vehicle is not locked.")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

myskoda-0.6.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

myskoda-0.6.0-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file myskoda-0.6.0.tar.gz.

File metadata

  • Download URL: myskoda-0.6.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for myskoda-0.6.0.tar.gz
Algorithm Hash digest
SHA256 841e066d8409c39b6cb3c436d60d01fba105bd8c235781f23c43e09413906804
MD5 d169fc27e469a878bb1004bdaa9e07f1
BLAKE2b-256 f36a004e3bb07d6eab10b3dee94bdf39ed87cec5bafa5bc28b33ecde60c1adc2

See more details on using hashes here.

File details

Details for the file myskoda-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: myskoda-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for myskoda-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2a700e5f4282e880641afbb662aaa816a0292b271482e3fa79a609299a6b536
MD5 4b2e62541b0f9073f02e106fd7b04c83
BLAKE2b-256 8818d7c8155ea5cadce3ae027d4229198cf63b435811a26e86732205c549242f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page