Integration for NissanConnect Services

Hi, you’re a hero for pulling all this together. The Leaf integration has never reliably worked in Home Assistant. I’ve never used MQTT/NodeRed before but the promise of this was enough to make me have a go. Between this thread and the readme on GitHub I managed to get it pulling data in for the first time in 5 years. Please find below a basic working configuration entry for a Leaf (2018 on) that I pulled together. I’ve added quotes around sensor names as that seems to be the standard, amended the battery labels for the V1 Leaf API, and added a degree mark for the C entry as HA complained about that. Hope this is a good start for any fellow (Gen2) Leafers. I wasn’t sure whether to put this here or GitHub but figured if i put it here you’d know what’s best. THANK YOU.

# configuration.yaml entry

device_tracker:
  - platform: mqtt_json
    devices:
      leaf: leaf/YOURVIN/location/json

mqtt:
  sensor:
    - name: "Leaf_battery_last_updated"
      state_topic: "leaf/YOURVIN/batteryStatus/lastUpdateTime"
      device_class: timestamp

    - name: "Leaf_battery_level"
      state_topic: "leaf/YOURVIN/batteryStatus/batteryLevel"
      unit_of_measurement: "%"
      device_class: battery

    - name: "Leaf_cabin_temperature"
      state_topic: "leaf/YOURVIN/hVacStatus/internalTemperature"
      device_class: temperature
      unit_of_measurement: "°C"
      
  binary_sensor:
    - name: "Leaf_plugged_Status"
      state_topic: "leaf/YOURVIN/batteryStatus/plugStatus"
      payload_on: "1"
      payload_off: "0"

    - name: "Leaf_charging_Status"
      state_topic: "leaf/YOURVIN/batteryStatus/chargeStatus"
      payload_on: "1"
      payload_off: "0"
      
    - name: "Leaf_climate_Status"
      state_topic: "leaf/YOURVIN/hVacStatus/hvacStatus"
      payload_on: "on"
      payload_off: "off"      
      

Hello,

Since the last update of home assistant 2023.4.5 nothing works anymore.
Do you have the same problem ?

I’m not on 2023.4.5 yet, but except some changes on MQTT yaml configuration I do not immeadiatly see breaking changes.

I think it was a bug because it works now. Sorry to bother you.

I’ve changed the username and password and seems to be connected but that’s where all the joy ends as trying to retrieve any information from the car just spits out an error.

I’ve tried everything, at least it feels like it. I changed my password twice now without any luck, maybe i’m not connected to the car after all as connecting the functions to a debug node one after one i discovered that i’m getting a 401 error code. I tripled checked my login credentials and they’re spelled correct.

Do anyone have the complete URL for the API, assuming it’s a REST API?
I have an education as a NodeJS developer and could probably make something myself if only I knew the URL and needed parameters to gain access. I find Node-RED extremely frustrating to work in.

I tried KevinVI/NissanConnect flows for the first time - thank you for the flows. Flows seemed to work as they should apart from the battery status which returned 501 with a message saying that it is not implemented. hVacStatus, location, tripHistory and LockStatus were succesfully retrieved. Anyone else having the same problem?

Hi, I’m also getting the same errors on mine. Has been working fine for a few weeks, and suddenly this morning it stopped working (can see errors in logs in NodeRed).

There is a message in the NissanConnect app warning about some maintenance coming up on the 23rd of April. The service will be down for an hour, I’m wondering if they’re changing stuff in the background like API calls/routes and so on and that’s the reason it stopped working for you?

What servers are you using, are you located in Europe?

I am using the default servers in the kevinVI’s flows (eu2.kamereon.io). I haven’t been able to check the battery status at all since I tried those flows yesterday for the very first time.

The whole error message from Node Red:
status: “Not Implemented”
code: “501”
title: “Not supported Feature”
detail: “This feature is not technically supported by this gateweay”

Yeah I did notice a message about maintenance. And yes, in based on Europe (Denmark).

Okay, Denmark here as well. Goddag. :slight_smile:

It looks to be broken, I’ll see if I can figure it out.

1 Like

Goddag!! I’m actually originally from the UK, but have been living in Aarhus for around 13 years. Lovely country :smiley:

To all, it’s fixed again, an updated NissanConnect flow added to the GIT

API authentication URL was changed by adding an additional required parameter, also the URL to get the car info was updated in version.

1 Like

Awesome work, thank you!

Hi again, so it’s probably my lack of understanding of NodeRed (still not my strong side), but what is the best way to import, or update my flows with the new updated one you’ve uploaded?

I just tried importing the new subflows, and I’ve tried injecting in the nodes in the first group at the top of the flow, and I just keep getting the error message shown below.

image

I ended up completely uninstalling Node Red, and started completely from scratch, but can’t seem to get it to work.

From what I can figure out, the error in debug says that there is something wrong with this function node.

Any idea what it could be? Do I still have the old url’s or something in the code in that function node? I’m also not seeing anything in MQTT explorer anymore…

Same for me. I’m getting the same errors and can’t seem to even login with Nissan services.
The issue seems to be somewhere in the NissanConnect-Session node, but there are a lot for functions in there, not sure where to being.

1 Like

Let’s hope @kefjevl can rescue us sometime soon. It would be awesome to at least get the battery status back, as we’ve just had solar panels installed, and the battery status would be awesome as part of EV charging automations.

Hi all, sorry it has been some crazy weeks so not really able to deep dive in the issues you are having,
find a video to the 2 places you need to change

Hi Kevin, I had just written a post to say it wasn’t working, as I could see the exact same things you showed in your video (thank you for that by the way), were as I had it in my flows, so all seemed correct, but was still not working.

But I decided to have another go, and I finally got it working again! This is exactly what I did.

  1. Deleted the NissanConnect flow, and all sub-flows from NodeRed
  2. Restarted NodeRed
  3. Imported your original flow from last month ( NissanConnectFlow-HA-NodeRed.json)
  4. Once imported, I went into the two functions shown in your video, and manually edited the two entrys (the extra url, and V5 instead of V4).
  5. In my NissanConnect app, I changed my password (just changed the last couple of characters).
  6. I then added my username and new password to the Set Flow-Vars/Config node
  7. Finally, double checked I still had my MQTT broker entered correctly.
  8. Once I’d done all this, it worked! I can now see my cars status.

Thanks for your help Kevin, it’s much appreciated :slight_smile:

2 Likes