BMW X5
BMW Garage BMW Meets Register Search Today's Posts Mark Forums Read

Post Reply
 
Thread Tools Search this Thread
      04-13-2021, 01:40 PM   #1
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

[SOLVED] BMW API techy question - BMW Custom alerts

My BMW or BMW Connected app seems to have continuous data from my car’s location. I wish the BMW app itself, had a way to setup notifications when my car moves away from its current location.

Question is does BMW provide a public API that can be used to get these information? I want to build an app that will ping the BMW server every minute and get the car’s location and I can set to send a notification or critical alerts when my car moves away from my phone.

UPDATE: I was able to achieve this myself through an app. Refer to this post for details
https://g05.bimmerpost.com/forums/sh...72&postcount=7

Last edited by jonatious; 04-19-2021 at 12:25 PM..
Appreciate 1
      04-13-2021, 01:53 PM   #2
thereef510
Lieutenant Colonel
thereef510's Avatar
United_States
1163
Rep
1,773
Posts

Drives: '16 X5 35i, '20 X5 40i
Join Date: Apr 2019
Location: Tennessee

iTrader: (0)

Quote:
Originally Posted by jonatious View Post
My BMW or BMW Connected app seems to have continuous data from my car’s location. I wish the BMW app itself, had a way to setup notifications when my car moves away from its current location.

Question is does BMW provide a public API that can be used to get these information? I want to build an app that will ping the BMW server every minute and get the car’s location and I can set to send a notification or critical alerts when my car moves away from my phone.
I read somewhere on this forum that stuff like that is a privacy violation. IE another driver could have your car and be the legal driver and then you could use the car to track their precise whereabouts.
Appreciate 0
      04-13-2021, 04:18 PM   #3
lexieke
Private First Class
Belgium
70
Rep
131
Posts

Drives: X5
Join Date: Jan 2020
Location: Oilsjt

iTrader: (0)

There is an automation available for home assistant. Since this is open source you should be able to check that source for more info on the API. Or you can simply use home assistant for what you plan to do.

https://www.home-assistant.io/integr...nnected_drive/
Appreciate 1
jonatious249.50
      04-13-2021, 04:42 PM   #4
B///MWGuy
Lieutenant
262
Rep
504
Posts

Drives: 2019 X5 xDrive40i
Join Date: Feb 2013
Location: California

iTrader: (0)

Garage List
Happy to see another engineer with similar interest! If you need hand would love to participate on this
Appreciate 0
      04-13-2021, 06:41 PM   #5
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by thereef510 View Post
I read somewhere on this forum that stuff like that is a privacy violation. IE another driver could have your car and be the legal driver and then you could use the car to track their precise whereabouts.
Privacy violation depends on how BMW decides to authenticate the user before allowing such tracking. I am just trying to see the location of my car. There is no difference between being able to see it on the MyBMW app vs the one I am trying the build

Quote:
Originally Posted by lexieke View Post
There is an automation available for home assistant. Since this is open source you should be able to check that source for more info on the API. Or you can simply use home assistant for what you plan to do.

https://www.home-assistant.io/integr...nnected_drive/
this is awesome. Will see what I can figure out from this

Quote:
Originally Posted by B///MWGuy View Post
Happy to see another engineer with similar interest! If you need hand would love to participate on this
Sure will let you know
Appreciate 0
      04-15-2021, 04:35 PM   #6
MustGoFast
Private First Class
United_States
39
Rep
115
Posts

Drives: '21 X5 M50i
Join Date: Apr 2008
Location: Wisconsin

iTrader: (0)

I would assume you could probably reverse engineer their api as well without that much effort. The question is whether or not it's a violation of their ToS and whether or not they monitor for it or limit connections to known signatures or some other method of validation on the inbound which might make your attempt moot - but no way to know without trying

Curious what you learn.
Appreciate 1
      04-18-2021, 06:22 PM   #7
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

I was able to reverse engineer the open source app.
https://github.com/bimmerconnected/bimmer_connected

I spent a good time on Home Assistance understanding what it is. Looks like it is a popular automation tool and seems pretty powerful and has a wide variety of uses.
https://www.home-assistant.io/
https://www.home-assistant.io/integr...rive/#services

Anyway, instead of building the tool myself after reverse engineering, I felt it is safe and easier to just reuse this source. I did the following and now, I have the locations of my car when moving saved in a database for future and I have setup alerts to send me a text message to tell me when my car leaves home and when it moves from a static location(say after I stop for overnight at a hotel).
NOTE: This might not be trivial for non techy person.

