Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMW 5 Series 2014 F10 #62

Closed
dws199 opened this issue Apr 3, 2018 · 51 comments
Closed

BMW 5 Series 2014 F10 #62

dws199 opened this issue Apr 3, 2018 · 51 comments
Assignees
Labels
enhancement 🆕 New feature or request waiting for user feedback ⏱️ Issue or question not fully clear and waiting for more info

Comments

@dws199
Copy link

dws199 commented Apr 3, 2018

@ChristianKuehnel @gerard33

I've managed to run the fingerprint command now and am seeing the following error, I have also attached the only file that was created

vehicles_0.txt
DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.account:getting new oauth token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "POST /webapi/oauth/token HTTP/1.1" 200 None
DEBUG:bimmer_connected.account:got new token frDNNgIsIbmPice5feQCvGA2Kme5Z55J with expiration date 2018-04-03 23:01:10.770055
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles HTTP/1.1" 200 None
DEBUG:bimmer_connected.state:requesting new data from connected drive
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles/WBA5C32050D629352/status HTTP/1.1" 400 None
ERROR:bimmer_connected.account:Unknown status code 400, expected 200
ERROR:bimmer_connected.account:{
"error" : {
"code" : 500,
"description" : "(SmartPhoneUtil-A-101) Mandatory parameter(s) missed or blank: dlat and dlon are required for BMW vehicles!"
}
}
Traceback (most recent call last):
File "/usr/bin/bimmerconnected", line 106, in
main()
File "/usr/bin/bimmerconnected", line 44, in main
args.func(args)
File "/usr/bin/bimmerconnected", line 73, in fingerprint
account.update_vehicle_states()
File "/usr/lib/python3.6/site-packages/bimmer_connected/account.py", line 205, in update_vehicle_states
car.update_state()
File "/usr/lib/python3.6/site-packages/bimmer_connected/vehicle.py", line 58, in update_state
self.state.update_data()
File "/usr/lib/python3.6/site-packages/bimmer_connected/state.py", line 92, in update_data
VEHICLE_STATUS_URL.format(server=self._account.server_url, vin=self._vehicle.vin), logfilename='status')
File "/usr/lib/python3.6/site-packages/bimmer_connected/account.py", line 128, in send_request
raise IOError(msg)
OSError: Unknown status code 400, expected 200

@gerard33
Copy link
Member

gerard33 commented Apr 3, 2018

@m1n3rva
Maybe lscType: NOT_SUPPORTED is showing that the car data is not fully available?
It's also here and here and for all working cars this field shows other data.

@dws199
Copy link
Author

dws199 commented Apr 5, 2018

Also just to note that I followed the instructions to run the fingerprint command but VIN no longer seems to be an argument, is that correct?

@m1n3rva
Copy link
Contributor

m1n3rva commented Apr 6, 2018

@dws199
The easy part of the answer 😉 is: Yes, the VIN is no longer needed. We figured out a way to list all the cars 🚗 associated with your connected drive account. And the vehicle_0.txt is exactly that list.

Now to the hard part about the status call failing. The response from the server contains the error message I was fearing to see:

"description" : "(SmartPhoneUtil-A-101) Mandatory parameter(s) missed or blank: dlat and dlon are required for BMW vehicles!"

I've heard rumours that in some cases you can only get the state of the vehicle if you're within a certain distance of the vehicle 😞 . I guess the same applies to your smartphone app 📱. I'm not sure why that is and which vehicles are affected by it. I'm also not sure if this is somehow related to the vehicle or the account.

So, what to do now. Some ideas:

  1. Always send a default position e.g. dlat=0.0 dlon=0.0 and see what happens
  2. Let the user of the library guess the position. In case of Home Assistant: use your home location then you will at least get some data when the vehicle is at home.
  3. Switch of the status-related attributes for such vehicles and only offer the remote services.

But none of these options is probably what you want 😢. But as we're using the same API as the smartphone 📱, we can't do any better than that 😐

@gerard33
Looking at the data in #60 there we also have the lscType: NOT_SUPPORTED but the server at least returns some data. Not much, but at least not an error message. So I guess this means something different.

