Nissan Leaf Component(s)/Platform

I have an automation that will poll 30 seconds after polling, using an additional input_boolean. Been running for weeks now without issue.

- action:
  - entity_id: input_boolean.leaf_repeat
    service: input_boolean.turn_on
  - delay: 00:00:30
  - service: nissan_leaf.update
    data:
      vin: 'XXXXXXX123456789'             # replace
  - delay: 00:10:00
  - entity_id: input_boolean.leaf_repeat
    service: input_boolean.turn_off
  alias: Leaf Double Take
  condition:
    - condition: state
      entity_id: input_boolean.leaf_repeat
      state: 'off'
  id: '4896215945484'
  trigger:
  - entity_id: sensor.leaf_updating
    platform: state
    to: 'False'

and the input_boolean

input_boolean:
  leaf_repeat:
    name: Leaf Repeat
    initial: off
    icon: mdi:leaf

EDIT: Here is the sensor missed from the original post.

  - platform: template
    sensors:
      leaf_updating:
        friendly_name: 'Leaf Update Status'
        value_template: "{{ state_attr('sensor.CHANGEME_charge', 'update_in_progress') }}"

I would love to try this, but I am too new to understand this 100%.

How does “sensor.leaf_updating” figure into this? Is that based on a sensor-template, or is that what you set when you manually or by automation check for update?

Thanks in advance!

You’re right, I missed that, it is indeed another sensor, here it is, just change the necessary parts.

  - platform: template
    sensors:
      leaf_updating:
        friendly_name: 'Leaf Update Status'
        value_template: "{{ state_attr('sensor.CHANGEME_charge', 'update_in_progress') }}"
  

Hello all.
I’m owing a 2019 Nissan Leaf and as a noob, I tried to follow all thoses config files but without succes. Are those files ok for my 2019 car ?
I allready put the files in “custom-components/nissan-leaf”, copy the script, include the sensor and nissan_leaf in config yaml but… no success.
Someone could write a step by step how to in order to point my mistake ?

No one to help me ? Really ?

Just doesnt work for any newer than may -19.

Someone has started developing a >May-19 Leaf component, but the development unfortunately stalled.

https://github.com/mitchellrj/kamereon-python

I do have this running as a custom component which ‘works’ however it has an OAUTH timeout issue which I cannot quite figure out as not able to tell if it’s using the built-in HASS OAUTH schema and how to have it automatically renew. My Python skills are far too basic to adapt this, but all the hard work of the extracting data from the API to HASS is done.

2 Likes

This is great, I’ve missed this component since I changed to a newer Leaf, let’s encourage the developer to continue!

@mitsumaui

How did you actually set this up in HA? The installation of the custom component I’m onboard with, but what config are you using to provide user-name and password?

i have exactly the same issue. i hope somebody hass the solution

update

sorry made an typo i now have it in hass on tuesday i get my leaf so i can try if i then have the new sensors

Great !
Can you write a “how to” as you say that you have install this as a custom component ?
(noob here…)
Thanks

You can install a custom component by:

  • Create a custom_components folder in your configuration directory
  • Download the GitHub repo as a zip file
  • Extract the kamereon folder (not the kamereon-python-master one - but the child folder underneath) to inside the custom_components folder
  • add configuration parameters to your configuration.yaml in home-assistant and restart

The configuration parameters I used are:

kamereon:
  username: {nissan username}
  password: {nissan password}
  manufacturer: "nissan"
  region: "EU"
1 Like

Thanks, I was missing what config item to use.

Having this “working”, there aren’t many sensors that gives data. Battery level is probably the one I’m missing most, but also a switch for remote start to climate would be great.

But this is a great start, I wish I had some better coding skills myself so that I could continue the development since the original developer seems to have stopped working on this.

Same here - I spent lastnight looking through other components to see how they have implemented OAuth so I could reuse anything they have done but it’s likely my lack of understanding that’s failing me more.

Sensors should not be too hard to add, but really the token refresh needs to be fixed first before it can develop further. I have been looking to see if there is somewhere I can ask for help…

Thank you very much for this reply.
Will give it a try as soon as possible.

Hi guys,

I’m having few issues.

  1. Can’t make a charge button working. Here is the code:
    type: button
    tap_action:
    action: call-service
    service: nissan_leaf.start_charge
    data:
    vin: SJNFAAZE0*********
    hold_action:
    action: none
    show_state: true
    name: START_CHARGE
    show_icon: true

It is returning “Failed to call service nissan_leaf/start_charge. required key not provided @ data[‘vin’]” on trigger.

Another thing - can’t get this part of configuration to work:
update_interval:
hours: 1
update_interval_charging:
minutes: 15
update_interval_climate:
minutes: 5
force_miles: true

System not parsing it:
Error loading /config/configuration.yaml: while parsing a block mapping
in “/config/configuration.yaml”, line 3, column 1
expected , but found ‘’
in “/config/configuration.yaml”, line 18, column 3

Without this part everything seems to work just fine. What am I missing here?

Firstly, is your leaf pre 2018?

I’m not sure about the first part, but here is mine, it triggers at 7am so I know it’s ok for going to work. Try putting the vin in single quotes.

- action:
  - service: nissan_leaf.update
    data:
      vin: 'XXXXXXXXXXXXXX'             # replace
  alias: Update Leaf
  id: '1545654345487'
  trigger:
  - at: '7:00:00'
    platform: time

As for the second part, it looks fine but try changing the hours: 1 to minutes: 60 see if that makes a difference.

Thanks, will try it out, yes Leaf is 2014.
I have another issue status is no longer updating at all, the only way to get it updated is to restart HA. I think this component is no longer functional.

Sometimes getting this:
return CarwingsLatestBatteryStatusResponse(response)
File “/usr/local/lib/python3.8/site-packages/pycarwings2/responses.py”, line 627, in init
bs = recs[“BatteryStatus”]
TypeError: list indices must be integers or slices, not str

But most of the time it is just not updating.

And now it stopped working completely:
2020-09-25 11:31:58 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.

Take a look at this post, it seems that HA doesn’t get the info every time, first time. The post describes how to add a second ‘poll’ for data, I’ve been using it for about a year and I have NO issues.

Linky Dink

Thank you very much!
I’m new to HA (currently migrating from Domoticz), so just starting to understanding how things working.

I’m strugling with this part:

  • platform: template
    sensors:
    leaf_updating:
    friendly_name: ‘Leaf Update Status’
    value_template: “{{ state_attr(‘sensor.CHANGEME_charge’, ‘update_in_progress’) }}”

Where exactly do I put it? And sensor.CHANGEME_charge should be changed to, I’m a bit confused.