Nissan Leaf Component(s)/Platform

I archived my repository (yp87/leaf2mqtt) since I don’t use it anymore because it has reliability issues caused by Nissan always looking for a way to break third party integrations.

@TNT_Larsn, @andyc , since it looks like you would like to keep using it, I unarchived and updated the libraries to latest version. Please tag me here if they need to be updated again as I won’t be using it, I won’t know if it stopped working.

@TNT_Larsn, I added support for arm64. I tried it on my raspberry pi 2, but it did not work since it needs arm/v7 support (32 bit) and it gives me an error when I try to build with it. If you have a Raspberry pi 3 or newer with 64 bit, it could work, you have to try it (Use the same image as below).

The docker image is available on dockerhub: yp87/leaf2mqtt:latest

2 Likes

@Sriracha, thank you so much; that’s brilliant and very much appreciated.

More than happy to let you know the next time it stops working. You’re very kind to rebuild it now that you’re not even using it yourself!

1 Like

@Sriracha I also thank you very much. If you provide a personal link to https://www.buymeacoffee.com/ I would donate one … or two … or even three :laughing:
Once again! Thank you

1 Like

@TNT_Larsn Did it work for your Raspberry pi?

Also thank you but, no, I don’t take donations :slight_smile: There is so many people who work way way more for free on home assistant, you could donate there, or to Tobias, the My Leaf author who builds the libraries used by leaf2mqtt, he takes donations through the My Leaf app.

Timing on this could not be more perfect. I just stumbled upon your image and turned it into a local add-on. It’s running on Home Assistant Blue, so I can confirm the arm64 version works fine (on my 2016 Canadian leaf).

This is great, thank you for the work you’ve put into this.

1 Like

I have not created a real add-on yet, but for those interested, you can create a local add-on by creating a folder in /addons called leaf2mqtt

Then create a file called config.json containing the following

{
	"name": "Leaf2MQTT",
	"version": "latest",
	"slug": "leaf2mqtt",
	"description": "Leaf2MQTT add-on",
	"startup": "application",
	"url": "https://github.com/yp87/leaf2mqtt",
	"image": "yp87/leaf2mqtt",
	"arch": ["aarch64", "amd64"],
	"environment": {
		"LEAF_USERNAME": "",
		"LEAF_PASSWORD": "",
		"LEAF_TYPE": "",
		"MQTT_HOST": "",
		"MQTT_PORT": "1883",
		"MQTT_USERNAME": "",
		"MQTT_PASSWORD": "",
		"MQTT_BASE_TOPIC": "leaf",
		"UPDATE_INTERVAL_MINUTES": "60",
		"CHARGING_UPDATE_INTERVAL_MINUTES": "15",
		"COMMAND_ATTEMPTS": "5",
		"LOG_LEVEL": "Warning"
	}
}

Edit environment variables as required. This pulls the latest image, so you can uninstall and install again to update when needed.

You can also add icon.png and logo.png in the /addons/leaf2mqtt folder with the following image for some nice visuals.

logo

4 Likes

Thank you. Works like a charm

I get the error

SEVERE: 2022-05-04 17:16:12.055273: main: V0.10

When I run the addon.

My login credentials are 100% correct as I verified them with the My Leaf app. I have an MQTT broker setup and working.

The code I’m using

{
    "name": "Leaf2MQTT",
    "version": "latest",
    "slug": "leaf2mqtt",
    "description": "Leaf2MQTT add-on",
    "startup": "application",
    "url": "https://github.com/yp87/leaf2mqtt",
    "image": "yp87/leaf2mqtt",
    "arch": ["aarch64", "amd64"],
    "environment": {
        "LEAF_USERNAME": "my_email_address",
        "LEAF_PASSWORD": "my_password",
        "LEAF_TYPE": "newerThanMay2019",
        "MQTT_HOST": "192.168.0.238",
        "MQTT_PORT": "1883",
        "MQTT_USERNAME": "mqtt",
        "MQTT_PASSWORD": "mqtt",
        "MQTT_BASE_TOPIC": "leaf",
        "UPDATE_INTERVAL_MINUTES": "60",
        "CHARGING_UPDATE_INTERVAL_MINUTES": "15",
        "COMMAND_ATTEMPTS": "5",
        "LOG_LEVEL": "Warning"
    }
}

When logging into the My Leaf app i need to select ‘World’. I don’t know if that is relevant…

Any ideas?

Try setting log level to Info. Should give you more details.

Are you able to run the image normally (not as an addon)?

I get the same result running as a docker container on my Ubuntu VM. I’ll try changing the logging and see what it says.

Unfortunately setting the log level to Info didn’t yield any more information from the log.

Hello!
This log is there to ensure we see the version no matter the log level. It is not a real error.

I can reduce the severity of this log since I did not really update the version with each changes anyway

So if I don’t get any other messages in the log. Does that mean the add-on is functioning correctly?

The best way to see if it is working correctly is to try it by refreshing battery information, starting climate, etc :slight_smile:

I would not assume that it is correctly working if there is no apparent issues in the logs.

I did the change, there should be a new docker image available soon

Thanks. I uninstalled and reinstalled and it’s working now with same config as before. Thanks buddy

1 Like

Thanks to @EtienneMD, his addon configuration is now part of the leaf2mqtt repository.

Home Assistant add-on

Click the icon below to add this repository to your Home Assistant instance or follow the procedure highlighted on the Home Assistant website.

Install leaf2mqtt add-on repo.

This seems promising! How do you configure it once added as an add-on?

Everything is configured on the add-on configuration page.

More info on configuration options on the project repo.

1 Like

Thanks—had to uninstall/reinstall. It works! Though, like previous versions, it still doesn’t seem to update the battery as reliably as the climate/location. Might post some logs later after a little more observation.

I’m really pleased for the possibility to integrate our car into Home Assistant, via Leaf2Mqtt. I went through this post and learned that @Sriracha has been really kind and kept updating the addon for the rest of us. Amazing!

I do need some help however with extracting the stats values. I don’t seem to get anything out - I’m checking with MQTT explorer as well as the listener tool in Home Assistant. It would be interesting to get the kilometersPerKwh and the kwhUsed etc.

I did race an issue - stats - help needed · Issue #32 · yp87/leaf2mqtt · GitHub, but perhaps it’s only something simple I’m missing. I’ve noticed there is a tripHistory and therefor tried swopping stats to tripHistory to alter the dates, but no luck.

Could someone help please…