@m1n3rva m1n3rva self-assigned this Apr 6, 2018
@dws199
Copy link
Author

dws199 commented Apr 7, 2018 via email

@dws199
Copy link
Author

dws199 commented Apr 17, 2018

@m1n3rva @gerard33

Is there anyway that you can provide me with a version that I can test with option 2? i.e. send the location of Hass (my home)? That would at least let me see if my car is home and some of the states of the vehicle.

@m1n3rva
Copy link
Contributor

m1n3rva commented Apr 22, 2018

Hey @dws199,

so I added the gps position 🌎 as parameter in #71. It does work with my vehicle, but is also worked before 😀. So I can't really test if that changes anything 😐 .

The new call is:

bimmerconnected status <user> <password> <region> <latitude> <longitude>

Where latitude and longitude are floating point numbers with your GPS position 🌎 .

Please checkout the PR and let me know if it works.

@m1n3rva m1n3rva added the enhancement 🆕 New feature or request label Apr 22, 2018
@dws199
Copy link
Author

dws199 commented Apr 22, 2018

Hi @m1n3rva

That sounds great! Sorry for the noob question but how do I go about testing it? I tried running pip3 install --upgrade bimmer_connected but it doesn't seem to get this version, I presume because it hasn't been commited? Should I copy the py file manually to my system instead?

Thanks

@m1n3rva
Copy link
Contributor

m1n3rva commented Apr 23, 2018

@dws199
this should work:

pip install --upgrade https://github.com/m1n3rva/bimmer_connected/archive/state_with_pos.zip

Or pip3 ..., depending on your installation..
Then you should be able to run the command line tool.

If you do not want to mess with your normal installation you can also create a virtual environment. And then install it there and also run your tests from there...

@dws199
Copy link
Author

dws199 commented Apr 24, 2018

@m1n3rva

Many thanks for your help with this. I have installed your new version as per your instructions but when I try and use it passing the lat and long I still get the same error "description" : "(SmartPhoneUtil-A-101) Mandatory parameter(s) missed or blank: dlat and dlon are required for BMW vehicles!". Also I did try passing an empty lat and long parameter (to make sure that I'm using the correct version of your code) and I do now see the prompt saying that these parameters are now optional.

So maybe the new parameters aren't being passed to the api correctly?

@m1n3rva
Copy link
Contributor

m1n3rva commented May 2, 2018

@dws199:
Guess I found the bug 🪲
The server probably expects the parameters as get-parameters encoded in the url, not as json string in the request body.

The weird thing is: I can send whatever parameters I want and the server does not complain either way. So I can't really check if that does anything...

I just uploaded the change to the same branch. Can you please try again?

@dws199
Copy link
Author

dws199 commented May 2, 2018

Hi @m1n3rva

That seems to have done the trick! It's now pulled back all the details of the vehicle!

Thanks!

@m1n3rva
Copy link
Contributor

m1n3rva commented May 2, 2018

Cool 😎 !

Are you a HomeAssistant user?
If so: How do you want to have this integrated with HomeAssistant? Should we take the position from the configuration.yaml?

homeassistant:
  latitude: xxx
  longitude: yyy

Or where should the position come from?

FYI: I just merged the change and deleted the branch. So if you want to keep testing, you have to take the master branch from now on:

pip install --upgrade https://github.com/m1n3rva/bimmer_connected/archive/master.zip

@dws199
Copy link
Author

dws199 commented May 2, 2018 via email

@m1n3rva
Copy link
Contributor

m1n3rva commented May 2, 2018

@gerard33 @ChristianKuehnel:
Could you have a look at the HomeAssistant side of this? I'm not really familiar with that. From looking at the sources, I guess this is the way to get the position from the configuration.yaml:
https://github.com/home-assistant/home-assistant/blob/ca54bbfcc942101fc8b4bfbc6eb3048f559fc114/homeassistant/helpers/sun.py#L17-L18

I can create a new release of bimmer_connected whenever you're ready 😄

@gerard33
Copy link
Member

gerard33 commented May 2, 2018

We can have a look at that 😀

In which scenario should we use the position from HA? Is that in case lscType = NOT_SUPPORTED or can we use it in all cases?

And while we are at it, we can also check for the unit_system in the config.yaml to determine if we should show the ranges in km or miles.
remainingRangeFuel
remainingRangeFuelMls

See this request on the forum.

@ChristianKuehnel
Copy link

My 2 cents:

1) Concerning the position:
Looking at the current implementation and trying it with my car, it seems that the server does not care what positions I'm sending to it. So we should be fine for the "nice" cars. And for the "picky" cars, I guess you need to send the right position to get a response. So in either case it would be fine to send the position of the HA installation.
--> Should be quite straight forward.

