Skip to main content

Communicate with Volkswagen WeConnect

Project description

Volkswagen Carnet

buy me a coffee

Release PyPi Version

Downloads a day Downloads a week Downloads a month

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
import volkswagencarnet
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 = volkswagencarnet.Connection(session, VW_USERNAME, VW_PASSWORD)
        if await connection._login():
            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())

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-4.4.24.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

volkswagencarnet-4.4.24-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file volkswagencarnet-4.4.24.tar.gz.

File metadata

  • Download URL: volkswagencarnet-4.4.24.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for volkswagencarnet-4.4.24.tar.gz
Algorithm Hash digest
SHA256 7566d898bc59c8ca95bbae48d8a2f10b5585c7b5fca62653b80dbe465d8cc966
MD5 dc0dcff6806cd7996e41e06bc1c36fe1
BLAKE2b-256 d420e2c0dc245ab198ef2f4e96bde13d37587af2e2679d6267b615c774ba6e55

See more details on using hashes here.

Provenance

File details

Details for the file volkswagencarnet-4.4.24-py3-none-any.whl.

File metadata

  • Download URL: volkswagencarnet-4.4.24-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for volkswagencarnet-4.4.24-py3-none-any.whl
Algorithm Hash digest
SHA256 eddbb2fbeccca239921e29bd0183c40599990bcb083723d661ce46b543d0e785
MD5 4005ffab7dd59996b35d2c5d7e83423d
BLAKE2b-256 643f35966ae7791d3347f12b8739b5f945726af8ffb0a402d5d5a733cf2b3d77

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