Nissan Leaf Component(s)/Platform


Please read up on how to use custom components, you need to grab the files for the Leaf component from the Github repo’s components folder and throw them into your own custom components folder retaining the hierarchy.

This is heavily under alpha/beta right now, so it’s not really made for first time users.


Ah sorry, I understand now. I was using I’m switching to your fork now.


Inside your configuration directory create a new folder called custom_components. It might be that one already exists, that’s fine too. This is the folder that Home Assistant will look at when looking for custom code.


I will keep an eye on this thread…
Just got a Leaf 2018 today and are quite eager to get this to work.


I’m getting the 2018 Tekna within 2 weeks and can’t wait to try this out on :sunny:


Anyone here that had it to work on or even better HAssOS?


I was surprised today when this component started working all of the sudden.
I’m running Hassio on hassos.


I’m trying to get the battery sensor to hit siri. It’s in listed in home assistant, but doesn’t traverse over to this component for some reason. Look at the bottom of this page. Battery tracking is possible.


How did you get all your leaf stats into one “leafen” group? Mine are in little bubbles on top and a switch group below.


Using group.yaml

  name: Leaf
  icon: mdi:car
  - binary_sensor.leaf_plug_status
  - sensor.leaf_charge
  - sensor.leaf_charge_time_1
  - sensor.leaf_charge_time_2
  - sensor.leaf_range
  - sensor.leaf_range_ac
  - switch.leaf_charging_status
  - switch.leaf_climate_control

Here’s more info on Groups


Nothing. It’s valid. It sees it. It doesn’t change it. This is really confusing stuff.


Installation on

I just copied the files from Ben over to my (running on top of Ubuntu 18.04) via the samba share like:


and added this to the configuration.yaml:

      username: "[email protected]"
      password: "mypassword"
      nissan_connect: true
      region: 'NE'
      update_interval: 30
      update_interval_charging: 10
      update_interval_climate: 5
      force_miles: false

Restarted and all works just fine…


I’ve implemented your changes exactly as stated in:

but on hassio restart:

Log Details (ERROR)
Sat Aug 11 2018 11:48:45 GMT+0200 (Midden-Europese zomertijd)

Testing configuration at /config
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/", line 207, in check
    res['components'] = check_ha_config_file(hass)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/", line 340, in check_ha_config_file
    component = loader.get_component(hass, domain)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/", line 94, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/", line 142
    self.nissan_connect = config[DOMAIN][CONF_NCONNECT]
TabError: inconsistent use of tabs and spaces in indentation
Fatal error while loading config: inconsistent use of tabs and spaces in indentation (, line 142)
Failed config
  General Errors: 
    - inconsistent use of tabs and spaces in indentation (, line 142)

Successful config (partial)

The actual file:

class LeafDataStore:

    def __init__(self, leaf, hass, config):
        self.leaf = leaf
        self.config = config
		self.nissan_connect = config[DOMAIN][CONF_NCONNECT]
		self.force_miles = config[DOMAIN][CONF_FORCE_MILES]
        self.hass = hass = {}[DATA_CLIMATE] = False[DATA_BATTERY] = 0[DATA_CHARGING] = False[DATA_LOCATION] = False[DATA_RANGE_AC] = 0[DATA_RANGE_AC_OFF] = 0[DATA_PLUGGED_IN] = False
        self.last_check = None

Any idea?


It’s as it says, inconsistent use of tabs. That PR hasn’t been merged due to a number of reasons, most of all because it doesn’t followed convention nor does it follow the structure of the rest of the component


I’ll take your word for it since I am not a coder :wink:


Not trying to sound unthankful, impatient or anything, because great work has been done already…but…

Is there any development going on? I don;t see much going on on github since 7 months or so…

I’m using this for a while now and it works great on without any further modifications.

A community addon would be great and make it more accessible to the “regular user”.

Any plans to integrate GPS location?
Any plans for a official home assistant addon?

Kind regards,



Been pretty busy which is why I haven’t had time to work on this. However I can’t build the device tracker for it as I have a pre-2016 Leaf that doesn’t send its GPS location. Someone did submit a PR for it but it wasn’t linted and didn’t follow the same structure so I had to decline it for now.

As for being part of Home Assistant, it’s mostly a restructuring and linting thing. I submitted it but was declined and basically just haven’t had any time to work on it as spare time is somewhat of an alien concept to me these days.


I understand. I have the same issue most days of the year :wink:


@ kurol

Would you be willing to review your code and share a working version of it (based on the latest Leaf addon by Ben) to the community? I tried the changes in your pull-request but it won’t work.

Kind regards,



Would this work with infiniti by chance? When I setup the Alexa skill it mentioned Nissan