2) Concerning imperial vs. metric units:
The data from the server seems to only offer miles and km, but not remainingFuel in liters and gallons. So we might have to convert that ourselves.
--> Might not look nice in the code, but should be quite straight forward.

3) Concerning the lscType:
Here we need to figure out the right interpretation of the lscType field: Which of the values give us which attributes. And I would say this is something that should to decided within bimmer_connected as it's closely related to the server API.
--> @m1n3rva can you have a look at this? This probably needs also some trail and error based on the test data...

bottom line
I would combine 1) and 2) into one PR for HA and keep 3) as a separate task. I'm the small changes kind of a developer ;)

@gerard33
Do you have anything in the pipeline you would like to get merged first, before we add 1) and 2)? Otherwise you might have to rebase your changes...

@gerard33
Copy link
Member

gerard33 commented May 3, 2018

@ChristianKuehnel, the change I have in the pipeline as adding (binary) sensors for electric/hybrid cars. It's already available in the custom component and thanks to your tip regarding the .value I think it's ready now.
I plan to add the PR this weekend. So I would suggest that I add that first and then you can add the position and unit PR.

@gerard33
Copy link
Member

gerard33 commented May 4, 2018

The PR for the new sensors is there.
home-assistant/core#14293

@delstel
Copy link

delstel commented May 6, 2018

Hi Guys - I'm having exactly the same problem as dws199. I have the same 2014 Series 535d. I get the same fingerpring data ( exactly ). However, I can't gat any data back from the car. The iPhone app works perfectly. After setting up the component in hassio don't receive any sensor badges. I probably have a more basic mistake but I cant find it.

After reading all the posts, I can't determine if there was a fix for the problems discribed by dws199. So, ant help on that AND my more basic problem would be greatly appreciated.

Thanks

@gerard33
Copy link
Member

gerard33 commented May 6, 2018

@delstel
I guess you use the fingerprint command including the lat and lon option?
bimmerconnected status <user> <password> <region> <latitude> <longitude>

If that's the case then the reason that HA is not showing the data from your car is described here.
#62 (comment)
We plan to make an update for that by implementing scenario 2 where the lat/lon from the HA settings is being send so you will at least receive data when your car is home.

@delstel
Copy link

delstel commented May 6, 2018 via email

@delstel
Copy link

delstel commented May 6, 2018

Thanks, That exchange broaden my communication skills on GitHub.

@delstel
Copy link

delstel commented May 6, 2018

Another question. If I use the command --

bimmerconnected status user password region latitude longitude

I get --- bimmerconnected: error: unrecognized arguments: xx.0005 -xx.5769
Any idea why?

When I used -- If I use -- bimmerconnected status user password region vin
I got a simular response so I dropped the vin and it worked fine

@gerard33
Copy link
Member

gerard33 commented May 6, 2018

I get --- bimmerconnected: error: unrecognized arguments: xx.0005 -xx.5769
Any idea why?

Have you downloaded the latest version? The lat lon option is recently added.

@delstel
Copy link

delstel commented May 6, 2018

Was that the master

@gerard33
Copy link
Member

gerard33 commented May 7, 2018

@dws199

That seems to have done the trick! It's now pulled back all the details of the vehicle!

Can you share which data is available for you when adding the lat lon parameters?

@dws199
Copy link
Author

