Git Product home page Git Product logo

leaf's Introduction

Leaf

GoDoc

leaf is a Go package and command-line tool providing access to the Nissan Leaf North American NissanConnect EV API.

Through this API you can ask your vehicle for the latest battery status, start charging remotely, start or stop climate control remotely, and retrieve the last known location of the vehicle.

This repo replaces my Carwings project, which implemented an older but global API. This API only works for North American vehicles (and I've only tested on a vehicle in the US, so it may not work in Canada).

Command-line tool

The leaf tool can be installed with:

go get github.com/joeshaw/leaf/cmd/leaf

Run leaf by itself to see full usage information.

To update vehicle information:

leaf -username <username> -password <password> update

To get latest battery status:

leaf -username <username> -password <password> battery

This will print something like:

Getting last updated battery status...
Battery status as of 2020-12-26 11:35:58 -0500 EST:
  Battery remaining: 91%
  Cruising range: 88 miles (83 miles with heat/AC)
  Plug-in state: connected
  Charging status: yes
  Time to full:
    Level 1 charge: 8h30m
    Level 2 charge: 3h0m
    Level 2 at 6 kW: 2h0m

For some people the username is an email address. For others it's a distinct username.

Config values can be provided through environment variables (such as LEAF_USERNAME) or in a ~/.leaf file in the format:

username <username>
password <password>
country US

NissanConnect North America protocol

Ben Woodford put together the first protocol reference, and several people have added onto that Gist.

Tobias Westergaard Kjeldsen has created a Dart library for this API which he uses in his My Leaf app for Android and iOS.

Contributing

Issues and pull requests are welcome. When filing a PR, please make sure the code has been run through gofmt.

License

Copyright 2017-2020 Joe Shaw

leaf is licensed under the MIT License. See the LICENSE file for details.

leaf's People

Contributors

joeshaw avatar stgraber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

leaf's Issues

Get climate status

Hey there,

Thanks for the great work!
The integration I've been using in home-assistant for a while recently broke so I've now switched over to using this Go package to build a basic daemon that pushes the data over MQTT as well as support triggering the climate control over it.

The main thing I'm missing is a boolean for whether the climate control is active or not.
This is something I used to have in the other implementation so presumably that should be available somewhere in the API.

I don't know if this is a currently missing field coming as part of the info/battery data or if this would need a separate API call just to retrieve it, but given that climate control turns itself off after 15min or if the car is started, it'd be good to be able to get that state so I can render a proper on/off switch for it.

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.