Git Product home page Git Product logo

pycarwings2's Introduction

pycarwings2

Library for connecting and interacting with Nissan's CARWINGS service for Nissan LEAF cars. Uses the (newly secure!) REST/JSON API rather than the previous XML-based API.

Inspired by original pycarwings library: https://github.com/haykinson/pycarwings

asynchronous methods

Note that several of the most interesting methods in the CARWINGS service are asynchronous--you ask the service to do something, and it just says "ok". You then have to poll a corresponding method to find out if the operation was successful.

More details are located at the top of pycarwings2.py.

Installation

pip install git+https://github.com/jdhorne/pycarwings2.git

example usage

exemples/get-leaf-info.py

license

Copyright 2016 Jason Horne

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

pycarwings2's People

Contributors

cedric222 avatar cpaillet avatar frahlg avatar jdhorne avatar rduivenvoorde avatar xibriz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycarwings2's Issues

401 error

If I log in to my carwings account from another app (eg the nissan connect app) I start getting 401 errors when making API calls through pycarwings2.

Unfortunately the auto reconnect code in _request_with_retry() only retries on 404 errors. I think it should also retry on 401 errors.

pycarwings2 error (INVALID PARAMS: 52)

I am pretty confident that this is not an issue of pycarwings2, since the website is acting up right now as well - just thought I'd document it here in case there actually is an API change in the EU region/others are experiencing the same problem.
All API requests succeed, however BatteryStatusRecordsRequest.php returns an unexpected response:

(...)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com:443
DEBUG:urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /api_v190426_NE/gdc/BatteryStatusRecordsRequest.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: b'{"status":52}'

This started happening for me this morning CET and might resolve itself with a backend change on Nissan's end.

location update not working (Canada)

Thanks for the library! All the examples seem to work (region: NCI/canada), except for the get-leaf-location example, which returns a error -5256: [MyCarFinder] API call error

Is this possibly due to the API not available in Canada? Also, just for curiosity's sake, do any other regions allow you to find the location of the vehicle?

Stop charging remotely?

Do you know if it's possible to stop charging remotely? I.e., add a stop_charging() call to the API.

Would be useful e.g., to charge to 80% via the library.

INVALID PARAMS error

Hi,

Thank you for writing pycarwings2.

I've installed it on my Centos box and tried to run the example get-leaf-info.py with my username and password in the config.ini.

It fails with an "INVALID PARAMS" error:

$ ./get-leaf-info.py
Prepare Session
Login...
ERROR:pycarwings2.pycarwings2:carwings error INVALID PARAMS: -2010
Traceback (most recent call last):
  File "./get-leaf-info.py", line 25, in <module>
    l = s.get_leaf()
  File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 189, in get_leaf
    self.connect()
  File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 163, in connect
    "Password": encodedPassword,
  File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 138, in _request
    raise CarwingsError("INVALID PARAMS")
pycarwings2.pycarwings2.CarwingsError: INVALID PARAMS

The vehicle in question is in Europe, and it looks like your get-leaf-info.py defaults to the NE region, so I don't think it's that.

It looks from #3 like maybe this is a problem with the password encryption - do you have any hints you could offer please? I'm afraid python isn't my tool of choice and I'm a bit clueless.

Cheers

change in URL for UK users?

Hi guys. Started to get this error recently (used to work 99% of time, not always fails):

DEBUG:pycarwings2.pycarwings2:invoking carwings API: https://gdcportalgw.its-mo.com/gworchest_160803A/gdc/InitialApp.php
DEBUG:pycarwings2.pycarwings2:params: {
   "RegionCode": "NE",
   "custom_sessionid": "",
   "initial_app_strings": "redacted_out",
   "lg": "en-US"
}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com
DEBUG:urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /gworchest_160803A/gdc/InitialApp.php HTTP/1.1" 404 234
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 404
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /gworchest_160803A/gdc/InitialApp.php was not found on this server.</p>
</body></html>

