robinostlund / homeassistant-volkswagencarnet

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

[BUG] Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8 #132

Closed amedeozottola closed 4 years ago

amedeozottola commented 4 years ago

Hi, thks for this plugin. I've installed this plugin today (ver. 4.4.8), in

and this configuration: volkswagencarnet: username: XXXXXXXX password: XXXXXXXXX scandinavian_miles: false scan_interval: minutes: 2 name: wvwzzzaazldnnnnnn: 'e-up! move E 61 E1F'

but I receive the following error: (i'v masked some personal data ;-)) Dettagli registro (ERROR) Logger: homeassistant.core Source: custom_components/volkswagencarnet/init.py:162 First occurred: 15:32:53 (8 occurrences) Last logged: 15:47:29

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/volkswagencarnet/init.py", line 162, in update if not await connection.update(): File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 348, in update await vehicle.update() File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 476, in update await self._connection.update_vehicle(self) File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 424, in update_vehicle response = await self.post('-/rts/get-latest-trip-statistics', url) File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 301, in post return await self._request(METH_POST, self._make_url(url, rel)) File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 277, in _request res = await response.json(loads=json_loads) File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1031, in json headers=self.headers) aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://www.portal.volkswagen-we.com/portal/delegate/dashboard/***************/-/rts/get-latest-trip-statistics Home Assistant has started!

robinostlund commented 4 years ago

Have you tried to login to web version of weconnect to see if it is any dialogs that needs to be filled in ther?

tubalainen commented 4 years ago

Made a PR :) https://github.com/robinostlund/homeassistant-volkswagencarnet/pull/133

amedeozottola commented 4 years ago

I use web application daily and i never see any dialogs ;-)

robinostlund commented 4 years ago

@amedeozottola Has it been working earlier? Which version are you running? and in whitch country are you located? :)

amedeozottola commented 4 years ago

@amedeozottola Has it been working earlier? Which version are you running? and in whitch country are you located? :)

I've just installed a 4.4.15, and the plugin hasn't worked in any of installed version (my first intallation is 4.4.8) :-( I'm located in Italy. thank's

zarya commented 4 years ago

i seem to have run in to the same problem altho the component used to work and i can access the web version without any problems.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 190, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/volkswagencarnet/__init__.py", line 179, in async_setup
    return await update(utcnow())
  File "/config/custom_components/volkswagencarnet/__init__.py", line 162, in update
    if not await connection.update():
  File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 348, in update
    await vehicle.update()
  File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 476, in update
    await self._connection.update_vehicle(self)
  File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 424, in update_vehicle
    response = await self.post('-/rts/get-latest-trip-statistics', url)
  File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 301, in post
    return await self._request(METH_POST, self._make_url(url, rel))
  File "/usr/local/lib/python3.7/site-packages/volkswagencarnet.py", line 277, in _request
    res = await response.json(loads=json_loads)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 1031, in json
    headers=self.headers)
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://www.portal.volkswagen-we.com/portal/delegate/dashboard/<REMOVED VIN>/-/rts/get-latest-trip-statistics
velkrosmaak commented 4 years ago

I get this too, but I have a new car which doesn't seem to be submitting these readings to car-net yet even though it's registered and set up correctly.

robinostlund commented 4 years ago

Can you try the latest release? i added some exceptions to when it tries to fetch last trips. So in the logs it will just say '_LOGGER.debug(f'Could not fetch last trips data: {err}')' instead of failing

lucky3004 commented 4 years ago

I get this message too. For me it was working with HA 0.106.6 and 4.1.5. Than it stopped working for some days. I updated to the current version, tried to install it with hacs. Updated my HA to 111.4 and 4.4.15. Nothing helped. With the browser and App is am able to access the data from the portal. Btw i am from Germany ;-)

robinostlund commented 4 years ago

@lucky3004 does it work with 4.4.16?

lucky3004 commented 4 years ago

yep it works again. Thx a lot!

amedeozottola commented 4 years ago

yes, now it works... but there are the same error in the log:

Dettagli registro (WARNING) Logger: volkswagencarnet Source: custom_components/volkswagencarnet/init.py:162 First occurred: 12:08:17 (1 occurrences) Last logged: 12:08:17

Failure when communcating with the server: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://www.portal.volkswagen-we.com/portal/delegate/dashboard/********/-/rts/get-latest-trip-statistics

robinostlund commented 4 years ago

@amedeozottola can you check in the home-assistant.log to see if it says debug before the error message? cause that error will still exists if you have debug mode enabled.

amedeozottola commented 4 years ago

Hi @robinostlund , in attach my home-assistant.log (from last HA reboot)

home-assistant.log

robinostlund commented 4 years ago

And how does your volkswagencarnet config look like? you can remove the username and password, i am wondering if you have specified the resources or not, if you have specified resources. Try to remove them in that case. It cannot see the state data from the car as debug mode is not enabled.

amedeozottola commented 4 years ago

volkswagencarnet: username: xxxxxx password: xxxxxxx spin: xxxxx scandinavian_miles: false scan_interval: minutes: 2 name: xxxxxxxxxxxxx: 'BiBi Car'

now I add the correct loglevel, restart... and resend ha.log ;-)

sorry :-)

amedeozottola commented 4 years ago

@robinostlund I'd like to send ha.log in private msg... it contains many sensible data ;-) how can I send a private message?

robinostlund commented 4 years ago

You can mail me on me@robinostlund.name 😊

amedeozottola commented 4 years ago

now, installing last update (4.4.19) the issue is resolved... :-) thks a lot ;-) UPDATE: after last reboot (I haven't upgraded anymore) the component has the same original problem :-(

UPDATE2: I restarted ha and it works again :-/ sorry ;-)