Code Monkey home page Code Monkey logo

nissan-connect's Introduction

Nissan Connect

A Node js library for interacting with the Nissan Connect (Carwings) API. This provides a wrapper around the API to make it cleaner to use.

nissan-connect-app provides a front end and HTTP server, with local storage; using this module.

Example Usage

NissanConnect is promise based. Generated docs can be found here.

 const NissanConnect = require('nissan-connect');
 
 let nc = new NissanConnect('username','password');
 
 async function things() {
   //AC controls
   await nc.acOn();
   await nc.acOff();
   
   await nc.setAcSchedule('2017-11-04 07:30');
   
   let schedule = await nc.getAcSchedule();
   
   console.log(schedule.targetDate);
   
   // Battery status
   let status = await nc.getBatteryStatus();
   
   console.log(status.batteryStatus.chargeState);
   console.log(status.batteryStatus.timeToFull3kW);
   
   //Driving analysis
   let drivingAnalysis = await nc.getDrivingAnalysisWeek('2017-11-01');
   
   console.log(drivingAnalysis.startDate);
   drivingAnalysis.days.forEach(daySummary => {
     console.log(daySummary.targetDate);
     if (daySummary.hasData) {
      console.log(daySummary.averageEconomy);
      console.log(daySummary.regen);
     }
   });
 }
 
things().catch(console.error);

nissan-connect's People

Contributors

beejjacobs avatar suhajdab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nissan-connect's Issues

npm repo is not in sync with github

npm repo has a 1.1.0 which seams to be older that the latest 1.0.14 in github. In particular, the bug " add support for a login response with a VehicleInfoList, fixes #2 " is not fix in the official npm repo

sort out code which uses both await and promises

e.g.

async login(username, password) {
  const key = await this.connect();
  NissanConnectApi.log('logging in');
  return this.request(Config.endPoints.login, {
    UserId: username,
    Password: NissanConnectApi.encryptPassword(password, key)
  })
      .then(res => new LoginResponse(res));
}

could be

async login(username, password) {
  const key = await this.connect();
  NissanConnectApi.log('logging in');
  const res = await this.request(Config.endPoints.login, {
    UserId: username,
    Password: NissanConnectApi.encryptPassword(password, key)
  });
  return new LoginResponse(res);
}

login-response may contain vehicle list

the login response may contain a vehicleinfolist instead of a single vehicleinfo:

          "VehicleInfoList": {
                    "VehicleInfo": [
                            {
                                    "charger20066":"false",
                                    "nickname":"LEAF",
                                    "telematicsEnabled":"true",
                                    "vin":"1ABCDEFG2HIJKLM3N"
                            }
                    ],
                    "vehicleInfo": [
                            {
                                    "charger20066":"false",
                                    "nickname":"LEAF",
                                    "telematicsEnabled":"true",
                                    "vin":"1ABCDEFG2HIJKLM3N"
                            }
                    ]
            },

(yes, one with a lower case v and another with upper case V)
currently, in that case, login-response.js throws an exception at line 57

A quick fix to get it going was to add before line 57:

 if (this.res.hasOwnProperty('VehicleInfoList')) {
    this.res.vehicleInfo = this.res.VehicleInfoList.vehicleInfo;
 }

Endpoint has changed ?

Hi,

I am trying to use this module, without success. I get a 404 error, so I think the endpoint has changed.
Can anyone help ?

Thank you

unable to login

using the docs, I am unable to login anymore.

{ status: '-2010', message: 'INVALID PARAMS' }

debugging a little deeper

request:
uri: 'https://gdcportalgw.its-mo.com/api_v180117_NE/gdc/UserLoginRequest.php',
method: 'POST'

response:
{"status":404,"message":"INVALID PARAMS"}

password encoding error

looks like the password encoding is not correct. don't know enough about the process to know why exactly, but hopefully the following helps:

i'm comparing with the encoded password from pycarwings2 and the value seems to be different (first 10 characters are the same). if i take the result from the python library and hardcode it into the output of the encryptPassword function, then everything works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.