Nissan Leaf Component(s)/Platform


#182

I picked up the latest files, modified them to work on Hass.io, but I’m getting an error message, I’ve actually had this error the last week (give or take a few days) and it’s related to pycarwings. I’ve created an issue for it.

Unable to install package pycarwings2==2.5: Failed building wheel for pycryptodome python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you’ll have pycryptodome 3.7.3 which is incompatible. pyrebase4 4.2.0 has requirement oauth2client==4.1.2, but you’ll have oauth2client 4.0.0 which is incompatible. broadlink 0.9 has requirement pycryptodome==3.4.11, but you’ll have pycryptodome 3.7.3 which is incompatible. Command “/usr/local/bin/python3 -u -c “import setuptools, tokenize;file=’/tmp/pip-install-n_08kzfq/pycryptodome/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-record-ftvogyx3/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=” failed with error code 1 in /tmp/pip-install-n_08kzfq/pycryptodome/ You are using pip version 18.0, however version 18.1 is available. You should consider upgrading via the ‘pip install --upgrade pip’ command.


#183

What do I need for testing? At the moment I’m using hassio, I have the files in the custom_components folders. Do I need to update the files, or just restart HA?


#184

Second this error:
Unable to install package pycarwings2==2.4: Failed building wheel for pycryptodome python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you’ll have pycryptodome 3.7.3 which is incompatible. pyrebase4 4.2.0 has requirement oauth2client==4.1.2, but you’ll have oauth2client 4.0.0 which is incompatible. broadlink 0.9 has requirement pycryptodome==3.4.11, but you’ll have pycryptodome 3.7.3 which is incompatible.

Came after I picked up the latest files from filcole’s git I believe?


#185

Hi all (esp. @BenWoodford, @LudoErgoSum, @RoadkillUK @Abertil !!)

I’ve released pycarwings2.6 without any restriction on the version of pycryptodome that’s used, since old versions are logging in fine. I’ve pushed an update to the pull request that will use version 2.6 of pycarwings. Please test!!


#186

As above, what do I need to do to test this?

I’m using custom_components and have edited the files (a few days ago) so do I have to download them again or just restart HA?

While I’m here, my 24kWh Leaf has only 11 bars remaining and shows 109% when fully charged, I notice that it reads this info from the nissan server, so could this be used to calculate the correct %?

"BatteryCapacity":"11","BatteryRemainingAmount":"7"


#187

I deleted all the associated files, downloaded the ones posted earlier in this thread, changed the files as mentioned also earlier in this thread.
Unfortunately it’s not working atm, here is the error log…

2019-01-22 23:54:55 ERROR (SyncWorker_7) [homeassistant.util.package] Unable to install package pycarwings2==2.6: Failed building wheel for pycryptodome
python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you'll have pycryptodome 3.7.3 which is incompatible.
pyrebase4 4.2.0 has requirement oauth2client==4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.
broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.7.3 which is incompatible.
Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vt2w9fp9/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-zsiwwtvw/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-vt2w9fp9/pycryptodome/
You are using pip version 18.0, however version 19.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2019-01-22 23:54:55 ERROR (MainThread) [homeassistant.requirements] Not initializing nissan_leaf because could not install requirement pycarwings2==2.6
2019-01-22 23:54:55 ERROR (MainThread) [homeassistant.setup] Setup failed for nissan_leaf: Could not install all requirements.

#188

I’ve also got the same error as @RoadkillUK using pycarwings2 2.6 and I looked in to a little more when this error started to appear and it seems that it came with Hass.io release 142.

Looking at the change log most probably connected to https://github.com/home-assistant/hassio/pull/882
#882 Update docker-py to 3.7.0


#189

also @LudoErgoSum

I updated to 0.86.0 and the pycryptodome issue went away.

Back to testing!!


#190

Got it working partly again now. But it seems that battery isn’t updating properly.

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/nissan_leaf.py", line 51, in state
    return round(self.car.data[DATA_BATTERY], 0)
TypeError: type str doesn't define __round__ method

I’m getting my log full of this error now, one every minute.


#191

This is my latest issue:
.pycarwings2] Response HTTP Status Code: 200
2019-01-24 22:37:27 DEBUG (SyncWorker_7) [pycarwings2 .pycarwings2] Response HTTP Response Body: {“status”: 200,“RemoteACRecords”:{“OperationResult”:“START”,“Ope rationDateAndTime”:“2019/01/24 09:43”,“RemoteACOper ation”:“STOP”,“ACStartStopDateAndTime”:“2019-jan-24 1 0:44”,“ACStartStopURL”:"",“PluginState”:“NOT_CONNECTE D”,“ACDurationBatterySec”:“900”,"ACDurationPluggedSec ":“7200”,“PreAC_unit”:“C”,“PreAC_temp”:“22”,"Inc_temp ":“12”}}
2019-01-24 22:37:27 ERROR (MainThread) [homeassistant .core] Error doing job: Future exception was never re trieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/concurrent/futures/t hread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/nissan_leaf.py”, li ne 199, in refresh_leaf_if_necessary
self.refresh_data()
File “/config/custom_components/nissan_leaf.py”, li ne 225, in refresh_data
climate_response = self.get_climate()
File “/config/custom_components/nissan_leaf.py”, li ne 275, in get_climate
request = self.leaf.get_latest_hvac_status()
File “/config/deps/lib/python3.6/site-packages/pycarwings2/pycarwings2.py”, line 390, in get_latest_hvac _status
return CarwingsLatestClimateControlStatusResponse (response)
File “/config/deps/lib/python3.6/site-packages/pyca rwings2/responses.py”, line 310, in init
racr, on_key=“CruisingRangeAcOn”, off_key=“Cruisi ngRangeAcOff”)
File “/config/deps/lib/python3.6/site-packages/pyca rwings2/responses.py”, line 57, in set_cruising_rang es
self.cruising_range_ac_off_km = float(status[off
key]) / 1000
KeyError: ‘CruisingRangeAcOff’