dws199 commented May 8, 2018

Hi @gerard33 , it seems to have stopped working for me now but I have a different error message as below. I tried upgraded first using pip3 install --upgrade bimmer_connected, is that correct

ERROR:bimmer_connected.account:Unknown status code 500, expected 200
ERROR:bimmer_connected.account:{
"error" : {
"code" : 500,
"description" : "(SmartPhoneUtil-A-302) External service failed. Could not retrieve vehicle status! Error: "(SmartPhoneUtil-E-302) External service failed. Failed to call service: CcgVehicle/CcgGetVehicleInformation""
}
}
Traceback (most recent call last):
File "/usr/bin/bimmerconnected", line 126, in

@delstel
Copy link

delstel commented May 8, 2018

Try this upgrade. It worked for me

pip install --upgrade https://github.com/m1n3rva/bimmer_connected/archive/master.zip

@dws199
Copy link
Author

dws199 commented May 8, 2018

@delstel Thanks for that but that is the version I was trying originally, I've just tried it again and I still get the same error

EDIT: Possibly the service is down as I'm unable to use any of the features on the Android app at the moment

@delstel
Copy link

delstel commented May 8, 2018

I’m not getting the error, but I don’t get any location data or mileage. I do get the status of all activated services. I’ll attach that fingerprint in a few minutes. Is this what you “were” getting and did you receive location coordinates?

@dws199
Copy link
Author

dws199 commented May 8, 2018

Unfortunately I didn't check carefully enough when it did work. However I've noticed on the android app that the mileage and fuel range barely seem to update unless I connect the phone to the car via usb every time I drive which makes the feature pointless really.

@delstel
Copy link

delstel commented May 8, 2018

Here's the status report:

https://github.com/m1n3rva/bimmer_connected/files/1980108/vehicles_0.txt

The fingerprint is similar - but no location

Has anyone else with our model, etc been able to get location data?

@delstel
Copy link

delstel commented May 8, 2018

One other note: I did spin up a new VM and install pip3 and the new version of bimmer_connected to get it to run.

@dws199
Copy link
Author

dws199 commented May 9, 2018

@delstel @gerard33

It's working for me now and I have a position in the status_0.txt file but it appears to be very wrong, currently it's showing that the car is in Sudan, I'm in the UK! Also I noticed that the mobile app is still saying that it can't retrieve the vehicle location despite the car being outside my house where it has worked before. However when logging on the connected drive website it picks up the location fine.

status_0.txt
vehicles_0.txt

@gerard33
Copy link
Member

gerard33 commented May 10, 2018

@dws199 the fingerprint script does anonymize the coordinates to 12.3456, 34.5678 so you don't accidently upload your real coordinates. So that's not an issue.
The data you have shared looks good, although it doesn't contain much data which we can actually use. So looks like in HA you can use device tracker, lock, flash lights and climate (after this is implemented in a new version). The hornblow is not activated for your car, I believe that's not allowed in the UK.

@dws199
Copy link
Author

dws199 commented May 10, 2018

@gerard33 Ok thanks for confirming. How can I implement this change in my Hass? As I believe a change is still required to get the default location from the main config file?

Also in the phone app I sometimes see fuel level/range and mileage of car but it seems to update very infrequently so is not really useful

@delstel
Copy link

delstel commented May 10, 2018

I'm Back to getting the same errors:

I have been running this in a VM with pip3 installed - ran fine - then errors - reinstalled the master - same issues - I must have done something wrong but I don't know what...... I'll keep looking.

DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.account:getting new oauth token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.us
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.us:443 "POST /webapi/oauth/token HTTP/1.1" 200 None
DEBUG:bimmer_connected.account:got new token ######## with expiration date 2018-05-10 22:05:57.716560
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.us
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.us:443 "GET /webapi/v1/user/vehicles HTTP/1.1" 200 None
DEBUG:bimmer_connected.state:requesting new data from connected drive
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.us
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.us:443 "GET /webapi/v1/user/vehicles/#########/status HTTP/1.1" 400 None
ERROR:bimmer_connected.account:Unknown status code 400, expected 200
ERROR:bimmer_connected.account:{
"error" : {
"code" : 500,
"description" : "(SmartPhoneUtil-A-101) Mandatory parameter(s) missed or blank: dlat and dlon are required for BMW vehicles!"
}
}
Traceback (most recent call last):
File "./bimmerconnected", line 106, in
main()
File "./bimmerconnected", line 44, in main
args.func(args)
File "./bimmerconnected", line 73, in fingerprint
account.update_vehicle_states()
File "/home/joe/.local/lib/python3.6/site-packages/bimmer_connected/account.py", line 205, in update_vehicle_states
car.update_state()
File "/home/joe/.local/lib/python3.6/site-packages/bimmer_connected/vehicle.py", line 58, in update_state
self.state.update_data()
File "/home/joe/.local/lib/python3.6/site-packages/bimmer_connected/state.py", line 92, in update_data
VEHICLE_STATUS_URL.format(server=self._account.server_url, vin=self._vehicle.vin), logfilename='status')
File "/home/joe/.local/lib/python3.6/site-packages/bimmer_connected/account.py", line 128, in send_request
raise IOError(msg)
OSError: Unknown status code 400, expected 200

@gerard33
Copy link
Member

@dws199 you have to wait for a new version which will support the lat lon before you car is supported in HA. It’s on our list :-)

@delstel based on the error message you haven’t entered the lat lon parameters.

@delstel
Copy link

delstel commented May 10, 2018

Here's my messages:

I'm using Master

bimmerconnected status me@me.com XXXXX north_america 34.xxx -84.xxx
usage: bimmerconnected [-h] {status,fingerprint,lightflash,image} ...
bimmerconnected: error: unrecognized arguments: 34.000 -84.576

bimmerconnected fingerprint me@me.com XXXXXXXX north_america 34.xxx -84.xxx
usage: bimmerconnected [-h] {status,fingerprint,lightflash,image} ...
bimmerconnected: error: unrecognized arguments: 34.xxx -84.xxx

@ChristianKuehnel
Copy link

@dws199 I just uploaded a first try at the integration with Home Assistant: home-assistant/core#14464

Please give that a try and let me know if it works.

⚠️ You have to activate the feature by adding send_location to your configuration.yaml(see description of the pull request)

@ChristianKuehnel
Copy link

@delstel What is the output of bimmerconnected fingerprint -h on your installation?

@ChristianKuehnel
Copy link

@m1n3rva some requests, based on the discussion above:

  1. Please increment the version number on master so it's different from the latest release. This solve resolve some potential dependency issues in HA.
  2. Please add a feature to show the version number on the comment line interface and the log output. This will probably help in analysing bug reports...

@dws199
Copy link
Author

dws199 commented May 15, 2018

@ChristianKuehnel This sounds great, thanks! How would I download this version with PIP so that I can test?

@ChristianKuehnel
Copy link

@dws199 to test a PR of Home Assistant you need to set up your machine according to this wiki page:
https://developers.home-assistant.io/docs/en/development_environment.html

@dws199
Copy link
Author

dws199 commented May 24, 2018

@ChristianKuehnel Thanks for this info, unfortunately I don't have a spare machine to test this on although I presume I can setup a vm. Is there anyway I can just update the bimmer script on my machine? Or use it as a custom component?

@m1n3rva
Copy link
Contributor

m1n3rva commented May 28, 2018

@dws199
some options I could think of:

  1. use the Python "virtualenv" to give you an isolated setup <-- recommended solution
  2. install the test setup in a virtual machine. This way you get a separate and clean installation
  3. you can probably install the changed files as custom components, but that probably messes up your project dependencies.

@m1n3rva m1n3rva added the waiting for user feedback ⏱️ Issue or question not fully clear and waiting for more info label May 28, 2018
@m1n3rva
Copy link
Contributor

m1n3rva commented Sep 23, 2018

no answer for a long time -> closing the ticket

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 🆕 New feature or request waiting for user feedback ⏱️ Issue or question not fully clear and waiting for more info
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants