Nissan Leaf Component(s)/Platform


#82

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.


#83

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


#84

https://developers.home-assistant.io/docs/en/dev_101_index.html

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.


#85

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


#86

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


#87

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


#88

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


#89

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.


#90

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


#91

Using group.yaml

leaf:
  name: Leaf
  icon: mdi:car
  entities:
  - 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


#92

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


#93

Installation on hass.io:

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

\\myip\config\custom_component\nissan_leaf.py
\\myip\config\custom_component\switch\nissan_leaf.py
\\myip\config\custom_component\sensor\nissan_leaf.py
\\myip\config\custom_component\binary_sensor\nissan_leaf.py

and added this to the configuration.yaml:

nissan_leaf:
      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 hass.io and all works just fine…


#94

I’ve implemented your changes exactly as stated in: https://github.com/BenWoodford/home-assistant/pull/1/files

but on hassio restart:

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

Testing configuration at /config
ERROR:homeassistant.scripts.check_config:BURB
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check
    res['components'] = check_ha_config_file(hass)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 340, in check_ha_config_file
    component = loader.get_component(hass, domain)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 94, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", 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/nissan_leaf.py", 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 (nissan_leaf.py, line 142)
Failed config
  General Errors: 
    - inconsistent use of tabs and spaces in indentation (nissan_leaf.py, 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
        self.data = {}
        self.data[DATA_CLIMATE] = False
        self.data[DATA_BATTERY] = 0
        self.data[DATA_CHARGING] = False
        self.data[DATA_LOCATION] = False
        self.data[DATA_RANGE_AC] = 0
        self.data[DATA_RANGE_AC_OFF] = 0
        self.data[DATA_PLUGGED_IN] = False
        self.last_check = None
        track_time_interval(
            hass,
            self.refresh_leaf_if_necessary,
            timedelta(seconds=CHECK_INTERVAL))

Any idea?


#95

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


#96

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


#97

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 hass.io without any further modifications.

A hass.io 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,

Michel


#98

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.


#99

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


#100

@ 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,

Michel


#101

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