API is not returning CruisingRangeAcOff.

Sorry for the bad indentation or whatever, writing this from my phone. I do hope it can be of any help though. Great job despite the horrific api…


#192

Also updated with the latest code in HASSIO and receive the exact same error.


#193

Hi All,

Nissan Servers are not returning data for me, but the error to do with string not being a float should be fixed in version 2.7 of pycarwings, which I’ve updated the pull request to use. Thanks for reporting.

    return round(self.car.data[DATA_BATTERY], 0)
TypeError: type str doesn't define __round__ method

#194

I’ve logged the “API is not returning CruisingRangeAcOff” as
https://github.com/filcole/home-assistant/issues/14 and will investigate when I have a few minutes.


#195

Love the new error message!! :smile:

Fri Jan 25 2019 07:44:53 GMT+0100 (Central European Standard Time)

Unable to fetch car details... do you actually have a Leaf connected to your account? 

Let’s see when the servers are up, I moved up to 2.7 for testing purposes.


#196

Tested and confirmed, works for me. I’m getting charging data again.

Need to follow up later today on the Charging sensor/switch. Didn’t work for me yesterday. Gave off even though the car was charging.

Plug status works fine.


#197

Seems to be working fine, thanks :slight_smile:

is there anything that can be done about the battery % ? Mine is showing over because I’ve lost a battery bar.


#198

I gather then that they still return it out of 12 even when your actual capacity is lower… weird but at this point nothing surprises me


#199

Hi, Pretty sure that’s a bug in pycarwings2 that I think should be solved in pycarwings2 version 2.7. Can you confirm that’s the version that’s installed. Are you able to send me the logs through so help debug please?

From your previous comment:

While I’m here, my 24kWh Leaf has only 11 bars remaining and shows 109% when fully charged, I notice that it reads this info from the nissan server, so could this be used to calculate the correct %?

"BatteryCapacity":"11","BatteryRemainingAmount":"7"


#200

It looks like I’m using pycarwings2.6, the only way I could tell was to look in the deps folder.

Here’s section of the log…

2019-01-26 19:13:01 DEBUG (SyncWorker_9) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v181217_NE/gdc/BatteryStatusRecordsRequest.php
2019-01-26 19:13:01 DEBUG (SyncWorker_9) [pycarwings2.pycarwings2] params: {
   "DCMID": "201399055139",
   "RegionCode": "NE",
   "TimeFrom": "2018-11-25T22:03:22Z",
   "VIN": "SJNFAAZE0U6025560",
   "custom_sessionid": "NtDiEL06dxXHy98SM49EvguPI8zLBrpk89SswMHnXKPnn/jz5+9L1XFnVKOPW8xlf+o5V3//tZ75mPIMtqGNVLqXxgRjLJens+Yz6lZR7YNA==",
   "initial_app_strings": "geORNtsZe5I4lRGjG9GZiA",
   "lg": "en_GB",
   "tz": "Europe/Paris"
}
2019-01-26 19:13:04 DEBUG (SyncWorker_9) [pycarwings2.pycarwings2] Response HTTP Status Code: 200
2019-01-26 19:13:04 DEBUG (SyncWorker_9) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":200,"BatteryStatusRecords":{"OperationResult":"START","OperationDateAndTime":"26-Jan-2019 19:53","BatteryStatus":{"BatteryChargingStatus":"NOT_CHARGING","BatteryCapacity":"11","BatteryRemainingAmount":"5","BatteryRemainingAmountWH":"","BatteryRemainingAmountkWH":""},"PluginState":"NOT_CONNECTED","CruisingRangeAcOn":"45760.0","CruisingRangeAcOff":"47872.0","TimeRequiredToFull":{"HourRequiredToFull":"14","MinutesRequiredToFull":"30"},"TimeRequiredToFull200":{"HourRequiredToFull":"8","MinutesRequiredToFull":"30"},"TimeRequiredToFull200_6kW":{"HourRequiredToFull":"4","MinutesRequiredToFull":"0"},"NotificationDateAndTime":"2019\\/01\\/26 18:53","TargetDate":"2019\\/01\\/26 18:53"}}'
2019-01-26 19:13:04 DEBUG (SyncWorker_16) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v181217_NE/gdc/BatteryStatusCheckRequest.php
2019-01-26 19:13:04 DEBUG (SyncWorker_16) [pycarwings2.pycarwings2] params: {
   "DCMID": "201399055139",
   "RegionCode": "NE",
   "UserId": "",
   "VIN": "SJNFAAZE0U6025560",
   "custom_sessionid": "NtDiEL06dxXHy98SM49EvguPI8zLBrpk89SswMHnXKPnn/jz5+9L1XFnVKOPW8xlf+o5V3//tZ75mPIMtqGNVLqXxgRjLJens+Yz6lZR7YNA==",
   "initial_app_strings": "geORNtsZe5I4lRGjG9GZiA",
   "lg": "en_GB",
   "tz": "Europe/Paris"
}
2019-01-26 19:13:06 DEBUG (SyncWorker_16) [pycarwings2.pycarwings2] Response HTTP Status Code: 200
2019-01-26 19:13:06 DEBUG (SyncWorker_16) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":200,"userId":"Roadkilluk","vin":"SJNFAAZE0U6025560","resultKey":"vm8AVdeiwv6tgy3kWiinao3E2kxkolyAyXkuap2wBZFHxjSurb"}'

#201

Change this line in in nissan_leaf.py (the one that isn’t a switch or sensor)

REQUIREMENTS = ['pycarwings2==2.7']

Restart and you should get version 2.7.