npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-vw-carnet

v0.0.4

Published

Connects to the VW Car-Net via the we-connect portal.

Downloads

57

Readme

node-vw-carnet

A client that can be used to call the Volkswagen Car-Net API via the We Connect portal. Since Volkswagen does not yet provide an open API, this module can be used as a workaround.

NOTE: This library will break when Volkswagen changes their We Connect/Car-Net portal.

To login and get valid session cookies, puppeteer is used. The library can be used with either puppeteer or puppeteer-core.

Example

Here is an example where this library is used in a REST API on a AWS Lambda.

Installation

# install puppeteer
npm i puppeteer -S

# (or puppeteer-core)
# npm i puppeteer-core -S

npm i node-vw-carnet -S

Usage

The main function in all examples below are called like this:

main()
.then(() => process.exit(0))
.catch(err => {
  console.log('ERROR!', err);
  process.exit(1);
});

Login

It takes a long time to log in (normally around 5-20 seconds). The reason is that the We-Connect portal takes some time to respond. Once the login is complete, you can save the CarnetAPIClient instance (or information) and call the Car-Net API directly (this is done with node-fetch) and the responses from these calls are usually quick.

With puppeteer

import puppeteer from 'puppeteer';
import CarnetLoginHandler from 'node-vw-carnet';
 
async function main() {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  // Create the puppeteer login client by sending in
  // the puppeteer.Page (and a optional logger, can be skipped).
  const handler = new CarnetLoginHandler(page, console);

  // Try to login with your username and password.
  // The login will take ~10 seconds... 
  const client = await handler.createClient({
    email: process.env.EMAIL, // your carnet email
    password: process.env.PASS // your carnet password
  });

  // Close chrome browser since it's not needed anymore.
  await browser.close();

  // Successful login, now use the client.
  // Get car details.
  const details = await client.loadCarDetails();
  console.log('car details:', details);

  // Start the climate heater.
  const response = await client.triggerClimatisation(true);
  console.log('response:', response);
}

With puppeteer-core

import puppeteer from 'puppeteer-core';
import CarnetLoginHandler from 'node-vw-carnet';

async function main() {
  const browser = await puppeteer.launch({  
    executablePath: '<path to chrome>' // /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
  });

  // ...
}

Available client methods

The following methods are available on the CarnetAPIClient. All methods returns Promise<CarNetJSONResponse>

interface CarNetJSONRespose {
  [x: string]: any;
  // If errorCode is '0' the request was successfull
  errorCode: string;
}
getLocation()
getFullyLoadedCars()
getCompleteVehicleJson()
loadCarDetails()
triggerClimatisation(on: boolean)
triggerWindowheating()
getPSPStatus()
getVehicleDetails()
getVehicleStatusReport()
getLatestReport()
getEmanager()
getLatestTripStatistics()
// Can be used if this library have missed a certain method.
triggerAction(url, body = null)

Building

# clone this repo
git clone https://github.com/nekman/node-vw-carnet.git

# install dependencies
npm i

# lint
npm run eslint

# manual test
EMAIL=<your carnet email> PASS=<your carnet pass> npm run manual:test

Q: Why puppeteer?

A: Easier to login to the We Connect Portal. I can of course do like other libraries and perform all required login steps, but next time Volkswagen changes their We Connect portal a new time consuming login procedure needs to be implemented. Changes will be easier to handle with Puppeteer.