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

Add support for Calendar API #27

Open
mseminatore opened this issue Apr 25, 2016 · 11 comments
Open

Add support for Calendar API #27

mseminatore opened this issue Apr 25, 2016 · 11 comments

Comments

@mseminatore
Copy link

No description provided.

@dewski
Copy link

dewski commented Apr 25, 2016

I don't believe there is an API, it's the iPhone app syncing with the car directly.

@timdorr
Copy link
Owner

timdorr commented Apr 26, 2016

Yep, @dewski is correct. The connection is done directly via Bluetooth.

@timdorr timdorr closed this as completed Apr 26, 2016
@ahimberg
Copy link

there is an API, the bluetooth connection is just controlling which calendar the car will display

@dewski
Copy link

dewski commented Apr 26, 2016

there is an API, the bluetooth connection is just controlling which calendar the car will display

The car says you need to keep the phone backgrounded. Do you have any requests/responses that support an API?

@ahimberg
Copy link

ahimberg commented Apr 26, 2016

Here’s a sample from 2014 when I first hooked it up. The official apps send just a couple days worth of data. I never set up background tasks in my app and just have a manual push at the moment.

POST https://owner-api.teslamotors.com/api/1/vehicles/###########/command/upcoming_calendar_entries HTTP/1.1
Content-Type: application/json; charset=utf-8
Authorization: Bearer xxx
Content-Length: 444
Host: owner-api.teslamotors.com
Connection: Keep-Alive
User-Agent: Model S 1.1.72 (Nexus 5; Android REL 4.4.4; en_US)
Accept-Encoding: gzip,deflate

{"calendar_data":{"access_disabled":false,"calendars":[{"color":"ff9a9cff","events":[{"color":"ff9a9cff","location":"1 LaLa St, Fremont CA","start":1411941600000,"organizer":"[email protected]","name":"Testlled":false,"all_day":false,"tentative":false,"end":1411945200000}],"name":"[email protected]"},{"color":"ff71aea7","[email protected]"}],"phone_name":"Nexus 5","uuid":"333239059961777"}}

This is for an event from 3-4pm on Sunday 9/28/2014, with a Red category color on the appointment.
in this same I had 2 accounts on the device with calendars but only 1 had events coming up. btw the colors don't seem to be used by the car right now, and not all fields are required (organizer at least isn't always available in a calendar item and its worked to send blank)

Note the times here are milliseconds since 1970 (vs seconds since 1970 for the scheduled timer time)
For the phone name, it appears just one of the name or id need to match, so what I did was have the user set up the phone name manually and send some random unique value as the uuid, which seems to work (neither value is exposed to apps on Windows Phone, well at least in the older APIs, uuid is available in WinPhone 8.1 apps but I still support 7.5 with my app)

@timdorr timdorr reopened this Apr 26, 2016
@timdorr
Copy link
Owner

timdorr commented Apr 26, 2016

That looks valid. Sorry for closing so quickly.

The phone_name is most likely the Bluetooth name for the phone. That's what the Summon and Homelink APIs use. I'll check the Android source for that uuid field. It's probably a hash of some stuff (BT name, broadcast MAC, etc etc).

@mseminatore
Copy link
Author

Yes, thanks Andy this is great info. Is the Bluetooth name typically what the car displays as the phone name?

@timdorr
Copy link
Owner

timdorr commented Apr 26, 2016

@mseminatore Yes, it's the Bluetooth name. On Android, you can set this via the Bluetooth settings. I believe on iOS, it's pulled from the name of the device (which applies in multiple contexts).

@mseminatore
Copy link
Author

mseminatore commented Apr 29, 2016

Hey Andy,

The JSON you shared looks like it may have some errors. Specifically
"name:Testled:false" and "[email protected]" without a key. Would you
mind re-pasting?

{"calendar_data":{"access_disabled":false,"calendars":[{"color":"ff9a9cff","events":[{"color":"ff9a9cff","location":"1
LaLa St, Fremont CA","start":1411941600000,"organizer":"[email protected]
","name":"Testlled":false,"all_day":false,"tentative":false,"end":1411945200000}],"name":"
[email protected]"},{"color":"ff71aea7","[email protected]"}],"phone_name":"Nexus
5","uuid":"333239059961777"}}

@mseminatore
Copy link
Author

mseminatore commented Dec 3, 2016

@ahimberg @timdorr Still looking to get some working calendar code. If anyone has valid POST payload for a calendar command that would be greatly appreciated!

@karekaa
Copy link
Contributor

karekaa commented Dec 4, 2019

Hi @mseminatore and @timdorr
I piped the json-code above through jq . on my Linux-machine, but jq complained about several syntax errors. After some tweaking, I managed to make this, which at least are legal json-syntax:

{
  "calendar_data": {
    "access_disabled": false,
    "calendars": [
      {
        "color": "ff9a9cff",
        "events": [
          {
            "color": "ff9a9cff",
            "location": "1 LaLa St, Fremont CA",
            "start": 1411941600000,
            "organizer": "[email protected]",
            "name": "Testlled",
            "all_day": false,
            "tentative": false,
            "end": 1411945200000
          }
        ],
        "name": "[email protected]"
      },
      {
        "color": "ff71aea7",
        "name": "[email protected]"
      }
    ],
    "phone_name": "Nexus 5",
    "uuid": "333239059961777"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants