bimmerconnected / bimmer_connected

🚘 Library to query the status of your BMW or Mini from the ConnectedDrive portal
Apache License 2.0
362 stars 79 forks source link

KeyError: 'vehicles' #176

Closed whitwocb closed 4 years ago

whitwocb commented 4 years ago

Describe the issue BMW Connected Drive integration shows "unavailable" within any Lovelace cards.

Expected behavior Integration should connect successfully and create the regular set of sensors and entities for the following vehicles within my account G05 (2019 BMW X5) and F55 (2020 MINI 5-Door)

Home Assistant version Home Assistant 0.108.6 Last version: Not relevant as issue is independent of HA version.

Screenshots Log Output: 2020-04-18 11:33:24 WARNING (MainThread) [homeassistant.setup] Setup of bmw_connected_drive is taking over 10 seconds. 2020-04-18 11:33:28 ERROR (MainThread) [homeassistant.setup] Error during setup of component bmw_connected_drive Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component component.setup, hass, processed_config # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/init.py", line 51, in setup accounts.append(setup_account(account_config, hass, name)) File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/init.py", line 79, in setup_account cd_account = BMWConnectedDriveAccount(username, password, region, name, read_only) File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/init.py", line 126, in init self.account = ConnectedDriveAccount(username, password, region) File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 61, in init self._get_vehicles() File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 230, in _get_vehicles for vehicle_dict in response.json()['vehicles']: KeyError: 'vehicles'

Your config.yaml

# BMW ConnectedDrive Integration
bmw_connected_drive:
  name:
    username: see below
    password: see below
    region: rest_of_world

username/password as proven to work on BMW ConnectedDrive portal and iOS App.

Output of bimmer_connected fingerprint I'm using the out-of-the-box integration from https://www.home-assistant.io/integrations/bmw_connected_drive/ so not so sure how to run the fingerprint.

NOTE: It might take me a while to respond on GitHub (I only maintain this in my free time), but I will respond.

gerard33 commented 4 years ago

Did the component work earlier for you? Or is this a new setup for you? And are the BMW and Mini linked to the same Connected Drive account?

whitwocb commented 4 years ago

Hi Gerard

Yes - has been working for a while already, a few months at least.

Yes, both vehicles are linked to the same CD account. I first had the G05 against my account and it worked fine in HA. I logged into the MINI Connected app with the same username/password and added the F55 to my account once I'd taken delivery of it. The F55 entities appeared the next time I rebooted my HA install.

gerard33 commented 4 years ago

You have probably already tried, but can you restart HA to see if that solves the issue? No changes have been made to bimmer_connected in the last HA releases and the BMW API has some hickups every now and then. Normally that's automatically solved, but maybe you did a HA restart during those issues and then your account can't be setup correctly.

whitwocb commented 4 years ago

Yep - have restarted HA a number of times for other purposes (pick up new integrations as example).

How can I run a fingerprint from my HA install on a RPi ?

rikroe commented 4 years ago

When you connect to your RPi via SSH or directly in the terminal of the RPi you should be able to execute the fingerprint code as mentioned in the readme.

gerard33 commented 4 years ago

@whitwocb if you are running Home Assistant (formerly known as hassio), you can install the SSH & Web Terminal add-on. Once installed you can open the webui and install bimmer_connected as mentioned here.

After that you can run the fingerprint command.

fingerprint on hassio

whitwocb commented 4 years ago

I must be doing something really dumb here because I get this:

Screenshot 2020-04-23 at 20 17 39
gerard33 commented 4 years ago

Can you try pip so without the 3?

whitwocb commented 4 years ago

Also "command not found"

gerard33 commented 4 years ago

I see I have protection mode disabled in the add-settings. Can you try that?

whitwocb commented 4 years ago

Yep, okay.. Dumb mistake. Wasn't using the community add-on, rather the similarly named Official one. Give me a few minutes..

gerard33 commented 4 years ago

Yeah you need the community one indeed. When you have successfully run the command bimmerconnected fingerprint <username> <password> <region> you can copy the files being made to the share folder with cp /usr/lib/python3.8/site-packages/bimmer_connected/vehicle_fingerprint/2020-04-23_20-25-53/* /share

The share folder should then contain a files status_0.txt and vehicles_0.txt.

whitwocb commented 4 years ago

vehicles_0.txt status_0.txt status_1.txt

whitwocb commented 4 years ago

I've updated the Supervisor version too in case this helps... Let me check the entities again.

gerard33 commented 4 years ago

The data looks good and as the fingerprint command was able to get it, so should the Home Assistant integration be.

whitwocb commented 4 years ago

Its all lit back up like a Christmas tree so I must have had larger problems than just this integration. Maybe it was the most visible one for me? Anyway - all is well now and I'm sorry for wasting your time.

gerard33 commented 4 years ago

No problem. Good to hear it’s working and happy to see your Mini is working nicely with the integration together with your BMW.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.