Nissan Leaf Component(s)/Platform

The author is @tomhillable , I hope he sees this at some point.

Hi,

this looks really good and I’ll be lookign to also implement this.

I have a python script pulling this info in manually using pycarwings and just to warn you this was set at a 15 minute poll which ran for around 8 months, my 12V died and resulting in a jump required from an ICE car. Switched the script off and voila no more issues. I’ll probably reinstate it using maybe a 4 hour window but makes me wonder is there any value?

If you drive or plug your car in a lot you’d be alright, but if it’s sitting in the driveway a lot then 15 minutes would easily kill it. That’s why I took a dynamic approach, by defaults it’s an hour polling but if the climate control is enabled or the car is plugged in and charging then it uses different polling values (default is 15 for charging, 5 for climate control).

Before I added those two new values in, it was rather irritating - especially the climate control. I could go to the store, pick up what I needed and then would have to double-instruct the car to turn off then turn on the climate control as I’d been less than the interval period.

Does the car charge the 12v battery when plugged in? I had assumed it didn’t as we leave ours plugged in on the drive. Our usage had dropped around the time the battery died so it was sat on the drive for probably a couple of days without usage.

My understanding is that it does not charge the 12v battery while plugged in. If it is just sitting in the driveway unplugged it will charge the 12v battery from the main if it drops to a certain point.

I tested my weak 12v the other day. If the car is charging, the 12v is charging too.

Also, I cannot figure out how to install this. :frowning:

1 Like

Post #36 above explains where things go. I’m not sure if it runs OK on HASS.IO

HTH

I’ve updated my fork of pycarwings2 so you should find any issues you were having with connectivity as of a few days ago have been fixed, no update to the components needed

Cheers @BenWoodford, I was going to post about the connection problems.

Does anyone know if this component can be easily installed in a Hasbian setup or does it only work in Hass.io?

It might work better on a Hasbian setup. Been a while since I did Hasbian so I can’t remember of hand where custom components go.

@BenWoodford Thanks for updating pycarwings2. Any chance of making it a requirement of the component so that Hass.io does not time out when loading the library. I think that is what is happening sometimes when I do an update to Hass.io. After an update, the main UI shows a bad config, but the detailed logs show that Hass.io was unable to load your fork of pycarwings2 and gave up. Maybe just make your pycarwings2 branch part of the component? When everything loads, it has been working better than Nissan’s app. I think that would eliminate the last problems people are having.

I believe the folder you need to put things in is …

Have you copied the correct files to the correct locations? These are the files that need copying across, it should work after that. However, I did have problems with it downloading the carwings component but, I did get it working on my PC.

\home\homeassistant.homeassistant\custom_components\nissan_leaf.py
\home\homeassistant.homeassistant\custom_components\switch\nissan_leaf.py
\home\homeassistant.homeassistant\custom_components\sensor\nissan_leaf.py
\home\homeassistant.homeassistant\custom_components\binary_sensor\nissan_leaf.py

These are not all the same file btw, they are found in the associated folders in \components.

Good luck :wink:

RK

My fork is already a requirement, however I have no experience with HASS.io so can’t comment on how it might handle a git repo instead of a proper package.

I can’t include pycarwings2 in the package because that’s against HASS policy. API interactions require an external library and mustn’t be part of the actual codebase (presumably so that the library can be fixed without requiring a HASS update).

I will eventually get this ready to be merged in but pycarwings2 needs updating by the author (or I could branch my own package but I’d rather not) and I need time to fix the feedback from the HASS devs

OK, I think I’m just being stupid. I created a custom_components folder in the config folder and copied all the files to the matching folders. My configuration.yaml has this line:
customize: !include customize.yaml

so I put this in customize.yaml:
nissan_leaf:
username: email-address
password: !secret carwings
region: NE

but HA fails to start with this error:
2018-06-10 16:34:18 ERROR (MainThread) [homeassistant.config] Invalid config for [homeassistant]: [nissan_leaf] is an invalid option for [homeassistant]. Check: homeassistant->customize->nissan_leaf. (See /home/homeassistant/.homeassistant/configuration.yaml, line 2).

can anyone tell me what I’m doing wrong?

Hi, I put my info straight into the configuration.yaml

nissan_leaf:
  username: "username"
  password: "password"
  region: 'NE'
  update_interval: 30
  update_interval_charging: 15
  update_interval_climate: 5
  force_miles: true

Also, I don’t think you’ve put the folders in the right place, should be in .homeassistant\custom_components\ not config\custom_components.

Hope that helps :roll_eyes:

customize.yaml is not for configuring platforms, it’s for setting generic HASS options like friendly name, etc.

You need to put the block directly into your configuration.yaml

Thanks both, my misunderstanding, also didn’t realise I needed double quotes on the username and single on the region. I moved the newly created custom_components to the top, moved the configuration into configuration.yaml and it worked! Thanks so much Ben for writing this, I can now coordinate charging with my solar panel and in home battery charging state so I have zero export to the grid, I’m so chuffed!

I cannot find the files for installing these components, I’m really confused. Should HASS automatically pull those files from github or are you required to manually install them in custom_components?

Files are not there. Please help, I’m new with HA.

@BenWoodford can you clarify?