Traceback (most recent call last):
  File "get-leaf-battery.py", line 33, in <module>
    l = s.get_leaf()
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 189, in get_leaf
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 151, in connect
    "lg": "en-US",
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 134, in _request
    j = json.loads(response.content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Looks like the URL changed?
Anyone seeing this?

Cheers,
Irek

TypeError: list indices must be integers, not str

Hi!

I am trying to test out the get-leaf-info.py script, by I keep getting this message. Any idea what might be causing it? Most of the info output seems fine (line VIN, mail etc.) I'm using the latest git code.

DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com
DEBUG:urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /gworchest_160803A/gdc/BatteryStatusRecordsRequest.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: {"status":200,"BatteryStatusRecords":[]}
Traceback (most recent call last):
File "./get-leaf-info.py", line 28, in
leaf_info = l.get_latest_battery_status()
File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 372, in get_latest_battery_status
return CarwingsLatestBatteryStatusResponse(response)
File "/usr/local/lib/python2.7/dist-packages/pycarwings2/responses.py", line 514, in init
bs = recs["BatteryStatus"]
TypeError: list indices must be integers, not str

AttributeError: CarwingsLatestBatteryStatusResponse instance has no attribute 'state_of_charge

After merge of PR #22 (see issue ##13) to obtain SOC. I now get the following error when running on my 24kwh leaf. I assumed this is because my 24kwh leaf does not support SOC response?

/get-leaf-info.py 
Prepare Session
Login...
get_latest_battery_status
date 01-Dec-2017 04:39
date 2017/12/01 03:40
battery_capacity2 12
battery_capacity 12
charging_status NOT_CHARGING
battery_capacity 12
battery_remaining_amount 9
charging_status NOT_CHARGING
is_charging False
is_quick_charging False
plugin_state NOT_CONNECTED
is_connected False
is_connected_to_quick_charger False
time_to_full_trickle 5:30:00
time_to_full_l2 3:00:00
time_to_full_l2_6kw 2:30:00
leaf_info.battery_percent 75.0
Traceback (most recent call last):
  File "./get-leaf-info.py", line 47, in <module>
    print "leaf_info.state_of_charge %s" % leaf_info.state_of_charge
AttributeError: CarwingsLatestBatteryStatusResponse instance has no attribute 'state_of_charge

Time for pycarwings3?

Seems like the best place to put this. They've got a totally new, RESTful API that supports multiple vehicles, so now we need a new library to handle it. I don't think revising the existing library is terribly sensible as basically everything has changed, so I'd like to start the ball rolling on a pycarwings3 for the new API before they deprecate the old one.

https://gist.github.com/BenWoodford/141ca350445e994e69a70aabfb6db942

Error trying to install

Hi, I'm trying to install I get error:

What version of python does this module require? I am running 2.7.6

pip install git+https://github.com/jdhorne/pycarwings2.git
Collecting git+https://github.com/jdhorne/pycarwings2.git
  Cloning https://github.com/jdhorne/pycarwings2.git to /tmp/pip-ehULDt-build
Collecting PyYAML (from pycarwings2==2.1)
  Using cached PyYAML-3.12.tar.gz
Collecting iso8601 (from pycarwings2==2.1)
  Using cached iso8601-0.1.11-py2.py3-none-any.whl
Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from pycarwings2==2.1)
Requirement already satisfied: pycrypto in /usr/lib/python2.7/dist-packages (from pycarwings2==2.1)
Building wheels for collected packages: PyYAML
  Running setup.py bdist_wheel for PyYAML ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-KTb45H/PyYAML/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp3Vmkjipip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/tokens.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/composer.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/nodes.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/loader.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/parser.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/reader.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/cyaml.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/constructor.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/representer.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/serializer.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/emitter.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/events.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/scanner.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/resolver.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/dumper.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/__init__.py -> build/lib.linux-x86_64-2.7/yaml
  copying lib/yaml/error.py -> build/lib.linux-x86_64-2.7/yaml
  running build_ext
  creating build/temp.linux-x86_64-2.7
  checking if libyaml is compilable
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
  checking if libyaml is linkable
  x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml
  building '_yaml' extension
  creating build/temp.linux-x86_64-2.7/ext
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
  ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory
   #include "Python.h"
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for PyYAML
  Running setup.py clean for PyYAML
Failed to build PyYAML
Installing collected packages: PyYAML, iso8601, pycarwings2
  Running setup.py install for PyYAML ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-KTb45H/PyYAML/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-XHESnw-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/tokens.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/composer.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/nodes.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/loader.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/parser.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/reader.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/cyaml.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/constructor.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/representer.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/serializer.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/emitter.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/events.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/scanner.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/resolver.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/dumper.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/__init__.py -> build/lib.linux-x86_64-2.7/yaml
    copying lib/yaml/error.py -> build/lib.linux-x86_64-2.7/yaml
    running build_ext
    creating build/temp.linux-x86_64-2.7
    checking if libyaml is compilable
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    checking if libyaml is linkable
    x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml
    building '_yaml' extension
    creating build/temp.linux-x86_64-2.7/ext
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
    ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-KTb45H/PyYAML/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-XHESnw-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-KTb45H/PyYAML/

KeyError: 'BatteryStatusRecords'

@jdhorne Could something have changed on carwings/Nissan's end?

Script worked the day before, and with no changes today it does not.

pizerow1:~/leaf $ python get-leaf-info.py Prepare Session Login... get_latest_battery_status Traceback (most recent call last): File "get-leaf-info.py", line 28, in <module> leaf_info = l.get_latest_battery_status() File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 372, in get_latest_battery_status return CarwingsLatestBatteryStatusResponse(response) File "/usr/local/lib/python2.7/dist-packages/pycarwings2/responses.py", line 508, in __init__ CarwingsResponse.__init__(self, status["BatteryStatusRecords"]) KeyError: 'BatteryStatusRecords' pi@pizerow1:~/leaf $

occasional ZeroDivisionError: float division by zero error

i'm occasionally seeing this:

Traceback (most recent call last):
 File "/data/hm/bin/leaf.py", line 35, in <module>
   battery_status = l.get_status_from_update(result_key)
 File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 224, in get_status_from_update
   return CarwingsBatteryStatusResponse(response)
 File "/usr/lib/python2.7/site-packages/pycarwings2/responses.py", line 244, in __init__
   self.battery_percent = 100 * float(status["batteryDegradation"]) / float(status["batteryCapacity"])
ZeroDivisionError: float division by zero

generally an immediate retry succeeds.

Historical charging patterns

Hello,

I'm looking to get historical charging patterns (timeStart, timeEnd, powerUsed). Do you have an idea of where to find that?

Best,

Olivier

KeyError: BatteryStatusRecords

Can't get the example-script to work. Any suggestions?

# /usr/bin/python ./get-leaf-info.py Prepare Session Login... get_latest_battery_status Traceback (most recent call last): File "./get-leaf-info.py", line 28, in <module> leaf_info = l.get_latest_battery_status() File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 372, in get_latest_battery_status return CarwingsLatestBatteryStatusResponse(response) File "/usr/local/lib/python2.7/dist-packages/pycarwings2/responses.py", line 508, in __init__ CarwingsResponse.__init__(self, status["BatteryStatusRecords"]) KeyError: 'BatteryStatusRecords'

occasional "UnboundLocalError: local variable 'response' referenced before assignment" error

i'm occasionally seeing this:

Traceback (most recent call last):
 File "/data/hm/bin/leaf.py", line 35, in <module>
   battery_status = l.get_status_from_update(result_key)
 File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 220, in get_status_from_update
   "resultKey": result_key,
 File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 101, in _request_with_retry
   ret = self._request(endpoint, params)
 File "/usr/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 134, in _request
   j = json.loads(response.content)
UnboundLocalError: local variable 'response' referenced before assignment

generally an immediate retry succeeds.

What does the value in batteryCapacity represent?

I'm trying to get the battery size from the APIs and the closest thing I found is the batteryCapacity, however, from what I saw, the value returned for that parameter is always 12, do you know what that number represents exactly?

Thanks in advance for the response and for the great work documenting these APIs!!

API rate limit ?

I'm up and running, thanks. ๐Ÿ‘

Do you know if there is a rate limit to the API? At what frequency would you recommend polling it? Do Nissan have a recommended sensible use policy? I would like to log my battery SOC to https://emoncms.org to graph it. This will require regularly polling the API.

Do you know how often the car updates the data?

Obtain status of climate control?

I have written a script to publish data to MQTT and respond to MQTT messages by activating control :
https://github.com/glynhudson/leaf-python-mqtt

e.g. publishing 1 to leaf/control/climate will turn on the car's A/C

This is working well, however I have been unable to find a way to return the car's A/C / climate control status start_cc_result = l.get_start_climate_control_result(result_key) or l.get_latest_hvac_status() does not seem to work.

"ValueError: No JSON object could be decoded" every time

As of yesterday I'm getting "ValueError: No JSON object could be decoded" every time.

The app on my phone still works.

$ time ./get-leaf-info.py 
Prepare Session
Login...
Traceback (most recent call last):
  File "./get-leaf-info.py", line 25, in <module>
    l = s.get_leaf()
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 189, in get_leaf
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 151, in connect
    "lg": "en-US",
  File "/usr/local/lib/python2.7/dist-packages/pycarwings2/pycarwings2.py", line 134, in _request
    j = json.loads(response.content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

real	0m4.006s
user	0m2.928s
sys	0m0.144s

Doesn't seem to work anymore

All the modules recently are resulting in:
INVALID PARAMS: -2010

Looks like Nissan changed their API expectations again. I was working on a Ruby Gem to control carwings (Nissan connect) but this has proved to be a blocker to making any more progress :-\

I need to analyze what the android app does.

Adding SOC to CarwingsLatestBatteryStatusResponse ok?

Hi, Thanks for the api!

I have a nice graph now of my battery during driving and loading :-)

Anyway, earlier I used a php class to read out the battery status:

https://github.com/gboudreau/nissan-connect-php

And that one also returns the 'SOC' from the LatestBatteryStatus

https://github.com/gboudreau/nissan-connect-php/blob/master/NissanConnect.class.php#L177

in my experience till now this value is the exact value I see on the dashboard in the car.
While the calculated 'self.battery_percent' can be off several points:

https://github.com/jdhorne/pycarwings2/blob/master/pycarwings2/responses.py#L245

