Skip to main content

Communicate with Volkswagen Connect

Project description

Volkswagen Carnet

buy me a coffee

Release PyPi Version CodeStyle Known Vulnerabilities CodeQL codecov

Downloads a day Downloads a week Downloads a month

Help Wanted

As i don't have a car with Volkswagen Connect anymore i would appreciate if it would be possible to get help to keep this repository maintained. So if you feel that you have some time over and is interested in helping out with this. Please feel to contact me! Thanks

Information

Retrieve statistics about your Volkswagen from the Volkswagen Carnet online service

No licence, public domain, no guarantees, feel free to use for anything. Please contribute improvements/bugfixes etc.

Thanks to

For supporting and helping in this project.

Other related repositories

Installation

[venv-python3] user@localhost:~
$ pip install volkswagencarnet

Example

#!/usr/bin/env python3
from volkswagencarnet.vw_connection import Connection
import pprint
import asyncio
import logging

from aiohttp import ClientSession

logging.basicConfig(level=logging.DEBUG)

VW_USERNAME='test@example.com'
VW_PASSWORD='mysecretpassword'


COMPONENTS = {
    'sensor': 'sensor',
    'binary_sensor': 'binary_sensor',
    'lock': 'lock',
    'device_tracker': 'device_tracker',
    'switch': 'switch',
    'climate': 'climate'
}

RESOURCES = [
    'position',
    'distance',
    'electric_climatisation',
    'combustion_climatisation',
    'window_heater',
    'combustion_engine_heating',
    'charging',
    'adblue_level',
    'battery_level',
    'fuel_level',
    'service_inspection',
    'oil_inspection',
    'last_connected',
    'charging_time_left',
    'electric_range',
    'combustion_range',
    'combined_range',
    'charge_max_ampere',
    'climatisation_target_temperature',
    'external_power',
    'parking_light',
    'climatisation_without_external_power',
    'door_locked',
    'trunk_locked',
    'request_in_progress',
    'windows_closed',
    'sunroof_closed',
    'trip_last_average_speed',
    'trip_last_average_electric_consumption',
    'trip_last_average_fuel_consumption',
    'trip_last_duration',
    'trip_last_length'
]

def is_enabled(attr):
    """Return true if the user has enabled the resource."""
    return attr in RESOURCES

async def main():
    """Main method."""
    async with ClientSession(headers={'Connection': 'keep-alive'}) as session:
        connection = Connection(session, VW_USERNAME, VW_PASSWORD)
        if await connection.doLogin():
            if await connection.update():
                # Print overall state
                pprint.pprint(connection._state)

                # Print vehicles
                for vehicle in connection.vehicles:
                    pprint.pprint(vehicle)

                # get all instruments
                instruments = set()
                for vehicle in connection.vehicles:
                    dashboard = vehicle.dashboard(mutable=True)

                    for instrument in (
                            instrument
                            for instrument in dashboard.instruments
                            if instrument.component in COMPONENTS
                            and is_enabled(instrument.slug_attr)):

                        instruments.add(instrument)

                # Output all supported instruments
                for instrument in instruments:
                    print(f'name: {instrument.full_name}')
                    print(f'str_state: {instrument.str_state}')
                    print(f'state: {instrument.state}')
                    print(f'supported: {instrument.is_supported}')
                    print(f'attr: {instrument.attr}')
                    print(f'attributes: {instrument.attributes}')

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    # loop.run(main())
    loop.run_until_complete(main())

Development

I'd strongly advise installing the git pre-commit hook using pre-commit install. See pre-commit.com for details. Some basic checks are performed before you commit the code, so code style issues will be visible and fixable before creating the PR. Git pre-commit hooks can always be skipped using the --no-verify flag to git commit, if there is something preventing you from actually fixing the reported (and non-auto-fixed) issues.

Decent test coverage for any new or changed code is also much appreciated :)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

volkswagencarnet-5.0.0b2.tar.gz (75.3 kB view details)

Uploaded Source

Built Distribution

volkswagencarnet-5.0.0b2-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file volkswagencarnet-5.0.0b2.tar.gz.

File metadata

  • Download URL: volkswagencarnet-5.0.0b2.tar.gz
  • Upload date:
  • Size: 75.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for volkswagencarnet-5.0.0b2.tar.gz
Algorithm Hash digest
SHA256 351443ef0aae0c51d2722178ae2712281508bde0deb5d4235d32301b0aa77b35
MD5 ad57f77af205ea026b40c4b2356e3d2a
BLAKE2b-256 95a9073a23c2c675fbd6907884ff4eb3af3627d4ff488a04ed75480ceccb5b68

See more details on using hashes here.

Provenance

File details

Details for the file volkswagencarnet-5.0.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for volkswagencarnet-5.0.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cbdef1a177825660556e809d21a89ffdf82d83378992f85683da8c1e8119f9b
MD5 3731f235c8a57d9721fe537fd7ccbbf8
BLAKE2b-256 d61780ca1e9232853075756076a1ba916c3437d8f3cd85cb23bd72badf526e1c

See more details on using hashes here.

Provenance

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