This is what I did
1. Setup Home Assistant on AWS EC2 micro instance - https://www.home-assistant.io/installation/linux
2. Integrate BMW Connected to the Home Assistant app with your login to get your car connected
3. Setup REST API connection and be able to update the car’s state and get the location through the bimmer_connected integration.
4. Setup a simple console app that pings the home assistant through a HTTP request for the location of my car
5. Save the location to a DB and send alerts if necessary based on the last location and current location.

Let me know if you need any assistance to set up such things.

A small pic of the alerts I got today attached.
Attached Images
 
Appreciate 7
volodp193.50
Auricom4349.50
Helius16.50
sd306378.50
      04-19-2021, 10:23 AM   #8
SmartSaves
X5 Enthusiast
SmartSaves's Avatar
Canada
459
Rep
762
Posts

Drives: 2021 X5
Join Date: Aug 2020
Location: Neighbourhood of Santa

iTrader: (0)

Garage List
2021 BMW X5  [10.00]
This is amazing! Thanks for providing the details. I don't have enough basic knowledge to set this up, but I am sure a lot of experienced enthusiasts will benefit from your insights.

A friend of mine - another forum member- and I was brainstorming somewhat similar automation goals for dashcam power on/off.

We installed a remote controlled (RF 433 mHz) relay to cut the dashcam power on/off from a battery-pack. When we don't need to run the dashcam we simply cut the power to the dashcam using the remote controlled relay(instead of unplugging the cam or switching off the battery pack manually). We were thinking if we could automate this manual remote controlled on/off process, perhaps using the geo/WiFi location, NFC tagging etc. and also to get some sort of confirmation that inform us about the power status of the cam (on/off), but my software/API knowledge is rather limited.

I'll study your instructions above and see if I could learn a thing or two. Nonetheless, greatly appreciated you sharing the technical steps.
__________________
2021 X5, Excellence, M Sport, DHP, DAP, RSE, MW, Merino.
Appreciate 1
jonatious249.50
      04-19-2021, 12:22 PM   #9
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by SmartSaves View Post
This is amazing! Thanks for providing the details. I don't have enough basic knowledge to set this up, but I am sure a lot of experienced enthusiasts will benefit from your insights.

A friend of mine - another forum member- and I was brainstorming somewhat similar automation goals for dashcam power on/off.

We installed a remote controlled (RF 433 mHz) relay to cut the dashcam power on/off from a battery-pack. When we don't need to run the dashcam we simply cut the power to the dashcam using the remote controlled relay(instead of unplugging the cam or switching off the battery pack manually). We were thinking if we could automate this manual remote controlled on/off process, perhaps using the geo/WiFi location, NFC tagging etc. and also to get some sort of confirmation that inform us about the power status of the cam (on/off), but my software/API knowledge is rather limited.

I'll study your instructions above and see if I could learn a thing or two. Nonetheless, greatly appreciated you sharing the technical steps.
Feel free to ask me any questions. I will do my best to help out.

I am also planning on setting up another alert that will alert me when the doors are unlocked for too long, in case I forget to lock my car doors. Any other ideas are also welcome

I feel great having the ability to setup any kind of monitors or alerts on my car all the time
Appreciate 0
      04-21-2021, 01:32 AM   #10
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

I love the automation power I have on hand. I have set alerts on car’s non CLOSED states for windows, doors, hood and trunk. I forgot to fully close my window today and got this critical alert on my phone
Attached Images
 
Appreciate 4
Shawzy44158.00
sd306378.50
      04-21-2021, 01:52 AM   #11
pauricmcb
Private
Ireland
11
Rep
72
Posts

Drives: 328i M-Sport
Join Date: Jul 2014
Location: Dublin

iTrader: (0)

Great work, looking forward to playing with this when my X5 arrives
Appreciate 0
      04-24-2021, 01:12 AM   #12
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Updating one last achievement I wanted to do. Plotting my cars recent locations on a map
Attached Images
 
Appreciate 5
      04-24-2021, 09:07 AM   #13
Consuldean
Private First Class
76
Rep
194
Posts

Drives: BMW 21'' X6MC (F96)
Join Date: May 2020
Location: QA

iTrader: (0)

Quote:
Originally Posted by jonatious View Post
Updating one last achievement I wanted to do. Plotting my cars recent locations on a map
This is pretty cool.