So my question / feature request, by adding one line at

https://github.com/jdhorne/pycarwings2/blob/master/pycarwings2/responses.py#L517

            self.charging_status = bs["BatteryChargingStatus"] # excisting line
            self.SOC = bs["SOC"]["Value"]  # this line added

I get myself a SOC value...

Is there a reason to NOT add it?
Or do I interpret the value wrong?

INVALID PARAMS error after nearly one year of working fine. Has the API changed?

Hello,

I use pycarwings2 to do some energy-automation while charging my 2018 Leaf at my house.
Pycarwings2 has now worked for nearly a year without hiccups, refreshing the Leaf state every minute or so.

Yesterday I started getting an error message from Nissan API: {"status":404,"message":"INVALID PARAMS"}
Nothing in the script I use has been changed, also my credentials have not changed. When I entered the credentials into the Android app, the app did (eventually) update the information.

Is this happening to other people as well?

BR,
Max

Vehicle location request?

In the official Nissan app I can search for the location of my vehicle (Leaf 2016, 30kWh, takes some time etc etc, but eventually the position appears on the map).

Is this an api call that can be added?
Did/can you try?
Would be cool to regularly update the position of the leaf on a map :-)

Thanks!

TabError: inconsistent use of tabs and spaces in indentation

There seems to be some tab/space inconsistency in the code. I assume older versions of Python are okay with this, but Python 3 throws an error

  File "/config/deps/lib/python3.6/site-packages/pycarwings2/responses.py", line 510
    self.answer = status
                       ^
TabError: inconsistent use of tabs and spaces in indentation

Bug in CarwingsLatestBatteryStatusResponse() when only { "status": 200 } received

Hi,

If an update request has not been sent to the car, and a latest battery status request is sent to the Nissan servers, then I am getting a server response back with just

{ "status": 200 }

I fixed this by changing the class CarwingsLatestBatteryStatusResponse as follows:

def __init__ (self, status)
    self.answer = status
    if not status.has_key("BatteryStatusRecords"):
        return
    CarwingsResponse.__init__(self, status["BatteryStatusRecords"])

This avoids the crash where BatteryStatusRecords was being checked for but it didn't exist and therefore caused a crash.

inconsistent use of tabs and spaces in indentation

Hi out there,had an issue with line 11.Can anyone tell me why it shows TabError bcz everything seems to be right?
Thank you

secret_word = "Lion"
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = False

while guess !=secret_word and not(out_of_guesses):
if guess_count < guess_limit:
guess = input("Enter guess: ")
11. guess_count += 1--------------------- File "Building a Guessing Game.py", line 11

               ^
                                                                 **TabError:** inconsistent use of tabs and spaces in indentation

                                                                                                    ***Repl Closed***


else:
    out_of_guesses = True   

if out_of_guesses:
print("Out_of_guesses, YOU LOSE!")
else:
print("You win!")

"KeyError: 'cruisingRangeAcOff'" starting climate control

I can successfully run get-leaf-info.py and see the expected output.

I used to be able to start the climate control successfully with the following script:

$ cat start-climate.py 
#!/usr/bin/python

import pycarwings2
import time
from ConfigParser import SafeConfigParser
import logging
import sys
import pprint

logging.basicConfig(stream=sys.stdout, level=logging.ERROR)


parser = SafeConfigParser()
candidates = [ 'config.ini', 'my_config.ini' ]
found = parser.read(candidates)

username = parser.get('get-leaf-info', 'username')
password = parser.get('get-leaf-info', 'password')

logging.debug("login = %s , password = %s" % ( username , password)  )

print "Prepare Session"
s = pycarwings2.Session(username, password , "NE")
print "Login..."
l = s.get_leaf()

result_key = l.start_climate_control()
time.sleep(60)
start_cc_result = l.get_start_climate_control_result(result_key)

#result_key = l.stop_climate_control()
#time.sleep(60)
#stop_cc_result = l.get_stop_climate_control_result(result_key)

But it now fails with the following error:

$ ./start-climate.py
Prepare Session
Login...
Traceback (most recent call last):
  File "./start-climate.py", line 29, in 
    start_cc_result = l.get_start_climate_control_result(result_key)
  File "/home/strowger/.local/lib/python2.7/site-packages/pycarwings2/pycarwings2.py", line 249, in get_start_climate_control_result
    return CarwingsStartClimateControlResponse(response)
  File "/home/strowger/.local/lib/python2.7/site-packages/pycarwings2/responses.py", line 319, in __init__
    self._set_cruising_ranges(status)
  File "/home/strowger/.local/lib/python2.7/site-packages/pycarwings2/responses.py", line 50, in _set_cruising_ranges
    self.cruising_range_ac_off_km = float(status[off_key]) / 1000
KeyError: 'cruisingRangeAcOff'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.