Nissan Leaf Component(s)/Platform

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

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:

1 Like

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

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

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.

1 Like

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

1 Like

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.
2 Likes

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.

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

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.

1 Like

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

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

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

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:

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

1 Like

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

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 replaced 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.

Thanks for this @filcole, bit I’m not as savvy as you may think I am :slight_smile:

These changes you’ve been doing, am I supposed to be updating my files somehow, from somewhere?

Cheers :slight_smile:

P.S. my config has the nissan_connect: set to false as I’m using carwings.

1 Like

Updated the custom_components for 0.88.0

LINKY

3 Likes

So, I think I’m getting pretty close to nailing this, but my Hassio keep nagging about this missing pycarwings2 module. And I cant figure out how to, and where to install it om my Hassoi

File “/config/custom_components/nissan_leaf/init.py”, line 91, in async_setup
import pycarwings2
ModuleNotFoundError: No module named ‘pycarwings2’

Managed too remove other error messages after installing the last pack of components for 0.88.0
I’m pretty noob in this and have no idea how I activate this as an Entity. But I’m really keen to get my Leaf on my HA :slight_smile:

Have you tried to restart your pi? :slight_smile: