robinostlund / homeassistant-volkswagencarnet

Volkswagen Carnet Component for home assistant
GNU General Public License v3.0
321 stars 60 forks source link

Invalid config #2

Closed kjetilsn closed 6 years ago

kjetilsn commented 6 years ago

Hi,

This is great! Cant wait to get this up and running!

This may be my own fault by wrong config, however I've checked and double checked, and cannot find the mistake. This is what's in the log: 2018-01-17 09:58:56 ERROR (MainThread) [homeassistant.setup] Error during setup of component volkswagen_carnet Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 199, in _async_setup_component component.setup, hass, processed_config) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 53, in setup hass.data[CARNET_DATA] = VWCarnet(hass, username, password) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 100, in __init__ self._carnet_login() File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 184, in _carnet_login responseData = json.loads(r.content) File "/usr/lib/python3.5/json/__init__.py", line 312, in loads s.__class__.__name__)) TypeError: the JSON object must be str, not 'bytes' This is my config:

volkswagen_carnet: username: kjetil@xxxxxx.com password: Blxxxxxxx update_interval: 1 # specify in minutes how often to fetch status data from carnet (optional, default 1 min)

(The indents are correct in my config but it does not show in the above example)

The files are in the correct folder by using Git clone.. It seems like a login issue?

My apologies if this is my own fault, I will then remove this post.

robinostlund commented 6 years ago

Hi, what version of requests and json do you use?

Brg Robin

robinostlund commented 6 years ago

Hi, can you try the latest version now?

Brg Robin

kjetilsn commented 6 years ago

Thank you for your help Robin! I'm afraid I don't know how to check the version of json and request... I'm running the latest stable of HA (0.61.0) on Hassbian. Do I need to change do "Dev"? I did a upgrade: "sudo hassbian-config upgrade hassbian" and re downloaded your code using "git clone" which now give me this error:

2018-01-17 13:53:55 ERROR (MainThread) [homeassistant.setup] Error during setup of component volkswagen_carnet Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 199, in _async_setup_component component.setup, hass, processed_config) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 88, in setup return update(utcnow()) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 75, in update fetch_vehicles(login_session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 60, in fetch_vehicles vw._carnet_get_vehicles(login_session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 355, in _carnet_get_vehicles data_owner_verification = self._carnet_get_owners_verification(session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 280, in _carnet_get_owners_verification return req.json() File "/srv/homeassistant/lib/python3.5/site-packages/requests/models.py", line 892, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.5/json/__init__.py", line 319, in loads return _default_decoder.decode(s) File "/usr/lib/python3.5/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 57 column 3 (char 58)

robinostlund commented 6 years ago

Oright, i don't use hassbian by myself so i have issues with troubleshooting, can you send me the output from command "pip3 list"?

Brg Robin

kjetilsn commented 6 years ago

Sure: aiohttp (2.3.7) astral (1.4) async-timeout (2.0.0) certifi (2017.11.5) chardet (3.0.4) cryptography (1.7.1) homeassistant (0.61.0) idna (2.6) Jinja2 (2.10) keyring (10.1) keyrings.alt (1.3) MarkupSafe (1.0) multidict (4.0.0) mysqlclient (1.3.12) pip (9.0.1) pyasn1 (0.1.9) pycrypto (2.6.1) pygobject (3.22.0) python-apt (1.1.0b5) pytz (2017.3) pyxdg (0.25) PyYAML (3.12) requests (2.18.4) SecretStorage (2.3.1) setuptools (33.1.1) six (1.10.0) typing (3.6.2) urllib3 (1.22) voluptuous (0.10.5) wheel (0.29.0) yarl (0.18.0)

robinostlund commented 6 years ago

Thanks, I think it is something related to decoding, i have changed so it is using utf-8 now, can you please try again?

Brg

kjetilsn commented 6 years ago

Robin, Downloaded and tried again, now I got this:

2018-01-18 09:19:05 ERROR (MainThread) [homeassistant.setup] Error during setup of component volkswagen_carnet Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 199, in _async_setup_component component.setup, hass, processed_config) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 92, in setup return update(utcnow()) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 79, in update fetch_vehicles(login_session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 64, in fetch_vehicles vw._carnet_get_vehicles(login_session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 353, in _carnet_get_vehicles data_owner_verification = self._carnet_get_owners_verification(session) File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 284, in _carnet_get_owners_verification return req.json() File "/srv/homeassistant/lib/python3.5/site-packages/requests/models.py", line 892, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.5/json/__init__.py", line 319, in loads return _default_decoder.decode(s) File "/usr/lib/python3.5/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 57 column 3 (char 58)

RobvanHamersveld commented 6 years ago

I have the same issue as @kjetilsn

I'm running Home Assistant 0.60.1 in a Python Virtual env on Ubuntu server.

Error message;

Error during setup of component volkswagen_carnet

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 193, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 92, in setup
    return update(utcnow())
  File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 79, in update
    fetch_vehicles(login_session)
  File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 64, in fetch_vehicles
    vw._carnet_get_vehicles(login_session)
  File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 353, in _carnet_get_vehicles
    data_owner_verification = self._carnet_get_owners_verification(session)
  File "/home/homeassistant/.homeassistant/custom_components/volkswagen_carnet.py", line 284, in _carnet_get_owners_verification
    return req.json()
  File "/srv/homeassistant/lib/python3.5/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 57 column 3 (char 58)

entries in configuration.yaml;

volkswagen_carnet:
  username: rob@<redacted>.nl
  password: '#<redacted>82'

Output of pip3 list;

aiodns (1.1.1)
aiohttp (2.3.6)
aiohttp-cors (0.5.3)
astral (1.4)
async-timeout (2.0.0)
buienradar (0.9)
cachetools (2.0.0)
certifi (2017.11.5)
chardet (3.0.4)
click (6.7)
click-datetime (0.2)
colorlog (3.0.1)
denonavr (0.5.5)
distro (1.1.0)
docopt (0.6.2)
dsmr-parser (0.11)
enum-compat (0.0.2)
future (0.16.0)
gTTS-token (1.1.1)
home-assistant-frontend (20171216.0)
homeassistant (0.60.1)
idna (2.6)
influxdb (4.1.1)
Jinja2 (2.10)
libpyfoscam (1.0)
limitlessled (1.0.8)
MarkupSafe (1.0)
multidict (3.3.2)
mutagen (1.38)
netdisco (1.2.3)
netifaces (0.10.6)
paho-mqtt (1.3.1)
pip (9.0.1)
PlexAPI (3.0.3)
protobuf (3.3.0)
psycopg2 (2.7.3.2)
pycares (2.3.0)
PyChromecast (0.8.2)
PyCRC (1.21)
pyfoscam (1.2)
pyharmony (1.0.18)
pyHS100 (0.3.0)
pyRFXtrx (0.20.1)
pyserial (3.4)
pyserial-asyncio (0.4)
python-dateutil (2.6.1)
python-telegram-bot (8.1.1)
pytz (2017.3)
PyYAML (3.12)
requests (2.18.4)
setuptools (36.2.7)
six (1.11.0)
sleekxmpp (1.3.3)
SQLAlchemy (1.1.15)
toonlib (1.0.0)
typing (3.6.2)
ua-parser (0.7.3)
urllib3 (1.22)
user-agents (1.1.0)
vincenty (0.1.4)
voluptuous (0.10.5)
websocket-client (0.44.0)
wheel (0.29.0)
xmltodict (0.11.0)
yarl (0.16.0)
zeroconf (0.19.1)
RobvanHamersveld commented 6 years ago

Ok, I've found a fix (or workaround, not sure).

On line 282 in custom_components/volkswagen_carnet.py I've changed;

url = session['base'] + '/portal/group/se/edit-profile/-/profile/get-vehicles-owners-verification' into url = session['base'] + '/portal/group/nl/edit-profile/-/profile/get-vehicles-owners-verification'

se to nl in the url.

I think it has something to do with the personal account settings.

Maybe its an alternative to add an option in the home-assistant config like this;

volkswagen_carnet:
  username: username
  password: password
  country: nl
kjetilsn commented 6 years ago

Thanks robvh84! This solved it for me as well, the sensors are now showing under <>. I change to "no"

Larsen1000 commented 6 years ago

This also solved my problem. Great work!

robinostlund commented 6 years ago

This will be solved in next version :)

robinostlund commented 6 years ago

This should now be fixed in the latest version, so once version 2.0.2 of volkswagencarnet is approved on pypi it should work.