Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
/ leaf2mqtt Public archive

Pull in data from the Nissan Connect platform for the LEAF and publish over MQTT

License

Notifications You must be signed in to change notification settings

Troon/leaf2mqtt

Repository files navigation

leaf2mqtt

Use this at your own risk. No liability is accepted for any negative consequences.

You probably want to use this fork which has a native Dart MQTT client. I'm no longer maintaining this one as I don't have the LEAF any more.

Builds a Docker container to pull in data from the Nissan Connect platform for the LEAF and publish over MQTT, using Tobias Westergaard Kjeldsen's excellent dartnissanconnect library which is also the basis for the MyLeaf app. Climate on/off control is available, but beware that it is slow and unreliable.

This works for my UK-based 2020 LEAF 40kWh car, and should work for any European LEAF that uses the NissanConnect app (Android or iOS). Please ensure you have installed the app and can communicate with the car before proceeding with this.

This will not work for older "original-shape" LEAFs. Don't waste any time trying.

You must have a working MQTT server on your LAN. The container uses mosquitto for publishing its data. I use this for interfacing with Home Assistant (running on a Synology NAS, hence the Docker container approach) via MQTT sensors: see leaf-sensors.yaml, leaf-binary-sensors.yaml, leaf-template.yaml and leaf-switches.yaml for examples (and replace the MY_VIN with your VIN from the MQTT messages once you have the steps below working!).

You must also have a working Docker installation, and be comfortable building images and running them as containers. Should work fine for x86_64 architectures; others may need a little work, particularly for the dart installation step.

Please note that I created this for my own personal use and am not looking for feedback, issues, feature requests etc. It's provided here as a starting point for your own projects.

Instructions

  1. Create a folder e.g. leaf2mqtt
  2. Drop all these files into that folder (Code button, Download ZIP).
  3. cd into that folder
  4. Run sudo docker build --tag leaf2mqtt ., which will prompt you for your sudo password, and then take quite a while to complete. You'll see a lot of Removing messages: this is just slimming down the image by removing intermediate packages that aren't required at runtime.
  5. That should have created a leaf2mqtt image: now you need to fire up a container from it. Doesn't need filesystem access, but you need to set five or seven environment variables:
    1. TZ: Set this to your timezone. Mine is Europe/London.
    2. MQTTTOPIC: I set this to leaf and you should too unless you have a good reason not to
    3. MQTTHOST: LAN IP address of your MQTT broker.
    4. USERNAME: your NissanConnect username — the one you use to log into the app.
    5. PASSWORD: your NissanConnect password — the one you use to log into the app.
    6. MQTTUSER: (optional) Username for your MQTT broker.
    7. MQTTPASS: (optional) Password for your MQTT broker.

If all goes well, you should start to see the messages coming through on MQTT.

You request updates over MQTT: see leaf-switches.yaml. It's up to you how and when you request an update: keep it to a minimum for the sake of your 12V battery. See leaf-automations.yaml for some inspiration.

About

Pull in data from the Nissan Connect platform for the LEAF and publish over MQTT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published