Would it be possible to do this for a car that has all the hardware but is in a region where connected drive is not active (my car is available on MYBMW app but I don't have the updated location anymore)?
Appreciate 0
      04-24-2021, 09:45 AM   #14
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by Consuldean View Post
This is pretty cool.

Would it be possible to do this for a car that has all the hardware but is in a region where connected drive is not active (my car is available on MYBMW app but I don't have the updated location anymore)?
As long as BMW API returns the location it should work. After setting up home assistant and integrating BMW connected, I am using “ BMW Connected Drive: update_state” service call every 2 mins and there is a entity state for the car’s location and it should update. Before you automate, you should be able to test it out on the CLI itself
Appreciate 0
      04-24-2021, 11:05 AM   #15
Consuldean
Private First Class
76
Rep
194
Posts

Drives: BMW 21'' X6MC (F96)
Join Date: May 2020
Location: QA

iTrader: (0)

Quote:
Originally Posted by jonatious View Post
Quote:
Originally Posted by Consuldean View Post
This is pretty cool.

Would it be possible to do this for a car that has all the hardware but is in a region where connected drive is not active (my car is available on MYBMW app but I don't have the updated location anymore)?
As long as BMW API returns the location it should work. After setting up home assistant and integrating BMW connected, I am using “ BMW Connected Drive: update_state” service call every 2 mins and there is a entity state for the car’s location and it should update. Before you automate, you should be able to test it out on the CLI itself
I don't think it actually returns the location.

I think the connection isn't established as the car isn't in a location served by Connected Drive.

For illustration, the navigation in the car doesn't have the updated maps in the country where I'm but when I zoom out, I see the car recognize where it is on the world map.

Would you be willing to help me try this out?
Appreciate 0
      04-24-2021, 12:27 PM   #16
ikheetleon
Lieutenant
Netherlands
219
Rep
480
Posts

Drives: BMW X5 45e 2020
Join Date: May 2016
Location: Earth

iTrader: (0)

Nice to see more automation fans in here! :-)

I've wrote a script that will fetch and email the total milage at the end of every months obtained from the api.
Appreciate 2
jonatious249.50
volodp193.50
      04-24-2021, 12:59 PM   #17
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by ikheetleon View Post
Nice to see more automation fans in here! :-)

I've wrote a script that will fetch and email the total milage at the end of every months obtained from the api.
How are you contacting the Api server? Do you have a way to do it without home assistant integration?
Appreciate 0
      04-24-2021, 01:01 PM   #18
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by Consuldean View Post
I don't think it actually returns the location.

I think the connection isn't established as the car isn't in a location served by Connected Drive.

For illustration, the navigation in the car doesn't have the updated maps in the country where I'm but when I zoom out, I see the car recognize where it is on the world map.

Would you be willing to help me try this out?
Did you try contacting BMW? It looks like may be the SIM in the car at contacts the BMW server does not have any roaming connection in the new country? BMW NA might be your best option. Also ur inbox is full
Appreciate 0
      04-25-2021, 12:28 AM   #19
ikheetleon
Lieutenant
Netherlands
219
Rep
480
Posts

Drives: BMW X5 45e 2020
Join Date: May 2016
Location: Earth

iTrader: (0)

Quote:
Originally Posted by jonatious View Post
Quote:
Originally Posted by ikheetleon View Post
Nice to see more automation fans in here! :-)

I've wrote a script that will fetch and email the total milage at the end of every months obtained from the api.
How are you contacting the Api server? Do you have a way to do it without home assistant integration?
I use the bimmer-connected library from a linux machine.

https://pypi.org/project/bimmer-connected/
Appreciate 3
      05-31-2021, 07:04 PM   #20
hdahman
Lieutenant
hdahman's Avatar
United_States
237
Rep
430
Posts

Drives: BMW X5MC
Join Date: Apr 2020
Location: NJ&QC

iTrader: (0)

Awesome, can it be installed on raspberry?
Appreciate 0
      05-31-2021, 10:45 PM   #21
jonatious
Lieutenant
250
Rep
581
Posts

Drives: BMW X7
Join Date: Jan 2021
Location: Seattle

iTrader: (0)

Quote:
Originally Posted by hdahman View Post
Awesome, can it be installed on raspberry?
You definitely can.
https://www.home-assistant.io/installation/raspberrypi
Appreciate 1
hdahman236.50
      06-01-2021, 08:50 AM   #22
hdahman
Lieutenant
hdahman's Avatar
United_States
237
Rep
430
Posts

Drives: BMW X5MC
Join Date: Apr 2020
Location: NJ&QC

iTrader: (0)

does your method work also on homebridge or I have to install home assistant? thanks
Appreciate 0
Post Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 09:04 AM.




xbimmers
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
1Addicts.com, BIMMERPOST.com, E90Post.com, F30Post.com, M3Post.com, ZPost.com, 5Post.com, 6Post.com, 7Post.com, XBimmers.com logo and trademark are properties of BIMMERPOST