Nissan Leaf Component(s)/Platform


#223

@filcole When restarting HA with you lastest changes on github got an error in custom_components.sensor.nissan_leaf.

File “/usr/src/app/homeassistant/loader.py”, line 117, in _load_file 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 678, in exec_module File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed File “/config/custom_components/sensor/nissan_leaf.py”, line 11, in <module> from homeassistant.components.nissan_leaf import ( ModuleNotFoundError: No module named ‘homeassistant.components.nissan_leaf’


#224

Hi,

Its all in the thread, but its a bit difficult to see if one is not a programmer:

First follow this post fdor links and files etc. : Nissan Leaf Component(s)/Platform

What I did next was to create “HASSIO\config\custom_components” (you need to ssh in to HA or use samba )

The next trick is to open all the “nissan_leaf.py” files and replace “from homeassistant.components.nissan_leaf import (” with: " from …nissan_leaf import ("

Then restart home assistant and it works.

Hope this helps.


#225

I’ve put together a rar file, download it and extract it to custom_components. eg. config/custom_components/sensor/ etc.

Dropbox


#226

Thanks, but it should be 2 dots (…) instead of 3 dots. @filcole Can you modify the sources to a relative import? TIA.


#227

Hi @remyderuysscher, Unfortunately not, when trying to get the component merged as a full component we can’t use the relative paths ‘..’ as far as I’m aware. There’s is some restructuring of the file layout for components, which I’ve been requested to update to, see this comment https://github.com/home-assistant/home-assistant/pull/19786#issuecomment-458771752


#228

OK, so the component is working well, however :wink: I have just charged my car up to 100% and it’s showing 109% in HA.

I’ve bodged a fix, I’m not a python programmer but I’ve dabbled in arduino etc. I have changed a line in the file responses.py

if float(self.battery_capacity) == 0:
    log.debug("battery_capacity=0, status=%s", status)
    self.battery_percent = 0
else:
    self.battery_percent = 100 * float(self.battery_remaining_amount) / float(12.0)

I changed the last float to 12.0 instead of self.battery_capacity

I’ve mentioned this before and I’m wondering if there is a fix? Also, is it possible to report the milage and charge % as 60 rather than 60.0 ?

Just asking is all :wink:


#229

Logged the 109% as https://github.com/filcole/home-assistant/issues/16

Logged the % charge as https://github.com/filcole/home-assistant/issues/17


#230

See edit, however, I would map the 12 to 11 if I could work out how :slight_smile: Worked it out!

if float(self.battery_capacity) == 0:
    log.debug("battery_capacity=0, status=%s", status)
    self.battery_percent = 0
else:
    self.battery_percent = 100 * (float(self.battery_remaining_amount) * float(self.battery_capacity)/12.0) / float(self.battery_capacity)

x = charge
y = capacity

z = x*y/12

This however will only work if the charge always reports 0-12, which I think it does.


#231

Both of these glitches are fixed in the latest version of the pull request that uses an updated pycarwings, version 2.8


#232

Just a quick post to document what I did to make the latest version works :

from homeassistant.components.nissan_leaf import (

with :
from ..nissan_leaf import (

  • Edit your HA configuration.yaml with the correct nissan_leaf: configuration.

#233

Hi all,

So I’ve been making some more fixes to the nissan_leaf component. It now exposes on attributes the next scheduled update, the time of the last attempted update was started, if an update is in progress, and the last date that the battery, climate and location were updated.

There’s also a new service that can be called to manually trigger an update. nissan_leaf.update, that must be passed the VIN number of the car (in case of multiple cars)

service: nissan_leaf.update
data:
  vin: 'SNDA23324324'

I think this might be improved/changed in future because I don’t like using the vin number. Have choices between the nickname of the car, or an entity_id from home assistant.

All known bugs have been fixed.


#234

Hi @filcole, what do I need to do? :slight_smile:


#235

So the HomeAssistant core developers have had a review of the pull request and have requested some changes reasonable changes before this pull request can be reviewed again.


#236

Hi, I am not so experienced, how can I install this on my home assistant?


#237

Check out THIS post, it has all the info you need.


#238

Thanks, I did it the old way (sensor, binary_sensor and switch folders with nissan_leaf.py) in it from the latest branch.

It did not work because of the missing “pycarwings2”, how do I install pycarwings2?
Should it install automatically?
I expect the same behavior with the “this post files”. Or not?

Update:
so I guess it should install automatically, however it might take too long so raspberry gives up:

regards
Daniel


#239

The post I referred to does work, have you edited the files mentioned?

Or download THIS rar file and put the files in the correct place. (Just updated to 2.8)

Anyway, the project will soon be integrated into HA.:):crossed_fingers:


#240

Hi all. It won’t make it into 0.88, hopefully 0.89, but it’s still pending some changes, reviews and enhancements.


#241

Thanks, got it working with your link, I had to restart HASS, not only home assistant server.
Thanks for this great feature!


#242

The changes the core developers have requested have mostly been made in new pull request 21145.

Note that the charging switch has been removed, and replace with a sensor. To start a charge a service must now be called, e.g.

- service: nissan_leaf.start_charge
  data:
    vin: XX1248212323232     # see Vin in the states area

I’d love to get some more feedback from 24kWh users, especially with nissan_connect: true and nissan_connect: false.