Nissan Leaf Component(s)/Platform

It I recall, the plugin can’t recover from a session dropping out, which is then sorted when you restart HASS. The Nissan app has a habit of doing this too.

If someone has the time, it may take a bit if fiddling but it should be fixable. I just don’t really have time to do it myself

1 Like

The leaf2mqtt container posted a few comments above is resilient to the different issues the Nissan API has. If you are willing to setup an mqtt server and spin the container, you may have better results than the home assistant native integration.

1 Like

Hi Ben. That sounds like a good place to start. I appreciate you taking the time to give me this insight. I am ok at coding, but don’t do it every day, so would you mind giving me some pointers as to how a fix might be approached? If you don’t have time, that’s fine but it would be great if you could!

There’s a fix in the latest version of pycarwings2 that helps with handling timeouts properly. That will be in the next release of homeassistant.

1 Like

That’s fantastic, thanks.

Anyone have any problem with Leaf integration over last few days?

It started just before 2022.2 dropped, I was still on latest 2021.12. So I suspect there had been some issue with their servers?

Here is an issue someone raised:

------------EDIT: ----------

Problem is at my end entirely. I had been self-isolating because of COVID, the car parked for 2 weeks. I guess it had gone into some sort of deep sleep after 10 days.

Drove it today and then restarted HA, everything is back now.

I think was a Nissan server problem.

By(t)e

I seem to be experiencing this issue intermittently too - I wonder if this fix has gone in yet ? I’m currently running Home Assistant 2022.2.0, however I see there are more recent versions available now.

Once the problem occurs it seems to keep trying over and over:

2022-02-11 03:49:25 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 03:59:25.077115+00:00
2022-02-11 03:59:25 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Updating Nissan Leaf Data
2022-02-11 03:59:25 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Requesting battery update, ------------
2022-02-11 03:59:30 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Waiting 40 seconds for battery update (------------) (0)
2022-02-11 06:10:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:10:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 06:20:31.035472+00:00
2022-02-11 06:13:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:13:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 06:23:31.051176+00:00
2022-02-11 06:23:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:23:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 06:33:31.053155+00:00
2022-02-11 06:33:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:33:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 06:43:31.055493+00:00
2022-02-11 06:43:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:43:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 06:53:31.057836+00:00
2022-02-11 06:53:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr
2022-02-11 06:53:31 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Next update=2022-02-11 07:03:31.060533+00:00
2022-02-11 07:00:36 DEBUG (MainThread) [homeassistant.components.nissan_leaf] Refresh currently in progress for Leaf1sbyr

Because it happened at the end of a charging session the most recent state was that the car was charging so the integration was following the 10 minute update_interval_charging I have configured, rather than the 3 hour update_interval. Hopefully it wasn’t actually causing the car to be polled this often while unplugged!

I use the Leaf integration as part of a custom charge limiter dashboard to let me set a weekly charge limit schedule so I soon notice if anything goes wrong with the API overnight. (The car charges to 100% instead of what I have scheduled)

So far I think I’ve only had 3 failures in the last couple of months, which is pretty good considering how unreliable the Nissan API used to be, however all of these failures have required a restart of home assistant to get things working again even after other clients are able to use the API again.

Hey thanks for putting that 40 second change in!

Regarding the change to the behaviour of the climate control switch entity - do I need to change anything on my dashboard for this, as the climate switch still seems to behave the same way under 2022.2.0 where it reports an error after the state of the switch is manually toggled even though the command does go to the car.

Hi, I’ve used this integration for quite some time now and I’ve done a bunch of the manual fixes posted above.

I just wanted to say thanks for all the hard work, the integration works better than ever before.

Great work guys!

1 Like

Are there currently any working solutions for Leafs newer than 2019? I see the creator of Leaf2MQTT has archived his repo on GitHub and the container is currently failing to login.

@Sriracha 's leaf2mqtt still works for my 2022 USA Leaf. But with the way things have been going, and Nissan’s continuing attempts to break third-party access (see this Google group run by the developer of leaf2mqtt’s underlying library), it’s probably only a matter of time before Nissan breaks it again. And with @Sriracha (understandably) not wanting to keep playing cat-and-mouse with Nissan, I guess leaf2mqtt will eventually be nonfunctional. Hopefully someone with the know-how can take it over.

Depending on the region and the year of the car, leaf2mqtt may continue to work, but unfortunately, it is not the case for my region/model year.

I implemented a workaround, it is more custom and more work to implement, but since then, it was very reliable for me.

My current solution is to have a rooted old android always plugged and install Tasker, AutoInput and Join on it. Also activate the Join integration in Home Assistant.
Home assistant will send a command to the phone through Join (Refresh, StartClimate, StartCharging) and then the phone will use Tasker and autoInput to simulate the button presses on the screen in order to achieve what I need. AutoInput can also scan the screen to fetch information like battery, plugged status, charging status and temperature.

Home assistant will use the refresh date that is returned by tasker (through Home assistant rest api) and retry the refresh until the date is less than 10 minutes old (it will stop after 5 tries). It will also send the startCharge and startClimate multiple times just to be sure.

Now they can change the the way the app gets the api key, but as long as the UI does not change, this solution will continue to work.

My OG leaf2mqtt (GitHub - Troon/leaf2mqtt: Pull in data from the Nissan Connect platform for the LEAF and publish over MQTT) just stopped working for the first time in ages. Nissan have changed the authentication key. Luckily, Tobias Westergaard Kjeldsen (author of the underlying library) is on the ball and has already updated.

I rebuilt my Docker container to pull in his new updates and all is well again :slight_smile: .

Thanks a bunch! Hadn’t even realized that the one I was using had stopped updating.
Had to do some minor tweaks, but got your image up and running :blush:

1 Like

Thanks for sharing this. My instance of yp87’s container stopped working on the 29th too. If you could please share what “tweaks” you had to apply, that would be greatly appreciated. I’ve tried rebuilding both Troon’s image and yp87’s one, but had (different) problems in both cases.

I have a late 2019 UK Leaf, so I believe either fork should be compatible with my car. Knowing which tunnel has a light at the end could save me a lot of time! :slightly_smiling_face: Thanks very much!

none of these docker images is “arm64” compatible. I’d love to see a version that runs native on a raspberry pi (My Homeassistant-Instance). Maybe someone can post a “howto” for a non advanced user. Had yp87/leaf2mqtt running on my Mac but now it’s deprecated. Tobias Westergaard Kjeldsen / dartnissanconnect · GitLab was already updated, but I dont understand why yp87/leaf2mqtt isn’t.

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