bimmerconnected / bimmer_connected

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

Send Message to Bmw #139

Closed sergiookey closed 4 years ago

sergiookey commented 4 years ago

Congratulations on your great work with this library. I use it daily. Would it be possible to send messages to the car?

rikroe commented 4 years ago

As far as I know the only method to send "messages" (in means like text messages) was the BMW labs IFTTT integration, which has been shutdown and required afaik the BMW Online CD package.

Using the API (as of now), we can only send messages using the Send POI where you need some coordinates (but should be able to send little snippets of arbitrary text as additionalInfo field).

So unfortunately, I don't think there is a good way.

robthebold commented 4 years ago

Using the API (as of now), we can only send messages using the Send POI where you need some coordinates (but should be able to send little snippets of arbitrary text as additionalInfo field).

Just for fun, I tried taking the lat and lon out of the PointOfInterest class constructor and called send_poi. And it works -- no "fake destination" needed. The message appears at the car without the "checkered flag" icon to set a new destination, no lat and lon in the message, it's just a message with a heading and text.

I haven't tried to test just how long the additionalInfo field can be, but I don't think this is as "hacky" as I'd have initially thought . . .

odelma commented 4 years ago

Hi, I've used a forked version of bmwcdapi.py (as I don't use OpenHab) and also tested sending a message to the car. It works well and the message comes to the "office" / all messages. In the original code it is here: https://github.com/jupe76/bmwcdapi/blob/2b00f0fe483041401291c3fb70a893c8a7b113f6/bmwcdapi.py#L265 I was wondering that maybe the same logic would work here as well...

rikroe commented 4 years ago

Thanks both of you! After your input I've debugged the API calls that the ConnectedDrive web application does. It have it's own API that is different from the one we're using (currently and also that we're trying to implement in #140).

Not sure if it is just some sort of proxy/url rewrite that takes place here. For a short-term solution, we pretty sure can use our existing sendpoi implementation with an addtional send_message cli command. The data structure send by the web app looks pretty the same, doesn't matter if I send a POI or a message:

POI

POST to https://www.bmw-connecteddrive.de/api/vehicle/myinfo/v1

{
    "vins": ["XXXXXXXXXXXXXXXXX"],
    "message": "powered by Googleâ„¢",
    "subject": "Zoo Frankfurt",
    "number": "1",
    "street": "Bernhard-Grzimek-Allee",
    "city": "Frankfurt am Main",
    "countryCode": "DE",
    "zip": "60316",
    "lat": "50.11580499999999",
    "lng": "8.702328800000032",
    "name": "Zoo Frankfurt"
}

message

POST to https://www.bmw-connecteddrive.de/api/vehicle/myinfo/v1

{
    "vins":["XXXXXXXXXXXXXXXXX"],
    "message": "...the Frankfurt zoo? There might be animals around :)",
    "subject":"Should we go to..."
}

Note: message has a length of 255 in the web interface.

I'll see if I can bring in a PR this weekend.

rikroe commented 4 years ago

Just a quick update - I got a PR ready but we need to merge some other stuff beforehand.

tungmeister commented 4 years ago

Any updates on this? Being able to send messages from home assistant would be great

gerard33 commented 4 years ago

This is merged in #164. Thanks @rikroe :+1:

lock[bot] commented 4 years ago

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.